mlx-dfloat 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mlx_dfloat/__init__.py +25 -0
- mlx_dfloat/_memory_caps.py +74 -0
- mlx_dfloat/_metal_decode.py +420 -0
- mlx_dfloat/_safetensors.py +185 -0
- mlx_dfloat/_scrub.py +29 -0
- mlx_dfloat/_version.py +24 -0
- mlx_dfloat/_watchdog.py +253 -0
- mlx_dfloat/bench/__init__.py +4 -0
- mlx_dfloat/bench/capped.py +165 -0
- mlx_dfloat/bench/preflight.py +216 -0
- mlx_dfloat/bench/results.py +227 -0
- mlx_dfloat/bench/scenario.py +191 -0
- mlx_dfloat/bench/table.py +251 -0
- mlx_dfloat/cli.py +30 -0
- mlx_dfloat/decode.py +120 -0
- mlx_dfloat/errors.py +45 -0
- mlx_dfloat/format.py +462 -0
- mlx_dfloat/integrate/__init__.py +1 -0
- mlx_dfloat/integrate/coverage.py +122 -0
- mlx_dfloat/integrate/memory.py +55 -0
- mlx_dfloat/integrate/names.py +121 -0
- mlx_dfloat/integrate/placeholders.py +72 -0
- mlx_dfloat/integrate/providers.py +271 -0
- mlx_dfloat/integrate/seam.py +196 -0
- mlx_dfloat/mflux/__init__.py +31 -0
- mlx_dfloat/mflux/flux1/__init__.py +1 -0
- mlx_dfloat/mflux/flux1/cli.py +419 -0
- mlx_dfloat/mflux/flux1/init.py +245 -0
- mlx_dfloat/mflux/flux1/lifecycle.py +159 -0
- mlx_dfloat/mflux/flux1/memory.py +201 -0
- mlx_dfloat/mflux/flux1/model.py +553 -0
- mlx_dfloat/mflux/flux1/names.py +79 -0
- mlx_dfloat/mflux/flux1/transformer.py +240 -0
- mlx_dfloat/py.typed +0 -0
- mlx_dfloat/reference.py +241 -0
- mlx_dfloat-0.1.0.dist-info/METADATA +325 -0
- mlx_dfloat-0.1.0.dist-info/RECORD +41 -0
- mlx_dfloat-0.1.0.dist-info/WHEEL +4 -0
- mlx_dfloat-0.1.0.dist-info/entry_points.txt +2 -0
- mlx_dfloat-0.1.0.dist-info/licenses/LICENSE +202 -0
- mlx_dfloat-0.1.0.dist-info/licenses/NOTICE +40 -0
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: mlx-dfloat
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Run DFloat11 losslessly compressed BF16 models on Apple Silicon with MLX: bit-identical output at roughly 70% of BF16 memory, as the DFloat11 authors report
|
|
5
|
+
Project-URL: Homepage, https://github.com/IonDen/mlx-dfloat
|
|
6
|
+
Project-URL: Source, https://github.com/IonDen/mlx-dfloat
|
|
7
|
+
Project-URL: Issues, https://github.com/IonDen/mlx-dfloat/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/IonDen/mlx-dfloat/blob/main/CHANGELOG.md
|
|
9
|
+
Author-email: Denis Ineshin <denis.ineshin@gmail.com>
|
|
10
|
+
License-Expression: Apache-2.0
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
License-File: NOTICE
|
|
13
|
+
Keywords: apple-silicon,bfloat16,df11,dfloat11,huffman,lossless-compression,metal,mflux,mlx,mlx-lm,model-compression
|
|
14
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Intended Audience :: Science/Research
|
|
17
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
18
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
19
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
24
|
+
Classifier: Typing :: Typed
|
|
25
|
+
Requires-Python: >=3.11
|
|
26
|
+
Requires-Dist: huggingface-hub>=0.24
|
|
27
|
+
Requires-Dist: mlx>=0.31
|
|
28
|
+
Requires-Dist: numpy>=1.26
|
|
29
|
+
Provides-Extra: mflux
|
|
30
|
+
Requires-Dist: mflux<0.21,>=0.20; (sys_platform == 'darwin') and extra == 'mflux'
|
|
31
|
+
Requires-Dist: psutil>=6; extra == 'mflux'
|
|
32
|
+
Description-Content-Type: text/markdown
|
|
33
|
+
|
|
34
|
+
# mlx-dfloat
|
|
35
|
+
|
|
36
|
+
Run [DFloat11](https://github.com/LeanModels/DFloat11) checkpoints on a Mac with [MLX](https://github.com/ml-explore/mlx).
|
|
37
|
+
|
|
38
|
+
DFloat11 is lossless compression for BF16 model weights. Each weight is 16 bits. DFloat11 stores the 8 exponent bits
|
|
39
|
+
as a short variable-length code, the same idea a zip file uses, and keeps the other 8 bits (the sign and the
|
|
40
|
+
fraction) exactly as they are. The DFloat11 authors report models at about 70% of their BF16 size with output that is
|
|
41
|
+
bit for bit the same as the original.[^size] Their decoder runs on NVIDIA GPUs only. This project is an independent
|
|
42
|
+
reader and decoder for Apple Silicon. The weights stay compressed in memory, and a Metal kernel decodes each block
|
|
43
|
+
on the GPU as it runs. That is how it generates FLUX.1 images through mflux.
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
one BF16 weight, 16 bits: s eeeeeeee mmmmmmm
|
|
47
|
+
| | |
|
|
48
|
+
| exponent: replaced by a variable-length code (compressed)
|
|
49
|
+
sign + fraction: kept as one raw byte (stored as is)
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Why that matters on a Mac: unified memory is the limit. The BF16 FLUX.1-dev transformer is about 24 GB,[^flux] more
|
|
53
|
+
than the GPU on a 32 GB machine can comfortably hold. At 70% it should come in under that line, and unlike 4-bit or
|
|
54
|
+
8-bit quantisation it changes nothing in the output. Whether it really fits on a given Mac is something this project
|
|
55
|
+
has to measure. The numbers measured so far are under "Measured numbers" below, and they cover a 32 GB Mac only.
|
|
56
|
+
|
|
57
|
+
## Status
|
|
58
|
+
|
|
59
|
+
Pre-alpha. Version 0.1.0 is on PyPI (see "Install" below). The first two milestones decided
|
|
60
|
+
whether the project would go ahead at all. The other two make it usable and its numbers reproducible:
|
|
61
|
+
|
|
62
|
+
1. A bit-exact reference decoder for published DFloat11 checkpoints. **Done.** Every compressed tensor of Qwen3-4B,
|
|
63
|
+
and sampled blocks of FLUX.1-schnell, FLUX.1-Krea-dev, Qwen-Image-Edit and Qwen-Image-Edit-2509, decode to
|
|
64
|
+
exactly the BF16 originals. That covers all four published versions of the checkpoint format.
|
|
65
|
+
2. A Metal decode kernel fast enough to run inside an image-generation step. **Done.** The kernel decodes the
|
|
66
|
+
published checkpoints bit-exactly at 50 GB/s on an M1 Max. Decoding every block just in time makes a 1024²
|
|
67
|
+
denoise step 5.0 % slower on FLUX.1-dev, 6.1 % slower on FLUX.1-schnell with a one-block evaluation run-ahead,
|
|
68
|
+
and 8.5 % slower on FLUX.1-schnell with per-block evaluation, all well under the project's ~25 % threshold.
|
|
69
|
+
That is measured against a control which,
|
|
70
|
+
on a reduced-depth transformer, agrees within 0.13 % with a run whose BF16 weights are all resident, through
|
|
71
|
+
the same per-block path. Those runs used a 1.4 GB MLX buffer-cache limit. The benchmark in milestone 4 uses
|
|
72
|
+
2.5 GB, and the overhead there is lower on both models. The recipe and numbers are in the changelog.
|
|
73
|
+
3. FLUX.1 image generation through mflux, straight from the compressed checkpoint to a saved image. **Done.**
|
|
74
|
+
FLUX.1-schnell, FLUX.1-dev and FLUX.1-Krea-dev each generate a 1024² image on a 32 GB M1 Max within the
|
|
75
|
+
machine's measured memory budget, and FLUX.1-schnell's output matches, bit for bit, the same transformer
|
|
76
|
+
streaming its BF16 weights block by block instead of the compressed ones. The command and the measured numbers
|
|
77
|
+
are under "Try it" below.
|
|
78
|
+
4. A reproducible benchmark and the measured 32 GB rows. **Done.** One command runs a scenario file that pins
|
|
79
|
+
the checkpoints, the prompt, the seed, the size and the cache limit, and writes one result file per condition
|
|
80
|
+
and round, and the tables under "Measured numbers" are generated from those files. A 32 GB M1 Max has measured
|
|
81
|
+
rows for all three FLUX.1 models. A two-run proof shows the memory watchdog stopping a run that crosses its
|
|
82
|
+
ceiling and leaving one under it alone.
|
|
83
|
+
|
|
84
|
+
All four milestones are done.
|
|
85
|
+
|
|
86
|
+
## Install
|
|
87
|
+
|
|
88
|
+
mlx-dfloat is for Macs with Apple Silicon and needs Python 3.11 or newer. Install it from PyPI:
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
pip install "mlx-dfloat[mflux]"
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Without the extra you get the checkpoint reader and the decoder. The `mflux` extra installs mflux 0.20, which the
|
|
95
|
+
`mlx-dfloat generate` command needs for FLUX.1 generation.
|
|
96
|
+
|
|
97
|
+
The parity scripts and the benchmark live in the repository, not in the package, so run them from a checkout with
|
|
98
|
+
[uv](https://docs.astral.sh/uv/):
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
git clone https://github.com/IonDen/mlx-dfloat
|
|
102
|
+
cd mlx-dfloat
|
|
103
|
+
uv sync --extra mflux
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
A plain `uv sync` installs the reader, the decoder and the parity scripts, and `--extra mflux` adds generation. The
|
|
107
|
+
benchmark runs with `uv run --group bench`, which installs mflux as well.
|
|
108
|
+
|
|
109
|
+
Every FLUX.1 base repository on the Hugging Face Hub is gated, so log in once with `hf auth login` and accept the
|
|
110
|
+
model's licence on its Hub page (details under "Generate a FLUX.1 image"). On disk, a DFloat11 FLUX.1 transformer
|
|
111
|
+
takes about 16 GB, and the base's text encoders, VAE and tokenizers about 10 GB more. The benchmark's `q8`
|
|
112
|
+
condition also needs the base's BF16 transformer, about 24 GB, which generation itself never downloads.
|
|
113
|
+
|
|
114
|
+
## Try it
|
|
115
|
+
|
|
116
|
+
The parity check compares a published DFloat11 repo with its BF16 original over HTTP range reads, so it fetches
|
|
117
|
+
only the blocks it checks instead of the whole model:
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
uv sync --group dev
|
|
121
|
+
uv run python -m scripts.verify_remote_group \
|
|
122
|
+
--df11-repo DFloat11/FLUX.1-schnell-DF11 \
|
|
123
|
+
--bf16-repo black-forest-labs/FLUX.1-schnell --bf16-subdir transformer \
|
|
124
|
+
--groups max-code --out result.json
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
A few gigabytes move over the network, so expect a few minutes. The script exits 0 when every compared value
|
|
128
|
+
matches, 1 on a real mismatch, and 2 on any other problem such as a repo it cannot read. It runs under a memory
|
|
129
|
+
watchdog and stops itself with exit 70 or 71 if it gets close to the machine's memory or to its time limit. For a
|
|
130
|
+
checkpoint that is already on disk, `scripts/verify_checkpoint.py` (run the same way, with `--df11` and `--bf16`
|
|
131
|
+
directories) checks every tensor and writes one result file per group, so an interrupted run resumes where it
|
|
132
|
+
stopped.
|
|
133
|
+
|
|
134
|
+
### Generate a FLUX.1 image
|
|
135
|
+
|
|
136
|
+
Generation needs the `mflux` extra (`pip install "mlx-dfloat[mflux]"`, see "Install"). The default repositories need
|
|
137
|
+
no extra flags:
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
mlx-dfloat generate --model schnell \
|
|
141
|
+
--prompt "A stone lighthouse on a rocky shore at dawn, waves breaking below it and a small fishing boat far out on the water" \
|
|
142
|
+
--seed 42 --steps 4 --height 1024 --width 1024 --report report.json
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
From a checkout, prefix the command with `uv run`. `--model` also takes `dev` and `krea-dev`. The command downloads that model's DFloat11 transformer and, from its
|
|
146
|
+
base repository, the text encoders, the VAE and the tokenizers; the base's own BF16 transformer is never fetched.
|
|
147
|
+
All three base repositories are gated on the Hub, so every model needs a Hub login (`hf auth login`, once).
|
|
148
|
+
FLUX.1-schnell's opens as soon as you accept its Apache-2.0 license on its Hub page. FLUX.1-dev's and
|
|
149
|
+
FLUX.1-Krea-dev's need a manual approval and come under Black Forest Labs' non-commercial license. Their text
|
|
150
|
+
encoders and VAE are byte-identical to FLUX.1-schnell's, so if you hold only the schnell license you can still run
|
|
151
|
+
dev or Krea-dev with `--base black-forest-labs/FLUX.1-schnell`. The dev and Krea-dev weights stay under the
|
|
152
|
+
non-commercial license whichever base supplies the encoders; you accept it on the FLUX.1-dev and FLUX.1-Krea-dev
|
|
153
|
+
Hub pages. Once everything is cached, set `HF_HUB_OFFLINE=1` to skip the Hub round trip that would otherwise check
|
|
154
|
+
for a newer revision on every run.
|
|
155
|
+
|
|
156
|
+
Measured on an M1 Max (32 GB, macOS 27.0, mlx 0.32.2, mflux 0.20.0, 2026-09-28/29) at 1024², one image per model:
|
|
157
|
+
FLUX.1-schnell (4 steps) peaked at 19.94 GiB and took 1 minute 54 seconds including imports; FLUX.1-dev (20 steps,
|
|
158
|
+
guidance 3.5) peaked at 20.10 GiB in 7 minutes 6 seconds; FLUX.1-Krea-dev (20 steps, guidance 3.5) peaked at 20.09
|
|
159
|
+
GiB in 7 minutes 2 seconds. The machine's budget for this, its recommended working set minus a 2 GiB reserve, is
|
|
160
|
+
22.96 GiB, so all three stay under it. `scripts/verify_image.py` checked FLUX.1-schnell's output against the same
|
|
161
|
+
transformer streaming its BF16 shards block by block instead of the compressed set: the final latents matched bit
|
|
162
|
+
for bit and the two images matched pixel for pixel. FLUX.1-dev and FLUX.1-Krea-dev were not checked this way,
|
|
163
|
+
because their BF16 transformers are gated and were not on disk to compare against. A later run of each model, the
|
|
164
|
+
one recorded under "Measured numbers", peaked within 0.2 GiB of these figures.
|
|
165
|
+
|
|
166
|
+
Generating a second image in the same process pays a reload. On a 32 GB Mac every call drops the compressed
|
|
167
|
+
transformer before the VAE decode, whatever the image size: at 1024² holding it next to the decode measured 23.29
|
|
168
|
+
GiB, over the budget, and smaller sizes have not been measured, so the estimate assumes the decode needs at least as
|
|
169
|
+
much there. The next call
|
|
170
|
+
reloads it, about 26 seconds. A Mac with a larger budget keeps the transformer loaded between calls. Even a repeated
|
|
171
|
+
prompt pays the reload: three consecutive 4-step FLUX.1-schnell calls with the same prompt each took about 103
|
|
172
|
+
seconds and peaked between 19.77 and 19.98 GiB. A different prompt adds a further
|
|
173
|
+
reload, this time of the text encoders instead of the transformer, since the two are never resident together.
|
|
174
|
+
`model.encode(*prompts)` pays that encoder reload once for several prompts, by encoding all of them while the
|
|
175
|
+
compressed transformer is not yet loaded.
|
|
176
|
+
|
|
177
|
+
Sizes above 1024² are refused for now, because no run above 1024² has been measured on this path. `--no-fit-check`
|
|
178
|
+
(`fit_check=False` in Python) runs them anyway, on a memory estimate that is then an extrapolation.
|
|
179
|
+
|
|
180
|
+
Quantisation on top of DFloat11 is refused because it would change the exact bits the format exists to preserve;
|
|
181
|
+
LoRA, img2img and ControlNet are refused because this path does not implement them; PiD decoding is refused
|
|
182
|
+
because it would need an 8 GB caption encoder resident next to the compressed transformer. `--negative-prompt` is
|
|
183
|
+
accepted and ignored, matching mflux's own FLUX.1 behavior. The command never overwrites an existing output file;
|
|
184
|
+
it picks a new name instead, and the report names the file it wrote.
|
|
185
|
+
|
|
186
|
+
## Measured numbers
|
|
187
|
+
|
|
188
|
+
The blocks below are generated from the files under `bench/results/` by `scripts/bench_table.py`, and a test fails
|
|
189
|
+
when the README and those files disagree. Every row carries one of three labels. MEASURED means the run used the
|
|
190
|
+
host's own memory limits on a Mac with that much memory. CAPPED means a larger Mac ran under a smaller Mac's MLX
|
|
191
|
+
memory limits and watchdog ceiling, which shows how much memory the run needs but not how that smaller Mac performs.
|
|
192
|
+
A CAPPED row uses MLX's default limits for a Mac of that size, which are looser than the caps `generate` would install
|
|
193
|
+
there, so its peak is not understated.
|
|
194
|
+
PROOF marks a run under a deliberately low watchdog ceiling, made only to show that the watchdog works; it never
|
|
195
|
+
appears as a tier row.
|
|
196
|
+
|
|
197
|
+
So far there are only 32 GB rows, and all of them are MEASURED, on one M1 Max. The table makes no claim about any
|
|
198
|
+
Mac it does not list. Each row is one `mlx-dfloat generate` run at 1024² with seed 42 (4 steps for FLUX.1-schnell,
|
|
199
|
+
20 for FLUX.1-dev and FLUX.1-Krea-dev), with `--tier 32` and `--report` writing the file in the last column. The
|
|
200
|
+
fit budget is the Mac's recommended GPU working set minus a 2 GiB reserve, the same budget `generate` uses to decide
|
|
201
|
+
whether a run fits. "Peak (watched)" is the larger of the process footprint the OS reports and MLX's active plus
|
|
202
|
+
cached memory, and a row's status is "target" when it stayed under the fit budget. The fit budget is not where the
|
|
203
|
+
watchdog stops a run on these rows. On the host's own tier the watchdog aborts at physical memory minus 4 GiB, 28 GiB
|
|
204
|
+
on this Mac (`watchdog_ceiling_bytes` in each file). On a CAPPED row the two are the same number.
|
|
205
|
+
|
|
206
|
+
<!-- bench:tier-table -->
|
|
207
|
+
| Mac | Fit budget (budget − reserve) | Model | DF11 size | Peak (watched) | Peak footprint | Peak MLX (active + cache) | Label | Status | Limits | Result |
|
|
208
|
+
|---|---|---|---|---|---|---|---|---|---|---|
|
|
209
|
+
| 32 GB | 22.96 GiB | FLUX.1-dev | 15.21 GiB | 19.96 GiB | 19.96 GiB | 19.19 GiB | MEASURED | target | host caps | `bench/results/tiers/dev-1024.json` |
|
|
210
|
+
| 32 GB | 22.96 GiB | FLUX.1-Krea-dev | 15.21 GiB | 20.04 GiB | 20.04 GiB | 19.19 GiB | MEASURED | target | host caps | `bench/results/tiers/krea-dev-1024.json` |
|
|
211
|
+
| 32 GB | 22.96 GiB | FLUX.1-schnell | 15.19 GiB | 19.78 GiB | 19.78 GiB | 19.03 GiB | MEASURED | target | host caps | `bench/results/tiers/schnell-1024.json` |
|
|
212
|
+
<!-- /bench:tier-table -->
|
|
213
|
+
|
|
214
|
+
The overhead block times one 1024² denoise step, five timed steps after two warm-up steps in each of three rounds,
|
|
215
|
+
with every condition in its own process. `df11` decodes each transformer block's weights from the compressed set
|
|
216
|
+
just before the block runs and evaluates after every block. `control` runs the same graph with the same per-block
|
|
217
|
+
evaluation, but its weights were decoded once before timing started, so the gap between the two is the cost of
|
|
218
|
+
decoding. The depth-2 pair evaluates one block behind instead, so the CPU can queue the next block, decode included,
|
|
219
|
+
while the GPU runs the current one. The eval policy cost is what evaluating after every block adds by itself:
|
|
220
|
+
`control` minus a control that evaluates once per step, with no decode involved. A negative value means the
|
|
221
|
+
per-block control was the faster of the two. The q8 ratio is DF11 with per-block evaluation over mflux's own
|
|
222
|
+
transformer quantised to 8 bits, with one eval per step. The q8 step runs under the scenario's 2.5 GB cache limit,
|
|
223
|
+
like every other condition here; mflux's own generate sets no cache limit, so this is not quite mflux's q8 as you
|
|
224
|
+
would run it. A q8 step changes the weights and the output; a DF11 step does not.
|
|
225
|
+
|
|
226
|
+
On FLUX.1-dev a step costs 3.52 % more with per-block evaluation (19.24 s against the control's 18.59 s) and 4.61 %
|
|
227
|
+
more with the depth-2 run-ahead. On FLUX.1-schnell the two figures are 4.05 % (19.28 s against 18.53 s) and 4.24 %.
|
|
228
|
+
Round 1 of the schnell run saw GPU load from outside the bench; the same pooled medians over rounds 2 and 3 alone give
|
|
229
|
+
+4.2 % for per-block evaluation. The dev depth-2 figure pools three rounds that disagree. Taken one round at a time
|
|
230
|
+
(each round's DF11 median over its own control's), they read −1.6 %, +5.9 % and +6.5 %, because round 1's depth-2
|
|
231
|
+
control ran slow at 19.50 s against 18.77 s and 18.69 s later; rounds 2 and 3 alone give +6.2 %. Evaluating one
|
|
232
|
+
block behind did not help on either model. Evaluating after every
|
|
233
|
+
block cost 0.41 s per step on schnell and nothing measurable on dev, where the per-block control came out 0.07 s
|
|
234
|
+
faster, less than either condition moved between rounds. Both sides of the overhead comparison pay that cost, so it is
|
|
235
|
+
not part of the decode overhead. A DF11 step takes 1.26 times as long as mflux's q8 step on dev (15.26 s) and 1.35
|
|
236
|
+
times on schnell (14.25 s). Treat both ratios as rough: the q8 step's median moved by about 2 s from one round to the
|
|
237
|
+
next in both scenarios, while the DF11 step's moved by 0.7 s at most. The q8 step also peaked lower, at 14.8–14.9 GiB
|
|
238
|
+
against DF11's 19.7–20.0 GiB. What DF11 keeps and q8 gives up is the exact BF16 output.
|
|
239
|
+
|
|
240
|
+
The control was validated once with `scripts/bench_control_validation.py`, at the earlier 1.4 GB cache limit and on
|
|
241
|
+
a reduced-depth transformer (4 double and 8 single blocks instead of 19 and 38): it agreed within 0.13 % with a run
|
|
242
|
+
whose BF16 weights were all resident.
|
|
243
|
+
|
|
244
|
+
<!-- bench:overhead -->
|
|
245
|
+
FLUX.1-dev, 1024², per-block evaluation: +3.5 % (depth-2: +4.6 %); eval policy cost -0.07 s/step; DF11 (per-block) over the mflux q8 step (one eval per step, same cache limit): 1.26×
|
|
246
|
+
|
|
247
|
+
Command: `uv run --group bench python -m scripts.bench_flux1 bench/scenarios/flux1-dev-1024.toml` (preflight skipped: not_charging)
|
|
248
|
+
|
|
249
|
+
FLUX.1-schnell, 1024², per-block evaluation: +4.0 % (depth-2: +4.2 %); eval policy cost 0.41 s/step; DF11 (per-block) over the mflux q8 step (one eval per step, same cache limit): 1.35×
|
|
250
|
+
|
|
251
|
+
Command: `uv run --group bench python -m scripts.bench_flux1 bench/scenarios/flux1-schnell-1024.toml`
|
|
252
|
+
|
|
253
|
+
Apple M1 Max, 32 GB, macOS 27.0.1, mlx 0.32.2, mflux 0.20.0, git d164fc5, 2026-10-01
|
|
254
|
+
|
|
255
|
+
DF11 and the mflux q8 step both run under a 2.5 GB MLX buffer-cache limit (decimal GB).
|
|
256
|
+
<!-- /bench:overhead -->
|
|
257
|
+
|
|
258
|
+
The scenario result files name the commit their runs used as it was on its pull-request branch; the `generate`
|
|
259
|
+
reports behind the tier rows and the harness proof record no commit. Merging onto `main` gave those commits new IDs
|
|
260
|
+
without changing their content: `d164fc5` (the scenario and tier runs) is `c29714d` on `main`, and `9c51869` (the
|
|
261
|
+
harness proof) is `3d142a7`.
|
|
262
|
+
|
|
263
|
+
The harness proof runs `mlx-dfloat generate` twice under the same lowered watchdog ceiling, once at a size that
|
|
264
|
+
stays under it and once at a size that does not. `bench/results/harness-proof/README.md` gives both commands and
|
|
265
|
+
the arithmetic behind the ceiling.
|
|
266
|
+
|
|
267
|
+
<!-- bench:harness-proof -->
|
|
268
|
+
Harness proof: under one 19.25 GiB cap, a 512² run passed with a watched peak of 18.64 GiB, and a 1024² run was stopped by the watchdog (memory, counter footprint) at 19.32 GiB. Records: `bench/results/harness-proof`.
|
|
269
|
+
<!-- /bench:harness-proof -->
|
|
270
|
+
|
|
271
|
+
### Reproduce the numbers
|
|
272
|
+
|
|
273
|
+
The overhead numbers come from one command per scenario, run from a checkout:
|
|
274
|
+
|
|
275
|
+
```
|
|
276
|
+
uv run --group bench python -m scripts.bench_flux1 bench/scenarios/flux1-schnell-1024.toml --results-root <a fresh directory>
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
`bench/results/` holds the published run. Without `--results-root` the command works in that directory, and it
|
|
280
|
+
refuses the committed files as soon as the code differs from the version that wrote them.
|
|
281
|
+
|
|
282
|
+
`bench/scenarios/` holds one scenario for FLUX.1-schnell and one for FLUX.1-dev. A scenario pins the DFloat11 and
|
|
283
|
+
base snapshot revisions, the prompt, the seed, the size, the step counts, the rounds, the cache limit and the
|
|
284
|
+
conditions. The command reads both checkpoints from the local Hugging Face cache and never downloads; when a pinned
|
|
285
|
+
snapshot is missing, it exits 2 and prints the `hf download` command that fetches it. Each condition and round runs
|
|
286
|
+
as its own process with its own memory watchdog, and writes its own JSON under `<results root>/<scenario>/`. An
|
|
287
|
+
interrupted run picks up where it stopped, and results from a different scenario or different code are refused
|
|
288
|
+
rather than mixed in.
|
|
289
|
+
|
|
290
|
+
Before anything runs, a launch check samples the machine and refuses to start (exit 2, naming what failed) when the
|
|
291
|
+
Mac is on battery, below 40 % battery, or on a charger that is not charging a battery below half; when
|
|
292
|
+
`pmset -g therm` reports a CPU speed limit below 100 or the lid is closed; when less than 20 GiB of disk or less
|
|
293
|
+
than 20 % of memory is free; or when another heavy process (a bench, a test run, mflux or mlx-lm) holds 1 GiB or
|
|
294
|
+
more. Timings taken in those states are not comparable. When macOS has recorded no CPU speed limit, as on the Mac
|
|
295
|
+
that produced these numbers, the speed-limit check passes. A refused launch writes nothing; once a run is accepted,
|
|
296
|
+
the sample is saved as `preflight.json` next to the results. The check runs again before each condition's process
|
|
297
|
+
starts, because a small charger can fall behind over a 40-minute run. When a check fails mid-run, the command stops
|
|
298
|
+
before that process (exit 2), `report.json` records which checks failed, and running the same command again picks
|
|
299
|
+
up from there. `--skip-preflight` skips every check, and the report records that it did. The busy check lists
|
|
300
|
+
a process by its executable name and pid only; set `MLX_DFLOAT_PREFLIGHT_EXCLUDE` to comma-separated substrings of
|
|
301
|
+
command lines that should not count as busy.
|
|
302
|
+
|
|
303
|
+
`mlx-dfloat generate --tier GB` runs under a smaller Mac's MLX memory and cache limits, with that Mac's watchdog
|
|
304
|
+
ceiling and fit budget, and labels its report CAPPED; `--tier` set to the host's own size keeps the host's limits
|
|
305
|
+
and gives the MEASURED rows above. `--memory-ceiling BYTES` lowers the watchdog ceiling alone, under the host's
|
|
306
|
+
limits, and labels the report PROOF. After a new run, `uv run python -m scripts.bench_table` rewrites the blocks
|
|
307
|
+
above, and `--check` exits 1 when they are out of date.
|
|
308
|
+
|
|
309
|
+
## Relationship to DFloat11
|
|
310
|
+
|
|
311
|
+
This is not a fork and not affiliated with the DFloat11 authors. It reads the checkpoint format they publish. Credit
|
|
312
|
+
for the method goes to them: *70% Size, 100% Accuracy: Lossless LLM Compression for Efficient GPU Inference via
|
|
313
|
+
Dynamic-Length Float* ([arXiv:2504.11651](https://arxiv.org/abs/2504.11651)).
|
|
314
|
+
|
|
315
|
+
## License
|
|
316
|
+
|
|
317
|
+
Apache-2.0. See [LICENSE](https://github.com/IonDen/mlx-dfloat/blob/main/LICENSE).
|
|
318
|
+
[NOTICE](https://github.com/IonDen/mlx-dfloat/blob/main/NOTICE) credits the DFloat11 work, mflux and the test-only encoder
|
|
319
|
+
copied from the DFloat11 repository, each with its licence.
|
|
320
|
+
|
|
321
|
+
[^size]: Reported in the DFloat11 paper ([arXiv:2504.11651](https://arxiv.org/abs/2504.11651)). The exponent bits of
|
|
322
|
+
trained weights are far from uniformly distributed, which is what makes them compressible; the exact ratio
|
|
323
|
+
depends on the model and is slightly different for each one.
|
|
324
|
+
[^flux]: The FLUX.1-dev transformer has about 12 billion parameters. In BF16 each takes 2 bytes, so about 24 GB for
|
|
325
|
+
the weights alone, before activations and before the text encoders.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
mlx_dfloat/__init__.py,sha256=-vfS89uy_7go2JbtUDKr9RLbZLCLR_Qy1db6P05qmB4,599
|
|
2
|
+
mlx_dfloat/_memory_caps.py,sha256=XIElrD3VrnQdQnfiixOczJE9pTl-o8sp-iuIh5fG-8M,2576
|
|
3
|
+
mlx_dfloat/_metal_decode.py,sha256=MsHwP-5aKWx2kkHsXl0Y0dQJQvBKAEX1qm1qC0l-RxY,17827
|
|
4
|
+
mlx_dfloat/_safetensors.py,sha256=kO15MCnP82L6JK-0PHsgT9jz95oHo9VKHKXZOivWsD4,6665
|
|
5
|
+
mlx_dfloat/_scrub.py,sha256=yf2mu0UWA6TB-ATOulFEzeGwgRhHydN-7WyV-qZ4o9Y,1050
|
|
6
|
+
mlx_dfloat/_version.py,sha256=n_5vdJsPNu7wZ57LGuRL585uvll-hiuvZUBWzdG0RQU,520
|
|
7
|
+
mlx_dfloat/_watchdog.py,sha256=cWBWLeOsVf1c4CViEwQSPp0L-WWJlZorg9VLzky4-7U,10587
|
|
8
|
+
mlx_dfloat/cli.py,sha256=w1Yp5Xu3eQnLsJpLQs7QZMDJwXb4ySbeT905wIbRh6U,1075
|
|
9
|
+
mlx_dfloat/decode.py,sha256=4Zptg1FihoLaafSaUM8IZXVc_yxGLufh-Wbl4BNs8gM,4767
|
|
10
|
+
mlx_dfloat/errors.py,sha256=oAt4erzEc-bINNvzXxYvKD4MIgfRRaN1ixbxJSq0b4c,1400
|
|
11
|
+
mlx_dfloat/format.py,sha256=80fnB5aDp6jNq0XLhWPNw5vjuFubDY5l4GPzLmN8p28,19156
|
|
12
|
+
mlx_dfloat/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
|
+
mlx_dfloat/reference.py,sha256=yqU555W9EJFdL34Ni0AWAF6TDq_L-zVTdPtMPCKW2Uw,9266
|
|
14
|
+
mlx_dfloat/bench/__init__.py,sha256=mgxeT2vep7PCxTD3PgU_JHKOYgbaqBZVwCkZ5tv2948,219
|
|
15
|
+
mlx_dfloat/bench/capped.py,sha256=8CW-LOKSW9d9zftzQ0sGssNA1ty4NLJ6aXJH5p-2b90,5861
|
|
16
|
+
mlx_dfloat/bench/preflight.py,sha256=lIHyQq_SsHAib0YYckI1i-hhdBPbfByVQ8HMoc3srLE,7699
|
|
17
|
+
mlx_dfloat/bench/results.py,sha256=8HByYbAYb0pNDgQ6tlR9gZ7JMf_4YVIFRaoyzS6n4tw,8005
|
|
18
|
+
mlx_dfloat/bench/scenario.py,sha256=StcDcijdDqpdF4xWVuRqGb1EZPmAmzp89Jm0Tu2da3M,6837
|
|
19
|
+
mlx_dfloat/bench/table.py,sha256=xdYrObiNwRGhZtzv4kmtmmcMvCxeq7oG6t8Iy8u6Pho,10330
|
|
20
|
+
mlx_dfloat/integrate/__init__.py,sha256=89XcVKcdvJC814PFpyPnB8FNmi4Gryczytbdmq9PWFU,99
|
|
21
|
+
mlx_dfloat/integrate/coverage.py,sha256=wg1nR6r_uFRPIme8Lxx_e8Z6iZM8YYLh0JJawAsesag,4774
|
|
22
|
+
mlx_dfloat/integrate/memory.py,sha256=QcE82nIFFKCcVoLvIMfUGLTNe20K9OPBtAu48TRdNpM,1945
|
|
23
|
+
mlx_dfloat/integrate/names.py,sha256=nWeAEcfPmJAb9ah2tVX7S7xGLE4lPVppBUGUz6Tv2Bw,4828
|
|
24
|
+
mlx_dfloat/integrate/placeholders.py,sha256=zhjl9B1rtLZYY9IzkknngU6MHBP9i0MMd1qtMNJVwH0,2813
|
|
25
|
+
mlx_dfloat/integrate/providers.py,sha256=w6IaUCo2SM03eNMw5LNhpV1v_11BlDQzIdlnBtxd2ns,11212
|
|
26
|
+
mlx_dfloat/integrate/seam.py,sha256=PV1ZtpKxNdgqIswV-YnI0Rnk2tDsoCmdnHD3DrvGl-E,7271
|
|
27
|
+
mlx_dfloat/mflux/__init__.py,sha256=eCrVbDAbtwZuP-c8fXrKmQowiC4Hb0McjwDZdglqVkk,1051
|
|
28
|
+
mlx_dfloat/mflux/flux1/__init__.py,sha256=pnikawmujh7CF3zQ8ioe4D3zsuvlQFs9FMBEwvnwB4A,76
|
|
29
|
+
mlx_dfloat/mflux/flux1/cli.py,sha256=Eh7PaXTMKk7qE8l2Ffo8x_Dj24iah7uy7uEsqyK0byM,16429
|
|
30
|
+
mlx_dfloat/mflux/flux1/init.py,sha256=0uOdahWKc3GDCtxhZFk1R46jM6oIJlTC8kJtafQqHzA,10029
|
|
31
|
+
mlx_dfloat/mflux/flux1/lifecycle.py,sha256=QBu6Uj2D7XwvFRd5a6dmhGgwMs3lTu5JtBbTh9qsagE,6309
|
|
32
|
+
mlx_dfloat/mflux/flux1/memory.py,sha256=YR5sWHjjAvtnBKBwCW8GV_vn6001Pgz-fkw1c94HKm0,7666
|
|
33
|
+
mlx_dfloat/mflux/flux1/model.py,sha256=I8SAXK4VZU5k5V3b6esTBpjXSP-cy2baZ53I9j1V0hw,23900
|
|
34
|
+
mlx_dfloat/mflux/flux1/names.py,sha256=h2M1IRXLmgmG3SuRyX9NarTB1f3Nrp19fsFdUbHjbb4,3812
|
|
35
|
+
mlx_dfloat/mflux/flux1/transformer.py,sha256=-Fd-HDOIL3GbcFxChJhSOLW91xDuQyYyaJCZcBY6gsg,9911
|
|
36
|
+
mlx_dfloat-0.1.0.dist-info/METADATA,sha256=_4Gi1oWaoZkCnP9JDRgCZ-9tf6Y4zBTIOW_K0yfvawY,22941
|
|
37
|
+
mlx_dfloat-0.1.0.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
|
|
38
|
+
mlx_dfloat-0.1.0.dist-info/entry_points.txt,sha256=YMmtGn9HTGz0MZ8rSSDy5YGdhep_AOCcRP9dlA4QQb8,51
|
|
39
|
+
mlx_dfloat-0.1.0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
|
40
|
+
mlx_dfloat-0.1.0.dist-info/licenses/NOTICE,sha256=8bpbyt9PF3Byd26tfQ5u0cLteoIdmn1U-mnWFL9wvGI,2186
|
|
41
|
+
mlx_dfloat-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
mlx-dfloat
|
|
2
|
+
Copyright 2026 Denis Ineshin
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0.
|
|
5
|
+
|
|
6
|
+
mlx-dfloat is an independent reader and decoder for the DFloat11 checkpoint format. It is not a fork of DFloat11
|
|
7
|
+
and is not affiliated with the DFloat11 authors.
|
|
8
|
+
|
|
9
|
+
DFloat11
|
|
10
|
+
--------
|
|
11
|
+
The DFloat11 method and checkpoint format come from:
|
|
12
|
+
|
|
13
|
+
Tianyi Zhang, Mohsen Hariri, Shaochen Zhong, Vipin Chaudhary, Yang Sui, Xia Hu, Anshumali Shrivastava.
|
|
14
|
+
"70% Size, 100% Accuracy: Lossless LLM Compression for Efficient GPU Inference via Dynamic-Length Float
|
|
15
|
+
(DFloat11)". arXiv:2504.11651, https://arxiv.org/abs/2504.11651. The paper is distributed under the
|
|
16
|
+
Creative Commons Attribution 4.0 International licence (CC BY 4.0).
|
|
17
|
+
|
|
18
|
+
The authors' implementation is https://github.com/LeanModels/DFloat11, licensed under the Apache License,
|
|
19
|
+
Version 2.0. The format reader and the decoders in this package are a separate implementation of the published
|
|
20
|
+
format. The only file taken from that repository is the test-only encoder described below.
|
|
21
|
+
|
|
22
|
+
Test-only encoder and test data
|
|
23
|
+
-------------------------------
|
|
24
|
+
tests/_upstream/dfloat11_encoder.py is derived from dfloat11_utils.py of https://github.com/LeanModels/DFloat11
|
|
25
|
+
at commit 457733886c, Copyright 2025 Tianyi Zhang, licensed under the Apache License, Version 2.0. It builds test
|
|
26
|
+
fixtures only and is not part of the installed package. tests/_upstream/NOTICE lists the changes made to it.
|
|
27
|
+
|
|
28
|
+
tests/fixtures/upstream/ holds a small slice (four compressed blocks of one matrix) of the DFloat11/Qwen3-4B-DF11
|
|
29
|
+
checkpoint and the matching BF16 values from Qwen/Qwen3-4B, which is licensed under the Apache License, Version 2.0.
|
|
30
|
+
|
|
31
|
+
mflux
|
|
32
|
+
-----
|
|
33
|
+
The optional FLUX.1 integration (the mlx-dfloat[mflux] extra) and the benchmark run on mflux,
|
|
34
|
+
https://github.com/mflux-community/mflux, Copyright (c) 2026 Filip Strand, licensed under the MIT License. mflux is a
|
|
35
|
+
dependency installed separately; mlx-dfloat does not include its code.
|
|
36
|
+
|
|
37
|
+
Model weights
|
|
38
|
+
-------------
|
|
39
|
+
mlx-dfloat ships no model weights. A DFloat11 checkpoint carries the licence of the model it was compressed from;
|
|
40
|
+
FLUX.1-dev and FLUX.1-Krea-dev, for example, are under Black Forest Labs' non-commercial licence.
|