Upload README.md
Browse files
README.md
CHANGED
|
@@ -25,6 +25,7 @@ license: mit
|
|
| 25 |
[](https://python.org)
|
| 26 |
[](https://github.com/ml-explore/mlx)
|
| 27 |
[](LICENSE)
|
|
|
|
| 28 |
|
| 29 |
---
|
| 30 |
|
|
@@ -58,11 +59,52 @@ This is a **major rewrite** that fixes the critical gaps in earlier community po
|
|
| 58 |
| **Model conversion** | PyTorchβMLX weight converter | β
**Updated for all z-lab drafters** |
|
| 59 |
| **Training** | Basic trainer | β
**Architecture-aware training** with adapter compatibility |
|
| 60 |
| **Benchmarking** | None | β
**Built-in benchmark** vs mlx_lm baseline |
|
|
|
|
| 61 |
|
| 62 |
---
|
| 63 |
|
| 64 |
## π¦ Installation
|
| 65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
```bash
|
| 67 |
pip install mlx-lm dflash-mlx-universal
|
| 68 |
```
|
|
@@ -151,6 +193,11 @@ python -m dflash_mlx.convert \
|
|
| 151 |
--model z-lab/Qwen3-4B-DFlash-b16 \
|
| 152 |
--output ./Qwen3-4B-DFlash-mlx
|
| 153 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 154 |
# Or in Python
|
| 155 |
from dflash_mlx.convert import convert_dflash_to_mlx
|
| 156 |
|
|
@@ -256,6 +303,13 @@ python -m dflash_mlx.serve \
|
|
| 256 |
--block-size 16 \
|
| 257 |
--port 8000
|
| 258 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 259 |
# Query with curl
|
| 260 |
curl http://localhost:8000/v1/chat/completions \
|
| 261 |
-H "Content-Type: application/json" \
|
|
@@ -351,9 +405,12 @@ dflash-mlx-universal/
|
|
| 351 |
β βββ test_adapters.py # Adapter tests (NEW)
|
| 352 |
βββ benchmark_m2.py # Apple Silicon benchmark
|
| 353 |
βββ setup_m2.sh # Automated setup script
|
|
|
|
|
|
|
|
|
|
| 354 |
βββ M2_PRO_MAX_GUIDE.md # Detailed M2 Pro Max guide
|
| 355 |
βββ README.md # This file
|
| 356 |
-
βββ pyproject.toml # Package configuration
|
| 357 |
```
|
| 358 |
|
| 359 |
---
|
|
@@ -361,15 +418,16 @@ dflash-mlx-universal/
|
|
| 361 |
## π§ͺ Testing
|
| 362 |
|
| 363 |
```bash
|
| 364 |
-
#
|
| 365 |
-
pytest tests/
|
|
|
|
|
|
|
|
|
|
| 366 |
|
| 367 |
-
#
|
|
|
|
| 368 |
pytest tests/test_adapters.py -v
|
| 369 |
pytest tests/test_model.py -v
|
| 370 |
-
|
| 371 |
-
# Run with coverage
|
| 372 |
-
pytest --cov=dflash_mlx tests/
|
| 373 |
```
|
| 374 |
|
| 375 |
---
|
|
@@ -456,3 +514,4 @@ MIT License β same as the original DFlash project.
|
|
| 456 |
**Get 6Γ faster LLM inference on Apple Silicon today!** π
|
| 457 |
|
| 458 |
> *Tested on M2/M3/M4 Pro/Max/Ultra with mlx-lm 0.24+.*
|
|
|
|
|
|
| 25 |
[](https://python.org)
|
| 26 |
[](https://github.com/ml-explore/mlx)
|
| 27 |
[](LICENSE)
|
| 28 |
+
[](https://github.com/astral-sh/uv)
|
| 29 |
|
| 30 |
---
|
| 31 |
|
|
|
|
| 59 |
| **Model conversion** | PyTorchβMLX weight converter | β
**Updated for all z-lab drafters** |
|
| 60 |
| **Training** | Basic trainer | β
**Architecture-aware training** with adapter compatibility |
|
| 61 |
| **Benchmarking** | None | β
**Built-in benchmark** vs mlx_lm baseline |
|
| 62 |
+
| **uv support** | pip only | β
**`uv` + `uv run` workflow** with lock files |
|
| 63 |
|
| 64 |
---
|
| 65 |
|
| 66 |
## π¦ Installation
|
| 67 |
|
| 68 |
+
### Option 1: `uv` (Recommended β ultra-fast, reproducible)
|
| 69 |
+
|
| 70 |
+
[`uv`](https://github.com/astral-sh/uv) is an extremely fast Python package manager written in Rust. It's the **recommended** way to install on macOS.
|
| 71 |
+
|
| 72 |
+
```bash
|
| 73 |
+
# 1. Install uv (one-time)
|
| 74 |
+
brew install uv
|
| 75 |
+
# or: curl -LsSf https://astral.sh/uv/install.sh | sh
|
| 76 |
+
|
| 77 |
+
# 2. Clone and setup
|
| 78 |
+
git clone https://huggingface.co/tritesh/dflash-mlx-universal.git
|
| 79 |
+
cd dflash-mlx-universal
|
| 80 |
+
|
| 81 |
+
# 3. One-command setup (creates venv, installs deps, locks)
|
| 82 |
+
chmod +x setup_uv.sh
|
| 83 |
+
./setup_uv.sh
|
| 84 |
+
|
| 85 |
+
# Or manually:
|
| 86 |
+
uv venv
|
| 87 |
+
uv pip install -e ".[dev,server]"
|
| 88 |
+
uv lock
|
| 89 |
+
```
|
| 90 |
+
|
| 91 |
+
**Why `uv`?**
|
| 92 |
+
- 10-100Γ faster than `pip` (written in Rust)
|
| 93 |
+
- Automatic virtual environment management
|
| 94 |
+
- Lock file (`uv.lock`) for reproducible installs
|
| 95 |
+
- `uv run` β run any script without activating venv manually
|
| 96 |
+
|
| 97 |
+
```bash
|
| 98 |
+
# Examples of uv workflow
|
| 99 |
+
uv run python examples/qwen3_4b_demo.py
|
| 100 |
+
uv run pytest tests/ -v
|
| 101 |
+
uv run python -m dflash_mlx.serve --target ... --draft ... --port 8000
|
| 102 |
+
uv run black dflash_mlx/
|
| 103 |
+
uv run ruff check dflash_mlx/
|
| 104 |
+
```
|
| 105 |
+
|
| 106 |
+
### Option 2: pip (Classic)
|
| 107 |
+
|
| 108 |
```bash
|
| 109 |
pip install mlx-lm dflash-mlx-universal
|
| 110 |
```
|
|
|
|
| 193 |
--model z-lab/Qwen3-4B-DFlash-b16 \
|
| 194 |
--output ./Qwen3-4B-DFlash-mlx
|
| 195 |
|
| 196 |
+
# Or with uv (recommended)
|
| 197 |
+
uv run python -m dflash_mlx.convert \
|
| 198 |
+
--model z-lab/Qwen3-4B-DFlash-b16 \
|
| 199 |
+
--output ./Qwen3-4B-DFlash-mlx
|
| 200 |
+
|
| 201 |
# Or in Python
|
| 202 |
from dflash_mlx.convert import convert_dflash_to_mlx
|
| 203 |
|
|
|
|
| 303 |
--block-size 16 \
|
| 304 |
--port 8000
|
| 305 |
|
| 306 |
+
# With uv (recommended)
|
| 307 |
+
uv run python -m dflash_mlx.serve \
|
| 308 |
+
--target mlx-community/Qwen3.5-9B-4bit \
|
| 309 |
+
--draft ./Qwen3.5-9B-DFlash-mlx \
|
| 310 |
+
--block-size 16 \
|
| 311 |
+
--port 8000
|
| 312 |
+
|
| 313 |
# Query with curl
|
| 314 |
curl http://localhost:8000/v1/chat/completions \
|
| 315 |
-H "Content-Type: application/json" \
|
|
|
|
| 405 |
β βββ test_adapters.py # Adapter tests (NEW)
|
| 406 |
βββ benchmark_m2.py # Apple Silicon benchmark
|
| 407 |
βββ setup_m2.sh # Automated setup script
|
| 408 |
+
βββ setup_uv.sh # β
UV setup script (NEW v0.2.0)
|
| 409 |
+
βββ .python-version # Python version pin for uv
|
| 410 |
+
βββ USAGE_GUIDE.md # Detailed usage guide
|
| 411 |
βββ M2_PRO_MAX_GUIDE.md # Detailed M2 Pro Max guide
|
| 412 |
βββ README.md # This file
|
| 413 |
+
βββ pyproject.toml # Package configuration (with uv support)
|
| 414 |
```
|
| 415 |
|
| 416 |
---
|
|
|
|
| 418 |
## π§ͺ Testing
|
| 419 |
|
| 420 |
```bash
|
| 421 |
+
# With uv (recommended)
|
| 422 |
+
uv run pytest tests/
|
| 423 |
+
uv run pytest tests/test_adapters.py -v
|
| 424 |
+
uv run pytest tests/test_model.py -v
|
| 425 |
+
uv run pytest --cov=dflash_mlx tests/
|
| 426 |
|
| 427 |
+
# Classic pip
|
| 428 |
+
pytest tests/
|
| 429 |
pytest tests/test_adapters.py -v
|
| 430 |
pytest tests/test_model.py -v
|
|
|
|
|
|
|
|
|
|
| 431 |
```
|
| 432 |
|
| 433 |
---
|
|
|
|
| 514 |
**Get 6Γ faster LLM inference on Apple Silicon today!** π
|
| 515 |
|
| 516 |
> *Tested on M2/M3/M4 Pro/Max/Ultra with mlx-lm 0.24+.*
|
| 517 |
+
```
|