mlx-dfloat 0.1.0__tar.gz

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.
Files changed (182) hide show
  1. mlx_dfloat-0.1.0/.coveragerc-integration +5 -0
  2. mlx_dfloat-0.1.0/.github/FUNDING.yml +1 -0
  3. mlx_dfloat-0.1.0/.github/workflows/ci.yml +67 -0
  4. mlx_dfloat-0.1.0/.github/workflows/release.yml +47 -0
  5. mlx_dfloat-0.1.0/.gitignore +25 -0
  6. mlx_dfloat-0.1.0/.python-version +1 -0
  7. mlx_dfloat-0.1.0/CHANGELOG.md +158 -0
  8. mlx_dfloat-0.1.0/LICENSE +202 -0
  9. mlx_dfloat-0.1.0/NOTICE +40 -0
  10. mlx_dfloat-0.1.0/PKG-INFO +325 -0
  11. mlx_dfloat-0.1.0/README.md +292 -0
  12. mlx_dfloat-0.1.0/bench/results/.gitkeep +0 -0
  13. mlx_dfloat-0.1.0/bench/results/flux1-dev-1024/preflight.json +17 -0
  14. mlx_dfloat-0.1.0/bench/results/flux1-dev-1024/report.json +174 -0
  15. mlx_dfloat-0.1.0/bench/results/flux1-dev-1024/round1-control-depth2.json +171 -0
  16. mlx_dfloat-0.1.0/bench/results/flux1-dev-1024/round1-control-noeval.json +171 -0
  17. mlx_dfloat-0.1.0/bench/results/flux1-dev-1024/round1-control.json +171 -0
  18. mlx_dfloat-0.1.0/bench/results/flux1-dev-1024/round1-df11-depth2.json +171 -0
  19. mlx_dfloat-0.1.0/bench/results/flux1-dev-1024/round1-df11.json +171 -0
  20. mlx_dfloat-0.1.0/bench/results/flux1-dev-1024/round1-q8.json +177 -0
  21. mlx_dfloat-0.1.0/bench/results/flux1-dev-1024/round2-control-depth2.json +171 -0
  22. mlx_dfloat-0.1.0/bench/results/flux1-dev-1024/round2-control-noeval.json +171 -0
  23. mlx_dfloat-0.1.0/bench/results/flux1-dev-1024/round2-control.json +171 -0
  24. mlx_dfloat-0.1.0/bench/results/flux1-dev-1024/round2-df11-depth2.json +171 -0
  25. mlx_dfloat-0.1.0/bench/results/flux1-dev-1024/round2-df11.json +171 -0
  26. mlx_dfloat-0.1.0/bench/results/flux1-dev-1024/round2-q8.json +177 -0
  27. mlx_dfloat-0.1.0/bench/results/flux1-dev-1024/round3-control-depth2.json +171 -0
  28. mlx_dfloat-0.1.0/bench/results/flux1-dev-1024/round3-control-noeval.json +171 -0
  29. mlx_dfloat-0.1.0/bench/results/flux1-dev-1024/round3-control.json +171 -0
  30. mlx_dfloat-0.1.0/bench/results/flux1-dev-1024/round3-df11-depth2.json +171 -0
  31. mlx_dfloat-0.1.0/bench/results/flux1-dev-1024/round3-df11.json +171 -0
  32. mlx_dfloat-0.1.0/bench/results/flux1-dev-1024/round3-q8.json +177 -0
  33. mlx_dfloat-0.1.0/bench/results/flux1-schnell-1024/preflight.json +15 -0
  34. mlx_dfloat-0.1.0/bench/results/flux1-schnell-1024/report.json +172 -0
  35. mlx_dfloat-0.1.0/bench/results/flux1-schnell-1024/round1-control-depth2.json +171 -0
  36. mlx_dfloat-0.1.0/bench/results/flux1-schnell-1024/round1-control-noeval.json +171 -0
  37. mlx_dfloat-0.1.0/bench/results/flux1-schnell-1024/round1-control.json +171 -0
  38. mlx_dfloat-0.1.0/bench/results/flux1-schnell-1024/round1-df11-depth2.json +171 -0
  39. mlx_dfloat-0.1.0/bench/results/flux1-schnell-1024/round1-df11.json +171 -0
  40. mlx_dfloat-0.1.0/bench/results/flux1-schnell-1024/round1-q8.json +177 -0
  41. mlx_dfloat-0.1.0/bench/results/flux1-schnell-1024/round2-control-depth2.json +171 -0
  42. mlx_dfloat-0.1.0/bench/results/flux1-schnell-1024/round2-control-noeval.json +171 -0
  43. mlx_dfloat-0.1.0/bench/results/flux1-schnell-1024/round2-control.json +171 -0
  44. mlx_dfloat-0.1.0/bench/results/flux1-schnell-1024/round2-df11-depth2.json +171 -0
  45. mlx_dfloat-0.1.0/bench/results/flux1-schnell-1024/round2-df11.json +171 -0
  46. mlx_dfloat-0.1.0/bench/results/flux1-schnell-1024/round2-q8.json +177 -0
  47. mlx_dfloat-0.1.0/bench/results/flux1-schnell-1024/round3-control-depth2.json +171 -0
  48. mlx_dfloat-0.1.0/bench/results/flux1-schnell-1024/round3-control-noeval.json +171 -0
  49. mlx_dfloat-0.1.0/bench/results/flux1-schnell-1024/round3-control.json +171 -0
  50. mlx_dfloat-0.1.0/bench/results/flux1-schnell-1024/round3-df11-depth2.json +171 -0
  51. mlx_dfloat-0.1.0/bench/results/flux1-schnell-1024/round3-df11.json +171 -0
  52. mlx_dfloat-0.1.0/bench/results/flux1-schnell-1024/round3-q8.json +177 -0
  53. mlx_dfloat-0.1.0/bench/results/harness-proof/README.md +53 -0
  54. mlx_dfloat-0.1.0/bench/results/harness-proof/abort.json +22 -0
  55. mlx_dfloat-0.1.0/bench/results/harness-proof/pass-512.json +119 -0
  56. mlx_dfloat-0.1.0/bench/results/tiers/dev-1024.json +119 -0
  57. mlx_dfloat-0.1.0/bench/results/tiers/krea-dev-1024.json +119 -0
  58. mlx_dfloat-0.1.0/bench/results/tiers/schnell-1024.json +119 -0
  59. mlx_dfloat-0.1.0/bench/scenarios/flux1-dev-1024.toml +15 -0
  60. mlx_dfloat-0.1.0/bench/scenarios/flux1-schnell-1024.toml +15 -0
  61. mlx_dfloat-0.1.0/pyproject.toml +176 -0
  62. mlx_dfloat-0.1.0/scripts/_bench_common.py +302 -0
  63. mlx_dfloat-0.1.0/scripts/_flux_rig.py +349 -0
  64. mlx_dfloat-0.1.0/scripts/_q8_rig.py +227 -0
  65. mlx_dfloat-0.1.0/scripts/_watchdog.py +9 -0
  66. mlx_dfloat-0.1.0/scripts/bench_control_validation.py +517 -0
  67. mlx_dfloat-0.1.0/scripts/bench_decode_kernel.py +396 -0
  68. mlx_dfloat-0.1.0/scripts/bench_flux1.py +571 -0
  69. mlx_dfloat-0.1.0/scripts/bench_flux_step.py +1405 -0
  70. mlx_dfloat-0.1.0/scripts/bench_table.py +252 -0
  71. mlx_dfloat-0.1.0/scripts/ci_metal_probe.py +48 -0
  72. mlx_dfloat-0.1.0/scripts/encode_prompt.py +228 -0
  73. mlx_dfloat-0.1.0/scripts/extract_upstream_slice.py +154 -0
  74. mlx_dfloat-0.1.0/scripts/flux_rig_smoke.py +288 -0
  75. mlx_dfloat-0.1.0/scripts/regpressure.py +185 -0
  76. mlx_dfloat-0.1.0/scripts/verify_checkpoint.py +575 -0
  77. mlx_dfloat-0.1.0/scripts/verify_image.py +559 -0
  78. mlx_dfloat-0.1.0/scripts/verify_remote_group.py +469 -0
  79. mlx_dfloat-0.1.0/src/mlx_dfloat/__init__.py +25 -0
  80. mlx_dfloat-0.1.0/src/mlx_dfloat/_memory_caps.py +74 -0
  81. mlx_dfloat-0.1.0/src/mlx_dfloat/_metal_decode.py +420 -0
  82. mlx_dfloat-0.1.0/src/mlx_dfloat/_safetensors.py +185 -0
  83. mlx_dfloat-0.1.0/src/mlx_dfloat/_scrub.py +29 -0
  84. mlx_dfloat-0.1.0/src/mlx_dfloat/_version.py +24 -0
  85. mlx_dfloat-0.1.0/src/mlx_dfloat/_watchdog.py +253 -0
  86. mlx_dfloat-0.1.0/src/mlx_dfloat/bench/__init__.py +4 -0
  87. mlx_dfloat-0.1.0/src/mlx_dfloat/bench/capped.py +165 -0
  88. mlx_dfloat-0.1.0/src/mlx_dfloat/bench/preflight.py +216 -0
  89. mlx_dfloat-0.1.0/src/mlx_dfloat/bench/results.py +227 -0
  90. mlx_dfloat-0.1.0/src/mlx_dfloat/bench/scenario.py +191 -0
  91. mlx_dfloat-0.1.0/src/mlx_dfloat/bench/table.py +251 -0
  92. mlx_dfloat-0.1.0/src/mlx_dfloat/cli.py +30 -0
  93. mlx_dfloat-0.1.0/src/mlx_dfloat/decode.py +120 -0
  94. mlx_dfloat-0.1.0/src/mlx_dfloat/errors.py +45 -0
  95. mlx_dfloat-0.1.0/src/mlx_dfloat/format.py +462 -0
  96. mlx_dfloat-0.1.0/src/mlx_dfloat/integrate/__init__.py +1 -0
  97. mlx_dfloat-0.1.0/src/mlx_dfloat/integrate/coverage.py +122 -0
  98. mlx_dfloat-0.1.0/src/mlx_dfloat/integrate/memory.py +55 -0
  99. mlx_dfloat-0.1.0/src/mlx_dfloat/integrate/names.py +121 -0
  100. mlx_dfloat-0.1.0/src/mlx_dfloat/integrate/placeholders.py +72 -0
  101. mlx_dfloat-0.1.0/src/mlx_dfloat/integrate/providers.py +271 -0
  102. mlx_dfloat-0.1.0/src/mlx_dfloat/integrate/seam.py +196 -0
  103. mlx_dfloat-0.1.0/src/mlx_dfloat/mflux/__init__.py +31 -0
  104. mlx_dfloat-0.1.0/src/mlx_dfloat/mflux/flux1/__init__.py +1 -0
  105. mlx_dfloat-0.1.0/src/mlx_dfloat/mflux/flux1/cli.py +419 -0
  106. mlx_dfloat-0.1.0/src/mlx_dfloat/mflux/flux1/init.py +245 -0
  107. mlx_dfloat-0.1.0/src/mlx_dfloat/mflux/flux1/lifecycle.py +159 -0
  108. mlx_dfloat-0.1.0/src/mlx_dfloat/mflux/flux1/memory.py +201 -0
  109. mlx_dfloat-0.1.0/src/mlx_dfloat/mflux/flux1/model.py +553 -0
  110. mlx_dfloat-0.1.0/src/mlx_dfloat/mflux/flux1/names.py +79 -0
  111. mlx_dfloat-0.1.0/src/mlx_dfloat/mflux/flux1/transformer.py +240 -0
  112. mlx_dfloat-0.1.0/src/mlx_dfloat/py.typed +0 -0
  113. mlx_dfloat-0.1.0/src/mlx_dfloat/reference.py +241 -0
  114. mlx_dfloat-0.1.0/tests/_decode_fixtures.py +272 -0
  115. mlx_dfloat-0.1.0/tests/_df11_fixtures.py +118 -0
  116. mlx_dfloat-0.1.0/tests/_flux_fakes.py +360 -0
  117. mlx_dfloat-0.1.0/tests/_shader_validation_repro.py +79 -0
  118. mlx_dfloat-0.1.0/tests/_upstream/NOTICE +14 -0
  119. mlx_dfloat-0.1.0/tests/_upstream/__init__.py +0 -0
  120. mlx_dfloat-0.1.0/tests/_upstream/dfloat11_encoder.py +163 -0
  121. mlx_dfloat-0.1.0/tests/conftest.py +104 -0
  122. mlx_dfloat-0.1.0/tests/fixtures/generate_report_schnell_1024.json +119 -0
  123. mlx_dfloat-0.1.0/tests/fixtures/upstream/qwen3_4b_layer0_4blocks.json +19 -0
  124. mlx_dfloat-0.1.0/tests/fixtures/upstream/qwen3_4b_layer0_4blocks.npz +0 -0
  125. mlx_dfloat-0.1.0/tests/test_bench_capped.py +162 -0
  126. mlx_dfloat-0.1.0/tests/test_bench_common.py +458 -0
  127. mlx_dfloat-0.1.0/tests/test_bench_control_validation.py +432 -0
  128. mlx_dfloat-0.1.0/tests/test_bench_flux1.py +804 -0
  129. mlx_dfloat-0.1.0/tests/test_bench_flux_step.py +1959 -0
  130. mlx_dfloat-0.1.0/tests/test_bench_preflight.py +324 -0
  131. mlx_dfloat-0.1.0/tests/test_bench_q8_slow.py +142 -0
  132. mlx_dfloat-0.1.0/tests/test_bench_results.py +167 -0
  133. mlx_dfloat-0.1.0/tests/test_bench_scenario.py +199 -0
  134. mlx_dfloat-0.1.0/tests/test_bench_table.py +363 -0
  135. mlx_dfloat-0.1.0/tests/test_bench_table_script.py +361 -0
  136. mlx_dfloat-0.1.0/tests/test_ci_config.py +145 -0
  137. mlx_dfloat-0.1.0/tests/test_cli.py +790 -0
  138. mlx_dfloat-0.1.0/tests/test_decode_api.py +85 -0
  139. mlx_dfloat-0.1.0/tests/test_decode_bounds.py +51 -0
  140. mlx_dfloat-0.1.0/tests/test_decode_corrupt.py +192 -0
  141. mlx_dfloat-0.1.0/tests/test_decode_parity.py +320 -0
  142. mlx_dfloat-0.1.0/tests/test_decode_staged.py +64 -0
  143. mlx_dfloat-0.1.0/tests/test_encode_prompt.py +72 -0
  144. mlx_dfloat-0.1.0/tests/test_extract_upstream_slice.py +16 -0
  145. mlx_dfloat-0.1.0/tests/test_flux1_embeddings_parity.py +47 -0
  146. mlx_dfloat-0.1.0/tests/test_flux1_init.py +298 -0
  147. mlx_dfloat-0.1.0/tests/test_flux1_lifecycle.py +311 -0
  148. mlx_dfloat-0.1.0/tests/test_flux1_memory.py +381 -0
  149. mlx_dfloat-0.1.0/tests/test_flux1_model.py +601 -0
  150. mlx_dfloat-0.1.0/tests/test_flux1_names.py +136 -0
  151. mlx_dfloat-0.1.0/tests/test_flux1_real_blocks.py +138 -0
  152. mlx_dfloat-0.1.0/tests/test_flux1_transformer.py +280 -0
  153. mlx_dfloat-0.1.0/tests/test_flux_rig.py +374 -0
  154. mlx_dfloat-0.1.0/tests/test_flux_rig_smoke.py +84 -0
  155. mlx_dfloat-0.1.0/tests/test_format_arrays.py +89 -0
  156. mlx_dfloat-0.1.0/tests/test_format_checkpoint.py +191 -0
  157. mlx_dfloat-0.1.0/tests/test_format_config.py +220 -0
  158. mlx_dfloat-0.1.0/tests/test_integrate_coverage.py +243 -0
  159. mlx_dfloat-0.1.0/tests/test_integrate_memory.py +47 -0
  160. mlx_dfloat-0.1.0/tests/test_integrate_placeholders.py +193 -0
  161. mlx_dfloat-0.1.0/tests/test_integrate_providers.py +379 -0
  162. mlx_dfloat-0.1.0/tests/test_integrate_retention.py +104 -0
  163. mlx_dfloat-0.1.0/tests/test_integrate_seam.py +486 -0
  164. mlx_dfloat-0.1.0/tests/test_markers.py +121 -0
  165. mlx_dfloat-0.1.0/tests/test_memory_caps.py +120 -0
  166. mlx_dfloat-0.1.0/tests/test_metal_constants.py +53 -0
  167. mlx_dfloat-0.1.0/tests/test_mflux_guard.py +105 -0
  168. mlx_dfloat-0.1.0/tests/test_mx_group.py +83 -0
  169. mlx_dfloat-0.1.0/tests/test_public_api.py +50 -0
  170. mlx_dfloat-0.1.0/tests/test_q8_rig.py +317 -0
  171. mlx_dfloat-0.1.0/tests/test_readme_bench_block.py +29 -0
  172. mlx_dfloat-0.1.0/tests/test_reference_hand.py +188 -0
  173. mlx_dfloat-0.1.0/tests/test_reference_roundtrip.py +186 -0
  174. mlx_dfloat-0.1.0/tests/test_safetensors_reader.py +155 -0
  175. mlx_dfloat-0.1.0/tests/test_script_entry.py +52 -0
  176. mlx_dfloat-0.1.0/tests/test_upstream_encoder.py +182 -0
  177. mlx_dfloat-0.1.0/tests/test_upstream_slice.py +42 -0
  178. mlx_dfloat-0.1.0/tests/test_verify_checkpoint.py +809 -0
  179. mlx_dfloat-0.1.0/tests/test_verify_image.py +345 -0
  180. mlx_dfloat-0.1.0/tests/test_verify_remote.py +612 -0
  181. mlx_dfloat-0.1.0/tests/test_watchdog.py +419 -0
  182. mlx_dfloat-0.1.0/uv.lock +1916 -0
@@ -0,0 +1,5 @@
1
+ [run]
2
+ branch = true
3
+
4
+ [report]
5
+ show_missing = true
@@ -0,0 +1 @@
1
+ github: IonDen
@@ -0,0 +1,67 @@
1
+ name: CI
2
+ on:
3
+ push:
4
+ branches: [main, "feature/**"]
5
+ pull_request:
6
+ branches: [main]
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ jobs:
12
+ test:
13
+ runs-on: macos-15
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+ with:
17
+ fetch-depth: 0 # hatch-vcs needs tags/history
18
+ - uses: astral-sh/setup-uv@v5
19
+ - run: uv sync --locked --group dev
20
+ - run: uv run python -c "import mlx.core; print('mlx import OK')"
21
+ - run: uv run ruff check .
22
+ - run: uv run ruff format --check .
23
+ - run: uv run mypy
24
+ - name: Metal capability probe (informational)
25
+ continue-on-error: true
26
+ run: uv run python scripts/ci_metal_probe.py
27
+ - name: Test (required)
28
+ run: uv run pytest --cov=mlx_dfloat --cov=scripts --cov-report=term-missing --cov-fail-under=85
29
+ integration:
30
+ # The mflux lane: installs the optional extra from the lock (torch and transformers come with
31
+ # mflux, pinned there too) and runs only the tests that need it.
32
+ runs-on: macos-15
33
+ strategy:
34
+ matrix:
35
+ # The lock pins mflux 0.20.0. A second row (another mflux release) would need the unlocked
36
+ # form instead of `uv sync --extra mflux`: `uv pip install "mflux==<version>"` after the
37
+ # sync, then `uv run --no-sync` for the steps below.
38
+ mflux: ["0.20.0"]
39
+ steps:
40
+ - uses: actions/checkout@v4
41
+ with:
42
+ fetch-depth: 0
43
+ - uses: astral-sh/setup-uv@v5
44
+ - run: uv sync --locked --group dev --extra mflux
45
+ - run: uv run --extra mflux --group dev python -c "import mflux, mlx.core, importlib.metadata as m; print('mflux', m.version('mflux'))"
46
+ # No combined threshold: init.py's tests run in the default lane (its live ones skip without a token); the next step gates model.py on its own.
47
+ - name: Integration tests (mflux lane)
48
+ env:
49
+ # Every FLUX.1 base repository is gated on the Hub (schnell auto-approved), so the three
50
+ # live tokenizer tests skip without a token; this is the variable huggingface_hub reads first.
51
+ # Only this step gets it: the actions, the sync and the collection and coverage steps have
52
+ # no use for it. The secret is a read-only Hub token; the default lane runs without one.
53
+ HF_TOKEN: ${{ secrets.HF_TOKEN }}
54
+ run: uv run --extra mflux --group dev pytest -m mflux --run-network --cov=mlx_dfloat.mflux.flux1.model --cov=mlx_dfloat.mflux.flux1.init --cov-config=.coveragerc-integration --cov-report=term-missing -q -p no:cacheprovider -rs
55
+ - name: model.py coverage on its own (mflux lane)
56
+ run: uv run --extra mflux --group dev coverage report --include='*/mflux/flux1/model.py' --fail-under=80
57
+ - name: The lane collected mflux tests
58
+ run: test "$(uv run --extra mflux --group dev pytest -m mflux --co -q -p no:cacheprovider | grep -c '::')" -ge 2
59
+ build:
60
+ # Same action the release workflow uses, so a distribution that would fail at tag time
61
+ # (e.g. a build-backend metadata version newer than the bundled twine) fails on the PR.
62
+ runs-on: ubuntu-latest
63
+ steps:
64
+ - uses: actions/checkout@v4
65
+ with:
66
+ fetch-depth: 0
67
+ - uses: hynek/build-and-inspect-python-package@v3.0.1
@@ -0,0 +1,47 @@
1
+ name: release
2
+ on:
3
+ push:
4
+ tags: ["v*"]
5
+
6
+ jobs:
7
+ build:
8
+ # ubuntu, not macOS: the package is a pure-Python (py3-none-any) wheel, so the
9
+ # build is platform-independent, and pypa/gh-action-pypi-publish is Linux-only.
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v6
13
+ with:
14
+ fetch-depth: 0 # hatch-vcs derives the version from the tag
15
+ - uses: hynek/build-and-inspect-python-package@v3.0.1
16
+
17
+ publish:
18
+ needs: build
19
+ runs-on: ubuntu-latest
20
+ environment: pypi
21
+ permissions:
22
+ id-token: write # PyPI Trusted Publishing
23
+ steps:
24
+ - uses: actions/download-artifact@v8
25
+ with:
26
+ name: Packages
27
+ path: dist
28
+ - uses: pypa/gh-action-pypi-publish@release/v1
29
+
30
+ github-release:
31
+ needs: publish
32
+ runs-on: ubuntu-latest
33
+ permissions:
34
+ contents: write
35
+ steps:
36
+ - uses: actions/download-artifact@v8
37
+ with:
38
+ name: Packages
39
+ path: dist
40
+ - name: Create GitHub Release
41
+ uses: softprops/action-gh-release@v3
42
+ with:
43
+ files: dist/*
44
+ generate_release_notes: true
45
+ draft: false
46
+ # Tags containing a hyphen (e.g. v0.2.0-alpha) are marked prerelease.
47
+ prerelease: ${{ contains(github.ref_name, '-') }}
@@ -0,0 +1,25 @@
1
+ .DS_Store
2
+ .codegraph/
3
+ .hypothesis/
4
+ docs/superpowers/
5
+ docs/backlog/
6
+ /.superpowers/
7
+ /CLAUDE.md
8
+ /AGENTS.md
9
+ /_spike/
10
+ /_artifacts/scratch/
11
+ .coverage
12
+ coverage.json
13
+ .mypy_cache/
14
+ .pytest_cache/
15
+ .ruff_cache/
16
+ .venv/
17
+ __pycache__/
18
+ build/
19
+ dist/
20
+ *.egg-info/
21
+ src/mlx_dfloat/_version.py
22
+
23
+ bench/results/**/embeds*.safetensors
24
+ bench/results/**/*.png
25
+ *.png
@@ -0,0 +1 @@
1
+ 3.12
@@ -0,0 +1,158 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented here. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and versions follow
5
+ [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [0.1.0] - 2026-10-01
10
+
11
+ The first release.
12
+
13
+ ### Added
14
+
15
+ - Project skeleton: package layout, MLX memory caps derived from the device's working-set size, test gates for
16
+ slow and networked tests, and CI.
17
+ - Reading and decoding DFloat11 (DF11) checkpoints. A safetensors header reader and a DF11 format reader check the
18
+ `dfloat11_config` block and each compressed group, and raise `DFloatFormatError` on malformed or unsafe input.
19
+ Legacy pickle-format repos are refused and never unpickled. A pure NumPy reference decoder turns a group back into
20
+ its BF16 bit patterns, bit for bit, and raises `DFloatResourceError` when a decode would exceed its memory budget.
21
+ Two scripts in the repository check a conversion against the original BF16 weights: one decodes a whole local
22
+ checkpoint, the other samples a few groups of a Hugging Face repo over range requests. They exit 0 when every
23
+ compared value matches, 1 on a real mismatch, 2 on any other error, and 70 or 71 when the memory or wall-clock
24
+ watchdog aborts the run.
25
+ - A Metal decode kernel for DFloat11 groups, behind `mlx_dfloat.decode`. `decode_group(group, backend="metal")`
26
+ returns the BF16 bit patterns and a per-block status word, `check` refuses a group whose status reports an invalid
27
+ code, a count mismatch or a broken thread chain, and `available_backends` says whether the kernel compiles and runs
28
+ on this machine; nothing falls back silently. Every decode path is tested bit for bit against the NumPy reference:
29
+ hand-built codebooks, encoder round-trips, a real Qwen3-4B slice, and corrupt inputs that must end with an error
30
+ instead of a hang. On an M1 Max the kernel decodes 50 to 54 GB/s of BF16 output when a block's output is staged
31
+ through threadgroup memory and 19 to 24 GB/s when it writes straight to device memory
32
+ (`scripts/bench_decode_kernel.py`, median of 5 repetitions after a warm-up); staged is the default, and the direct
33
+ path is the fallback for blocks larger than the staging buffer. `verify_checkpoint.py --decoder metal` checks a
34
+ whole checkpoint through the kernel, against the BF16 original when one is given and against the reference
35
+ otherwise: Qwen3-4B decodes bit-identically in 12.8 s where the reference took 223 s, and all 57 groups of
36
+ FLUX.1-schnell match the reference.
37
+ - A measurement rig for the question the project hinges on: how much a FLUX.1 denoise step slows down when every
38
+ transformer block's weights are decoded just in time. `scripts/bench_flux_step.py` runs one mode per process, either
39
+ decoding per block or a control that swaps pre-decoded weights into the same graph, and reports the paired overhead;
40
+ `scripts/bench_control_validation.py` checks that control against a run whose BF16 weights are all resident, on a
41
+ reduced-depth transformer and through the same per-block path; `scripts/encode_prompt.py` encodes the prompt once,
42
+ so the timed process holds no text encoder. Measured on an M1 Max (32 GB, macOS 27.0, mlx 0.32.2, mflux 0.20.0) at
43
+ 1024², five timed steps in each of three rounds: FLUX.1-schnell costs 6.1 % more per step with a one-block
44
+ evaluation run-ahead and 8.5 % with a per-block evaluation; FLUX.1-dev costs 5.0 % either way (the dev prompt was
45
+ encoded with the schnell text encoders at 512 tokens, the same T5 and CLIP architecture, because the dev base
46
+ repository is gated). The control agrees with that run within 0.13 %; the per-block evaluation itself costs 0.21 s
47
+ (schnell) to 0.26 s (dev) per step, measured against a control that evaluates only at the end of the step. In the
48
+ step, decoding costs 2.1 to 3.4 times what the isolated kernel benchmark predicts from its throughput. A follow-up
49
+ measurement on schnell (one round of five timed steps per mode, with the bench's new `--trace` and `--cache-limit`
50
+ options) attributes most of that difference to memory allocation: at the bench's 1.4 GB cache limit the activation
51
+ buffers each block frees already fill MLX's buffer cache, so every block's decoded output is released instead of
52
+ kept and allocated fresh for the next block: about 30 ms for a double block and 14 ms for a single one on the
53
+ per-block stamps, and 1.29 s of a step as the difference between two cache limits. With a 2.5 GB limit, large enough
54
+ that a decoded buffer survives in the cache next to those activations, the
55
+ per-block overhead on schnell is 4.0 % for one more GiB of memory, and the in-step decode time is 1.5 times the
56
+ isolated prediction. Decoding the next block on a second GPU stream (`df11-prefetch`, submitted after the previous
57
+ block's evaluation returns) hides about a fifth of the kernel's time and, at that submission point, none of the
58
+ allocation; since the cache limit removes that cost anyway, the integration will evaluate per block and size the
59
+ cache limit instead. A timed process peaks at about 19 GiB of memory, 20.3 GiB with the look-ahead.
60
+ - The scripts' memory watchdog now enforces its ceiling on the process footprint the OS reports rather than on RSS
61
+ plus MLX memory, which counted loaded arrays twice.
62
+ - A block-boundary integration layer, `mlx_dfloat.integrate`: zero-size placeholders for a module's matrices, weight
63
+ providers that decode a DFloat11 group just in time, reuse one already decoded, or hand back a resident BF16
64
+ weight, and a seam that assigns one block's weights, runs the block, evaluates by policy and restores the
65
+ placeholders afterward. The seam and the providers raise when a matrix name falls outside the map or a weight
66
+ comes back the wrong shape, instead of leaving the layer at its placeholder value; a separate coverage check makes
67
+ sure every other parameter (biases, norm scales, embedders) gets exactly one tensor from the checkpoint. The FLUX.1
68
+ adapter, `mlx_dfloat.mflux.flux1`, reads mflux's own weight mapping to name each block's matrices and builds mflux's
69
+ transformer directly from a DFloat11 checkpoint; it needs the optional `mlx-dfloat[mflux]` extra and is tested with
70
+ mflux 0.20.0. Three new errors mark
71
+ this boundary: `DFloatIntegrationError` for a seam or name-map invariant that failed, `DFloatUnsupportedError` for
72
+ an option this path does not implement, and `DFloatDependencyError` for a missing optional dependency. The step
73
+ bench and the control validation now run through this integration code instead of a separate rig.
74
+
75
+ - `DFloatFlux1` and the `mlx-dfloat generate` command: FLUX.1 schnell, dev and Krea-dev images from a DFloat11
76
+ transformer through mflux, decoded one block at a time. The VAE and the text encoders come from the base
77
+ repository; its BF16 transformer is never downloaded. The text encoders and the compressed transformer are never
78
+ in memory together: a prompt is encoded first, then the encoders are dropped and the compressed weights loaded;
79
+ a new prompt after that reloads both (`encode()` pre-encodes several prompts at once). Each call derives an MLX
80
+ buffer-cache limit from the checkpoint and the resolution, estimates the peak memory per phase against the
81
+ device's budget, and restores the process's cache limit afterwards. A call that would not fit is refused, and so
82
+ is any size above 1024², the largest measured so far (`fit_check=False` overrides both; above 1024² the estimate
83
+ is an extrapolation). On a 32 GB Mac every call drops the compressed set before the VAE decode, because at 1024²
84
+ the decode next to the resident set measured 23.29 GiB, over the budget, and smaller sizes have not been measured;
85
+ the next call reloads the set in about 26 s. A Mac with a larger budget keeps it. All three base repositories are
86
+ gated on the Hub and need `hf auth login`: FLUX.1-schnell's with automatic approval once its Apache-2.0 license is
87
+ accepted, FLUX.1-dev's and FLUX.1-Krea-dev's with manual approval under Black Forest Labs' non-commercial license.
88
+ Their encoders and VAE are byte-identical, so the schnell base also serves dev and Krea-dev. The command installs the memory caps and the footprint watchdog; the Python API does
89
+ neither. Measured on an M1 Max (32 GB, macOS 27.0, mlx 0.32.2, mflux 0.20.0) at 1024²: FLUX.1-schnell (4 steps)
90
+ peaked at 19.94 GiB (19.95 GiB with depth-2 evaluation) in 1 minute 54 seconds including imports, with per-phase
91
+ MLX peaks of 10.09 GiB encoding the prompt, 15.20 GiB loading the compressed set, 17.44 GiB denoising and 9.55 GiB
92
+ decoding the VAE; FLUX.1-dev (20 steps, guidance 3.5) peaked at 20.10 GiB in 7 minutes 6 seconds; FLUX.1-Krea-dev
93
+ (20 steps, guidance 3.5) peaked at 20.09 GiB in 7 minutes 2 seconds. All three stay under the machine's measured
94
+ 22.96 GiB budget. `scripts/verify_image.py` compares the final latents with those of the same transformer
95
+ streaming the BF16 shards block by block: FLUX.1-schnell's latents match bit for bit and are not degenerate, and
96
+ the two images match pixel for pixel; FLUX.1-dev and FLUX.1-Krea-dev were not checked this way, because their BF16
97
+ transformers are gated and were not on disk to compare against. Quantisation, LoRA, img2img, ControlNet and the
98
+ PiD decoder are refused with a reason; `negative_prompt` is accepted and ignored, as mflux does for FLUX.1.
99
+ - A reproducible FLUX.1 benchmark driven by scenario files. A scenario (`bench/scenarios/*.toml`, one each for
100
+ FLUX.1-schnell and FLUX.1-dev) pins the DFloat11 and base snapshot revisions, the prompt, the seed, the size, the
101
+ step counts, the rounds, the MLX cache limit and the conditions. The loader refuses unknown or malformed fields,
102
+ and every result file carries the scenario's hash. `scripts/bench_flux1.py` runs a scenario end to end. It first
103
+ checks the machine (power, charging, battery, CPU speed limit, lid, disk, free memory, other heavy processes) and
104
+ stops unless `--skip-preflight` is given, and it checks again before each condition's process: a failed check
105
+ stops the run there, `report.json` records which checks failed, and the same command resumes later. It reads the
106
+ pinned snapshots from the local cache only, encodes the prompt once, and runs every condition and round as its own
107
+ process, interleaved, resuming from the files already written and refusing ones from another scenario or another
108
+ version of the code. The step bench gains a
109
+ `q8` condition: mflux's own transformer quantised to 8 bits at load from the pinned base, with one evaluation per
110
+ step, under the scenario's cache limit like the other conditions (mflux's own generate sets none). Its record
111
+ carries the bits, group size and mode read from a built block.
112
+ - The numbers from that benchmark, measured on an M1 Max (32 GB, macOS 27.0.1, mlx 0.32.2, mflux 0.20.0) at 1024²
113
+ under a 2.5 GB cache limit, five timed steps after two warm-up steps in each of three rounds. On FLUX.1-dev a step
114
+ costs 3.52 % more with per-block evaluation (19.24 s against 18.59 s) and 4.61 % more with a one-block run-ahead;
115
+ on FLUX.1-schnell, 4.05 % (19.28 s against 18.53 s) and 4.24 %. The run-ahead did not help on either model.
116
+ Evaluating after every block, measured on the control alone, cost 0.41 s per step on schnell and nothing
117
+ measurable on dev (the per-block control was 0.07 s faster); both sides of the overhead comparison pay it. A DF11
118
+ step with per-block evaluation takes 1.26 times as long as the q8 step on dev (15.26 s) and 1.35
119
+ times on schnell (14.25 s). These ratios are rough, because the q8 step's median moved by about 2 s between rounds
120
+ in both scenarios while the DF11 step's moved by 0.7 s at most. The dev depth-2 figure pools rounds that read
121
+ −1.6 %, +5.9 % and +6.5 % one at a time (each round's DF11 median over its control's), because round 1's depth-2
122
+ control ran slow; rounds 2 and 3 alone give +6.2 %. The q8 step also peaked lower, at 14.8–14.9 GiB
123
+ against DF11's 19.7–20.0 GiB; what DF11 keeps and q8 gives up is the exact BF16 output. The dev run used
124
+ `--skip-preflight`: the only failed gate was "not charging", because macOS held the battery at 80 % for optimised
125
+ charging, and its `report.json` records both. The check now lets a battery at 50 % or more run on a charger that
126
+ is not charging it. The results are in `bench/results/flux1-schnell-1024/` and
127
+ `bench/results/flux1-dev-1024/`; `uv run --group bench python -m scripts.bench_flux1 <scenario file>
128
+ --results-root <a fresh directory>` reproduces them.
129
+ - `mlx_dfloat.bench`, the pure side of the benchmark: the scenario loader, a smaller Mac's MLX limits and watchdog
130
+ ceiling, the launch check, the reader and summary of per-condition results, and the README renderers. It does not
131
+ import mflux or touch the GPU.
132
+ - `mlx-dfloat generate --tier GB` runs under a smaller Mac's MLX memory and cache limits, watchdog ceiling and fit
133
+ budget, and labels its report CAPPED; the host's own size keeps the host's limits and gives a MEASURED report.
134
+ `--memory-ceiling BYTES` lowers the watchdog ceiling alone, under the host's limits, and labels the report PROOF.
135
+ Every report now records the limits in force, its label, the image size and the watched peak, and writes the home
136
+ directory as `~`.
137
+ - The measured 32 GB rows for FLUX.1-schnell, FLUX.1-dev and FLUX.1-Krea-dev at 1024² (`bench/results/tiers/`):
138
+ watched peaks of 19.78, 19.96 and 20.04 GiB, all under the M1 Max's 22.96 GiB fit budget.
139
+ - A harness proof (`bench/results/harness-proof/`): under one 19.25 GiB watchdog ceiling, a 512² FLUX.1-schnell run
140
+ finished at 18.64 GiB, and a 1024² run was stopped by the watchdog at 19.32 GiB with exit 70. The watchdog's abort
141
+ file now names the model, size, seed and steps of the run it stopped, and the proof reads the stopped run's size
142
+ from it.
143
+ - `scripts/bench_table.py` writes the README's measured-numbers blocks from `bench/results/`, and a test fails when the
144
+ README and the result files disagree.
145
+
146
+ ### Changed
147
+
148
+ - CI runs the whole test suite, Metal tests included, on the macOS runner, which reports a Metal device; a probe step
149
+ prints the device it found.
150
+ - The memory watchdog enforces its ceiling on the larger of the process footprint and MLX's active plus cached memory,
151
+ names the counter that tripped in its abort file, and records the peak of each.
152
+ - The benchmark refuses a pinned snapshot whose weight shards are not all in the local cache, and names the
153
+ `hf download` command that completes it.
154
+ - CI's mflux lane gets the Hub token for its test step only, so the three tokenizer tests against the gated FLUX.1
155
+ bases run there instead of skipping.
156
+
157
+ [Unreleased]: https://github.com/IonDen/mlx-dfloat/compare/v0.1.0...HEAD
158
+ [0.1.0]: https://github.com/IonDen/mlx-dfloat/releases/tag/v0.1.0
@@ -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.