xfermat 0.6.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.
- xfermat-0.6.0/.gitignore +11 -0
- xfermat-0.6.0/LICENSE +56 -0
- xfermat-0.6.0/PKG-INFO +151 -0
- xfermat-0.6.0/README.md +62 -0
- xfermat-0.6.0/SECURITY.md +27 -0
- xfermat-0.6.0/pyproject.toml +63 -0
- xfermat-0.6.0/src/fermat/__init__.py +69 -0
- xfermat-0.6.0/src/fermat/__main__.py +6 -0
- xfermat-0.6.0/src/fermat/_tensors/alphaevolve_tensors.npz +0 -0
- xfermat-0.6.0/src/fermat/_tensors/factorizations_f2.npz +0 -0
- xfermat-0.6.0/src/fermat/_tensors/factorizations_r.npz +0 -0
- xfermat-0.6.0/src/fermat/bilinear.py +292 -0
- xfermat-0.6.0/src/fermat/cli.py +244 -0
- xfermat-0.6.0/src/fermat/engine.py +304 -0
- xfermat-0.6.0/src/fermat/io_algebra.py +1198 -0
- xfermat-0.6.0/src/fermat/kv_quant.py +1189 -0
- xfermat-0.6.0/src/fermat/model.py +530 -0
- xfermat-0.6.0/src/fermat/persistence.py +373 -0
- xfermat-0.6.0/src/fermat/rns_ozaki.py +587 -0
- xfermat-0.6.0/src/fermat/ssd_mamba.py +397 -0
- xfermat-0.6.0/src/fermat/structured.py +1017 -0
- xfermat-0.6.0/src/fermat/ternary.py +277 -0
- xfermat-0.6.0/tests/test_runtime.py +123 -0
xfermat-0.6.0/.gitignore
ADDED
xfermat-0.6.0/LICENSE
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
xFermat Open-Core & Commercial Dual License (v0.6.0)
|
|
2
|
+
Copyright (c) 2026 aopas software development (Aris Nikolaou). All rights reserved.
|
|
3
|
+
|
|
4
|
+
xFermat is distributed under a dual-licensing model designed to keep research,
|
|
5
|
+
solo builders, and technical evaluation free while licensing commercial app
|
|
6
|
+
redistribution and large organizational Mac deployments cleanly.
|
|
7
|
+
|
|
8
|
+
================================================================================
|
|
9
|
+
PART A — COMMUNITY, RESEARCH & EVALUATION LICENSE (€0)
|
|
10
|
+
================================================================================
|
|
11
|
+
|
|
12
|
+
Permission is hereby granted, free of charge, to individual natural persons,
|
|
13
|
+
students, and academic researchers solely for non-commercial personal evaluation
|
|
14
|
+
and open research on one (1) personal Apple Silicon workstation ("Community
|
|
15
|
+
Tier") to install, run, modify for personal testing, and benchmark the Software
|
|
16
|
+
(`fermat` / `xfermat` CLI, Python package, and Metal kernels), subject to the
|
|
17
|
+
following conditions:
|
|
18
|
+
|
|
19
|
+
1. Attribution & Truth-in-Benchmarking:
|
|
20
|
+
Published benchmarks, papers, or videos derived from xFermat must preserve
|
|
21
|
+
this notice and clearly state hardware tier, model size, quantization method,
|
|
22
|
+
and whether 2-bit post-training weights or 3-bit/4-bit production tiers were
|
|
23
|
+
evaluated.
|
|
24
|
+
2. Permitted Scope:
|
|
25
|
+
- Strictly non-commercial personal projects, academic papers, and public
|
|
26
|
+
reproducibility benchmarks on one (1) personal workstation.
|
|
27
|
+
3. Excluded Without Commercial License (see Part B):
|
|
28
|
+
- Any commercial business usage, SaaS backend, or multi-workstation company
|
|
29
|
+
deployment (2 or more Macs), whether internal or customer-facing.
|
|
30
|
+
- Bundling, embedding, or redistributing the xFermat runtime, Metal kernels,
|
|
31
|
+
or xFermat-compressed derivatives inside paid or proprietary desktop,
|
|
32
|
+
macOS, iOS, or SaaS products distributed to third parties.
|
|
33
|
+
- Managed organizational fleet deployments of twenty (20) or more Apple Silicon
|
|
34
|
+
workstations.
|
|
35
|
+
|
|
36
|
+
================================================================================
|
|
37
|
+
PART B — COMMERCIAL PER-SEAT & ENTERPRISE FLEET LICENSE
|
|
38
|
+
================================================================================
|
|
39
|
+
|
|
40
|
+
Commercial usage (individual founders, studios, and businesses across 1–20
|
|
41
|
+
seats under `Pro Commercial`, or organizational fleet deployments of 20+
|
|
42
|
+
workstations / Jamf MDM under `Enterprise Mac Fleet`) requires an active paid
|
|
43
|
+
license agreement issued by:
|
|
44
|
+
|
|
45
|
+
aopas software development (Owner: Aris Nikolaou)
|
|
46
|
+
Große Brinkgasse 9, 50672 Cologne, Germany · USt-IdNr. DE314648161
|
|
47
|
+
|
|
48
|
+
- Licensing Tiers & Pilot Requests: https://xfermat.com/pricing
|
|
49
|
+
- Enterprise & Licensing Inquiries: enterprise@xfermat.com (General: ask@xfermat.com)
|
|
50
|
+
|
|
51
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
52
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
53
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
54
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
55
|
+
LIABILITY ARISING FROM THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
56
|
+
SOFTWARE.
|
xfermat-0.6.0/PKG-INFO
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: xfermat
|
|
3
|
+
Version: 0.6.0
|
|
4
|
+
Summary: Apple Silicon Metal GPU inference runtime: fused 2-bit/4-bit KIVI KV-cache, sub-second Safetensors loading, SDPA/FlashDecode, Mamba-2 SSD hybrids, and CRT-Ozaki II FP64
|
|
5
|
+
Project-URL: Homepage, https://xfermat.com
|
|
6
|
+
Project-URL: Documentation, https://xfermat.com/docs
|
|
7
|
+
Project-URL: Whitepaper, https://xfermat.com/whitepaper
|
|
8
|
+
Project-URL: Repository, https://github.com/xFermat/xFermat
|
|
9
|
+
Project-URL: Issues, https://github.com/xFermat/xFermat/issues
|
|
10
|
+
Author-email: "Aris Nikolaou (aopas software development)" <ask@xfermat.com>
|
|
11
|
+
License: xFermat Open-Core & Commercial Dual License (v0.6.0)
|
|
12
|
+
Copyright (c) 2026 aopas software development (Aris Nikolaou). All rights reserved.
|
|
13
|
+
|
|
14
|
+
xFermat is distributed under a dual-licensing model designed to keep research,
|
|
15
|
+
solo builders, and technical evaluation free while licensing commercial app
|
|
16
|
+
redistribution and large organizational Mac deployments cleanly.
|
|
17
|
+
|
|
18
|
+
================================================================================
|
|
19
|
+
PART A — COMMUNITY, RESEARCH & EVALUATION LICENSE (€0)
|
|
20
|
+
================================================================================
|
|
21
|
+
|
|
22
|
+
Permission is hereby granted, free of charge, to individual natural persons,
|
|
23
|
+
students, and academic researchers solely for non-commercial personal evaluation
|
|
24
|
+
and open research on one (1) personal Apple Silicon workstation ("Community
|
|
25
|
+
Tier") to install, run, modify for personal testing, and benchmark the Software
|
|
26
|
+
(`fermat` / `xfermat` CLI, Python package, and Metal kernels), subject to the
|
|
27
|
+
following conditions:
|
|
28
|
+
|
|
29
|
+
1. Attribution & Truth-in-Benchmarking:
|
|
30
|
+
Published benchmarks, papers, or videos derived from xFermat must preserve
|
|
31
|
+
this notice and clearly state hardware tier, model size, quantization method,
|
|
32
|
+
and whether 2-bit post-training weights or 3-bit/4-bit production tiers were
|
|
33
|
+
evaluated.
|
|
34
|
+
2. Permitted Scope:
|
|
35
|
+
- Strictly non-commercial personal projects, academic papers, and public
|
|
36
|
+
reproducibility benchmarks on one (1) personal workstation.
|
|
37
|
+
3. Excluded Without Commercial License (see Part B):
|
|
38
|
+
- Any commercial business usage, SaaS backend, or multi-workstation company
|
|
39
|
+
deployment (2 or more Macs), whether internal or customer-facing.
|
|
40
|
+
- Bundling, embedding, or redistributing the xFermat runtime, Metal kernels,
|
|
41
|
+
or xFermat-compressed derivatives inside paid or proprietary desktop,
|
|
42
|
+
macOS, iOS, or SaaS products distributed to third parties.
|
|
43
|
+
- Managed organizational fleet deployments of twenty (20) or more Apple Silicon
|
|
44
|
+
workstations.
|
|
45
|
+
|
|
46
|
+
================================================================================
|
|
47
|
+
PART B — COMMERCIAL PER-SEAT & ENTERPRISE FLEET LICENSE
|
|
48
|
+
================================================================================
|
|
49
|
+
|
|
50
|
+
Commercial usage (individual founders, studios, and businesses across 1–20
|
|
51
|
+
seats under `Pro Commercial`, or organizational fleet deployments of 20+
|
|
52
|
+
workstations / Jamf MDM under `Enterprise Mac Fleet`) requires an active paid
|
|
53
|
+
license agreement issued by:
|
|
54
|
+
|
|
55
|
+
aopas software development (Owner: Aris Nikolaou)
|
|
56
|
+
Große Brinkgasse 9, 50672 Cologne, Germany · USt-IdNr. DE314648161
|
|
57
|
+
|
|
58
|
+
- Licensing Tiers & Pilot Requests: https://xfermat.com/pricing
|
|
59
|
+
- Enterprise & Licensing Inquiries: enterprise@xfermat.com (General: ask@xfermat.com)
|
|
60
|
+
|
|
61
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
62
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
63
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
64
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
65
|
+
LIABILITY ARISING FROM THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
66
|
+
SOFTWARE.
|
|
67
|
+
License-File: LICENSE
|
|
68
|
+
Keywords: apple-silicon,inference,kivi,kv-cache,llm,mamba2,metal,mlx,quantization,safetensors
|
|
69
|
+
Classifier: Development Status :: 4 - Beta
|
|
70
|
+
Classifier: Environment :: GPU
|
|
71
|
+
Classifier: Environment :: MacOS X
|
|
72
|
+
Classifier: Intended Audience :: Developers
|
|
73
|
+
Classifier: Intended Audience :: Science/Research
|
|
74
|
+
Classifier: License :: Other/Proprietary License
|
|
75
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
76
|
+
Classifier: Programming Language :: Python :: 3
|
|
77
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
78
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
79
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
80
|
+
Requires-Python: >=3.12
|
|
81
|
+
Requires-Dist: mlx>=0.20.0
|
|
82
|
+
Requires-Dist: numpy>=1.26.0
|
|
83
|
+
Requires-Dist: scipy>=1.12.0
|
|
84
|
+
Provides-Extra: dev
|
|
85
|
+
Requires-Dist: pytest>=8.0.0; extra == 'dev'
|
|
86
|
+
Provides-Extra: llm
|
|
87
|
+
Requires-Dist: mlx-lm>=0.20.0; extra == 'llm'
|
|
88
|
+
Description-Content-Type: text/markdown
|
|
89
|
+
|
|
90
|
+
# xFermat (`v0.6.0`) — Apple Silicon Open Inference Runtime
|
|
91
|
+
|
|
92
|
+
**xFermat Open Runtime** provides Apple Silicon Metal GPU kernels, native-speed Safetensors loading, fused 2-bit/4-bit **KIVI KV-cache** decoding (`--kv-bits 4|2`), **3:1 Mamba-2 SSD + SDPA** hybrid layers (`FermatModel`), and an empirical shape autotuner ([`FermatEngine`](https://github.com/xFermat/xFermat/blob/main/src/fermat/engine.py)) unifying 18 peer-reviewed foundations.
|
|
93
|
+
|
|
94
|
+
> **Open-Core Architecture:** This public repository and PyPI runtime distribute the transparent, pure-source inference engine (`xfermat info`, `xfermat bench`, `xfermat run`, `load_compressed_model`, `FermatKIVICache`, and verified Metal kernels). Proprietary offline weight compression (`Clip-GPTQ`, `4D VPTQ`) and `MOHAWK` distillation modules remain private commercial tools under [`aopas software development`](https://xfermat.com/pricing).
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## Measured Apple Silicon Summary (`Qwen2.5-0.5B` & `1.5B`)
|
|
99
|
+
|
|
100
|
+
Full disjoint evaluations, null-result boundaries, and reproducible JSON logs live in [`WHITEPAPER.md`](https://github.com/xFermat/xFermat/blob/main/WHITEPAPER.md) and [`benchmarks/`](https://github.com/xFermat/xFermat/tree/main/benchmarks):
|
|
101
|
+
|
|
102
|
+
| Benchmark (`8 GB` Apple Silicon GPU, `mlx 0.32.4`) | Strongest Native / Baseline | **xFermat `v0.6.0`** | Verified Gain |
|
|
103
|
+
| :--- | :--- | :--- | :--- |
|
|
104
|
+
| **`Qwen2.5-0.5B` 3-Bit KL & Decode** | `mlx_lm.awq`: `0.792` KL (`98.3 tok/s`) | **`0.423` KL (`144.1 tok/s`)** | **-47% KL**, **1.47× faster** |
|
|
105
|
+
| **`Qwen2.5-0.5B` 4-Bit `WikiText-2` PPL** | `mlx_lm.awq`: `23.86` PPL (`0.132` KL) | **`23.61` PPL (`0.100` KL, `150.4 tok/s`)** | **-25% in-dom KL**, beats AWQ |
|
|
106
|
+
| **`Qwen2.5-1.5B` 3-Bit Footprint & Reload** | `2,944.4 MB` BF16 (`21.3 tok/s` swap) | **`783.9 MB` (`3.76×`), `0.70 s` reload, `60.0 tok/s`** | **-12% KL vs AWQ** (`37.36` PPL) |
|
|
107
|
+
| **`8K` KIVI KV Cache (`D=128, G=64`)** | FP16 `16.0 MB` / 2b per-token `0.533` cos | **`3.16 MB` (`5.06×`), `0.710 ms`, `0.923` cos** | Live `mlx_lm` KV cut **`2.86×–3.66×`** |
|
|
108
|
+
| **`8K` 3:1 Hybrid SSD State & Decode** | Flash `65.5 MB` (`378.7 tok/s`) | **`16.4 MB` (`3.99×`), `457.4 tok/s`** | **`1.21×` decode / `1.53×` prefill** |
|
|
109
|
+
|
|
110
|
+
*(Honest engineering caveat: 3-bit and 4-bit remain the recommended production PTQ tiers; compact `0.5B` 2-bit post-training weights still trail BF16 on open-ended chat until QAT lands in `v0.7.0`. Under `mode="auto"`, sub-cubic Winograd–Strassen, AlphaEvolve rank-48, ternary LUTs, and 120-bit CRT FP64 stay opt-in where native Apple GEMM/BLAS wins.)*
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## Runtime Modules Included (`src/fermat/`)
|
|
115
|
+
|
|
116
|
+
| Module | Capability |
|
|
117
|
+
| :--- | :--- |
|
|
118
|
+
| [`src/fermat/kv_quant.py`](https://github.com/xFermat/xFermat/blob/main/src/fermat/kv_quant.py) | `QuantizedKVCache`, `FermatKIVICache`, fused Metal `L_q=1` register-unpack KIVI (`--kv-bits 4/2`) |
|
|
119
|
+
| [`src/fermat/persistence.py`](https://github.com/xFermat/xFermat/blob/main/src/fermat/persistence.py) | Sub-second sharded `.safetensors` serialization & `load_compressed_model` |
|
|
120
|
+
| [`src/fermat/engine.py`](https://github.com/xFermat/xFermat/blob/main/src/fermat/engine.py) | `FermatEngine(mode="auto")` per-shape median + 10% hysteresis autotuner |
|
|
121
|
+
| [`src/fermat/io_algebra.py`](https://github.com/xFermat/xFermat/blob/main/src/fermat/io_algebra.py) | `flash_tiled_attention` (SDPA auto-routing + Split-KV Metal `FlashDecode`) & `WinogradConv2d` |
|
|
122
|
+
| [`src/fermat/ssd_mamba.py`](https://github.com/xFermat/xFermat/blob/main/src/fermat/ssd_mamba.py) | Chunked `Q_c=64` Mamba-2 State Space Duality Metal forward + reverse-VJP scan |
|
|
123
|
+
| [`src/fermat/structured.py`](https://github.com/xFermat/xFermat/blob/main/src/fermat/structured.py) | `HadamardQuantLinear`, `FermatFinalNorm`, `MonarchLinear`, fused Metal SRAM FWHT (`R4`) |
|
|
124
|
+
| [`src/fermat/bilinear.py`](https://github.com/xFermat/xFermat/blob/main/src/fermat/bilinear.py) | AlphaEvolve `<4,4,4>`, AlphaTensor, Gauss 3M, Winograd-Strassen + bundled `.npz` tables |
|
|
125
|
+
| [`src/fermat/rns_ozaki.py`](https://github.com/xFermat/xFermat/blob/main/src/fermat/rns_ozaki.py) | Explicit 120-bit CRT-Ozaki II GPU FP64 reconstruction (`7.56e-16` rel. err.) |
|
|
126
|
+
| [`src/fermat/ternary.py`](https://github.com/xFermat/xFermat/blob/main/src/fermat/ternary.py) | `OzakiHadamardTernaryLinear` (`T-MAC` Metal SRAM LUTs) |
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Quickstart & Security Verification
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
# Install runtime (add [llm] to load & stream Hugging Face / mlx-lm models with KIVI)
|
|
134
|
+
pip install "xfermat[llm]"
|
|
135
|
+
|
|
136
|
+
# Verify pure-source package integrity & Metal GPU runtime
|
|
137
|
+
xfermat info
|
|
138
|
+
xfermat bench --json
|
|
139
|
+
|
|
140
|
+
# Stream any Hugging Face / mlx-lm model with fused 4-bit KIVI KV cache
|
|
141
|
+
xfermat run Qwen/Qwen2.5-0.5B-Instruct --kv-bits 4 --prompt "Explain Fermat's principle."
|
|
142
|
+
|
|
143
|
+
# Or load a saved compressed xFermat safetensors checkpoint in ~0.7s
|
|
144
|
+
xfermat run ./path-to-compressed-model --kv-bits 4 --prompt "Explain Fermat's principle."
|
|
145
|
+
|
|
146
|
+
# Verify runtime suite
|
|
147
|
+
pytest -q
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
- **Supply-Chain Transparency ([`SECURITY.md`](https://github.com/xFermat/xFermat/blob/main/SECURITY.md)):** Pure `py3-none-any` source Python + runtime-compiled Metal shaders (zero compiled `.dylib`/`.so` blobs, zero `pickle` checkpoint loading, zero telemetry).
|
|
151
|
+
- **Licensing ([`LICENSE`](https://github.com/xFermat/xFermat/blob/main/LICENSE)):** Free (`€0`) for solo personal & academic use on **1 personal Mac**. Commercial redistribution and business fleets (`€39/seat` Pro, `From €750/mo` Enterprise) are licensed via [xfermat.com/pricing](https://xfermat.com/pricing).
|
xfermat-0.6.0/README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# xFermat (`v0.6.0`) — Apple Silicon Open Inference Runtime
|
|
2
|
+
|
|
3
|
+
**xFermat Open Runtime** provides Apple Silicon Metal GPU kernels, native-speed Safetensors loading, fused 2-bit/4-bit **KIVI KV-cache** decoding (`--kv-bits 4|2`), **3:1 Mamba-2 SSD + SDPA** hybrid layers (`FermatModel`), and an empirical shape autotuner ([`FermatEngine`](https://github.com/xFermat/xFermat/blob/main/src/fermat/engine.py)) unifying 18 peer-reviewed foundations.
|
|
4
|
+
|
|
5
|
+
> **Open-Core Architecture:** This public repository and PyPI runtime distribute the transparent, pure-source inference engine (`xfermat info`, `xfermat bench`, `xfermat run`, `load_compressed_model`, `FermatKIVICache`, and verified Metal kernels). Proprietary offline weight compression (`Clip-GPTQ`, `4D VPTQ`) and `MOHAWK` distillation modules remain private commercial tools under [`aopas software development`](https://xfermat.com/pricing).
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Measured Apple Silicon Summary (`Qwen2.5-0.5B` & `1.5B`)
|
|
10
|
+
|
|
11
|
+
Full disjoint evaluations, null-result boundaries, and reproducible JSON logs live in [`WHITEPAPER.md`](https://github.com/xFermat/xFermat/blob/main/WHITEPAPER.md) and [`benchmarks/`](https://github.com/xFermat/xFermat/tree/main/benchmarks):
|
|
12
|
+
|
|
13
|
+
| Benchmark (`8 GB` Apple Silicon GPU, `mlx 0.32.4`) | Strongest Native / Baseline | **xFermat `v0.6.0`** | Verified Gain |
|
|
14
|
+
| :--- | :--- | :--- | :--- |
|
|
15
|
+
| **`Qwen2.5-0.5B` 3-Bit KL & Decode** | `mlx_lm.awq`: `0.792` KL (`98.3 tok/s`) | **`0.423` KL (`144.1 tok/s`)** | **-47% KL**, **1.47× faster** |
|
|
16
|
+
| **`Qwen2.5-0.5B` 4-Bit `WikiText-2` PPL** | `mlx_lm.awq`: `23.86` PPL (`0.132` KL) | **`23.61` PPL (`0.100` KL, `150.4 tok/s`)** | **-25% in-dom KL**, beats AWQ |
|
|
17
|
+
| **`Qwen2.5-1.5B` 3-Bit Footprint & Reload** | `2,944.4 MB` BF16 (`21.3 tok/s` swap) | **`783.9 MB` (`3.76×`), `0.70 s` reload, `60.0 tok/s`** | **-12% KL vs AWQ** (`37.36` PPL) |
|
|
18
|
+
| **`8K` KIVI KV Cache (`D=128, G=64`)** | FP16 `16.0 MB` / 2b per-token `0.533` cos | **`3.16 MB` (`5.06×`), `0.710 ms`, `0.923` cos** | Live `mlx_lm` KV cut **`2.86×–3.66×`** |
|
|
19
|
+
| **`8K` 3:1 Hybrid SSD State & Decode** | Flash `65.5 MB` (`378.7 tok/s`) | **`16.4 MB` (`3.99×`), `457.4 tok/s`** | **`1.21×` decode / `1.53×` prefill** |
|
|
20
|
+
|
|
21
|
+
*(Honest engineering caveat: 3-bit and 4-bit remain the recommended production PTQ tiers; compact `0.5B` 2-bit post-training weights still trail BF16 on open-ended chat until QAT lands in `v0.7.0`. Under `mode="auto"`, sub-cubic Winograd–Strassen, AlphaEvolve rank-48, ternary LUTs, and 120-bit CRT FP64 stay opt-in where native Apple GEMM/BLAS wins.)*
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Runtime Modules Included (`src/fermat/`)
|
|
26
|
+
|
|
27
|
+
| Module | Capability |
|
|
28
|
+
| :--- | :--- |
|
|
29
|
+
| [`src/fermat/kv_quant.py`](https://github.com/xFermat/xFermat/blob/main/src/fermat/kv_quant.py) | `QuantizedKVCache`, `FermatKIVICache`, fused Metal `L_q=1` register-unpack KIVI (`--kv-bits 4/2`) |
|
|
30
|
+
| [`src/fermat/persistence.py`](https://github.com/xFermat/xFermat/blob/main/src/fermat/persistence.py) | Sub-second sharded `.safetensors` serialization & `load_compressed_model` |
|
|
31
|
+
| [`src/fermat/engine.py`](https://github.com/xFermat/xFermat/blob/main/src/fermat/engine.py) | `FermatEngine(mode="auto")` per-shape median + 10% hysteresis autotuner |
|
|
32
|
+
| [`src/fermat/io_algebra.py`](https://github.com/xFermat/xFermat/blob/main/src/fermat/io_algebra.py) | `flash_tiled_attention` (SDPA auto-routing + Split-KV Metal `FlashDecode`) & `WinogradConv2d` |
|
|
33
|
+
| [`src/fermat/ssd_mamba.py`](https://github.com/xFermat/xFermat/blob/main/src/fermat/ssd_mamba.py) | Chunked `Q_c=64` Mamba-2 State Space Duality Metal forward + reverse-VJP scan |
|
|
34
|
+
| [`src/fermat/structured.py`](https://github.com/xFermat/xFermat/blob/main/src/fermat/structured.py) | `HadamardQuantLinear`, `FermatFinalNorm`, `MonarchLinear`, fused Metal SRAM FWHT (`R4`) |
|
|
35
|
+
| [`src/fermat/bilinear.py`](https://github.com/xFermat/xFermat/blob/main/src/fermat/bilinear.py) | AlphaEvolve `<4,4,4>`, AlphaTensor, Gauss 3M, Winograd-Strassen + bundled `.npz` tables |
|
|
36
|
+
| [`src/fermat/rns_ozaki.py`](https://github.com/xFermat/xFermat/blob/main/src/fermat/rns_ozaki.py) | Explicit 120-bit CRT-Ozaki II GPU FP64 reconstruction (`7.56e-16` rel. err.) |
|
|
37
|
+
| [`src/fermat/ternary.py`](https://github.com/xFermat/xFermat/blob/main/src/fermat/ternary.py) | `OzakiHadamardTernaryLinear` (`T-MAC` Metal SRAM LUTs) |
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Quickstart & Security Verification
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
# Install runtime (add [llm] to load & stream Hugging Face / mlx-lm models with KIVI)
|
|
45
|
+
pip install "xfermat[llm]"
|
|
46
|
+
|
|
47
|
+
# Verify pure-source package integrity & Metal GPU runtime
|
|
48
|
+
xfermat info
|
|
49
|
+
xfermat bench --json
|
|
50
|
+
|
|
51
|
+
# Stream any Hugging Face / mlx-lm model with fused 4-bit KIVI KV cache
|
|
52
|
+
xfermat run Qwen/Qwen2.5-0.5B-Instruct --kv-bits 4 --prompt "Explain Fermat's principle."
|
|
53
|
+
|
|
54
|
+
# Or load a saved compressed xFermat safetensors checkpoint in ~0.7s
|
|
55
|
+
xfermat run ./path-to-compressed-model --kv-bits 4 --prompt "Explain Fermat's principle."
|
|
56
|
+
|
|
57
|
+
# Verify runtime suite
|
|
58
|
+
pytest -q
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
- **Supply-Chain Transparency ([`SECURITY.md`](https://github.com/xFermat/xFermat/blob/main/SECURITY.md)):** Pure `py3-none-any` source Python + runtime-compiled Metal shaders (zero compiled `.dylib`/`.so` blobs, zero `pickle` checkpoint loading, zero telemetry).
|
|
62
|
+
- **Licensing ([`LICENSE`](https://github.com/xFermat/xFermat/blob/main/LICENSE)):** Free (`€0`) for solo personal & academic use on **1 personal Mac**. Commercial redistribution and business fleets (`€39/seat` Pro, `From €750/mo` Enterprise) are licensed via [xfermat.com/pricing](https://xfermat.com/pricing).
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Security & Supply-Chain Integrity Policy (`xFermat`)
|
|
2
|
+
|
|
3
|
+
**xFermat** is built for local and air-gapped Apple Silicon environments where developers and regulated enterprise IT teams must verify every line of code before execution.
|
|
4
|
+
|
|
5
|
+
## 1. Supply-Chain & Binary Verification Guarantees
|
|
6
|
+
|
|
7
|
+
1. **Pure Source Python + Metal (`py3-none-any`):**
|
|
8
|
+
Official wheels (`xfermat-*-py3-none-any.whl`) contain readable Python source files, readable Metal shader kernels, and bundled `.npz` decomposition tables—with **zero compiled C/C++ binaries (`.so`, `.dylib`)** and **zero `setup.py` install-time scripts**. You can audit the full archive before running via `unzip -l xfermat-0.6.0-py3-none-any.whl`.
|
|
9
|
+
2. **Zero `pickle` Weight Execution (`.safetensors` Only):**
|
|
10
|
+
Compressed LLM weights and metadata are serialized exclusively via **Safetensors** (`model.safetensors`, `xfermat_quant_config.json`). xFermat never loads arbitrary Python pickle (`.pkl` / `.pt` / `.bin`) checkpoints.
|
|
11
|
+
3. **Zero Outbound Runtime Telemetry:**
|
|
12
|
+
The `fermat` runtime, CLI (`xfermat run`), and Metal kernels make zero analytics, update-check, or licensing network calls during execution (Wi-Fi completely off capable). The only optional network fetch is `mlx_lm.load(...)` when a user explicitly passes a remote Hugging Face Hub repo ID during initial compression.
|
|
13
|
+
4. **PyPI Trusted Publishing & Cryptographic Provenance (`PEP 740`):**
|
|
14
|
+
Public PyPI releases are published exclusively from `github.com/xFermat/xFermat` via GitHub OIDC Trusted Publishing (`id-token: write`, no static PyPI API tokens) with Sigstore build attestations enabled (`attestations: true`).
|
|
15
|
+
5. **Deterministic Checksum Verification (`SHA256SUMS.txt`):**
|
|
16
|
+
Compare local downloads directly against published SHA-256 digests:
|
|
17
|
+
```bash
|
|
18
|
+
shasum -a 256 -c SHA256SUMS.txt
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## 2. Reporting a Security Vulnerability
|
|
22
|
+
|
|
23
|
+
- **Security Contact:** [`security@xfermat.com`](mailto:security@xfermat.com)
|
|
24
|
+
- **General / Rapid Escalation:** [`ask@xfermat.com`](mailto:ask@xfermat.com)
|
|
25
|
+
- **Maintainer Entity:** `aopas software development` (Owner: Aris Nikolaou, Große Brinkgasse 9, 50672 Cologne, Germany · USt-IdNr. `DE314648161`)
|
|
26
|
+
|
|
27
|
+
Please avoid filing public GitHub Issues for sensitive vulnerabilities; we acknowledge security disclosures within 24 hours on business days.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.25.0"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "xfermat"
|
|
7
|
+
version = "0.6.0"
|
|
8
|
+
description = "Apple Silicon Metal GPU inference runtime: fused 2-bit/4-bit KIVI KV-cache, sub-second Safetensors loading, SDPA/FlashDecode, Mamba-2 SSD hybrids, and CRT-Ozaki II FP64"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { file = "LICENSE" }
|
|
11
|
+
authors = [{ name = "Aris Nikolaou (aopas software development)", email = "ask@xfermat.com" }]
|
|
12
|
+
keywords = ["mlx", "apple-silicon", "metal", "llm", "inference", "quantization", "kv-cache", "kivi", "mamba2", "safetensors"]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Development Status :: 4 - Beta",
|
|
15
|
+
"Environment :: GPU",
|
|
16
|
+
"Environment :: MacOS X",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"Intended Audience :: Science/Research",
|
|
19
|
+
"License :: Other/Proprietary License",
|
|
20
|
+
"Operating System :: MacOS :: MacOS X",
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
"Programming Language :: Python :: 3.13",
|
|
24
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
25
|
+
]
|
|
26
|
+
requires-python = ">=3.12"
|
|
27
|
+
dependencies = [
|
|
28
|
+
"mlx>=0.20.0",
|
|
29
|
+
"numpy>=1.26.0",
|
|
30
|
+
"scipy>=1.12.0",
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
[project.urls]
|
|
34
|
+
Homepage = "https://xfermat.com"
|
|
35
|
+
Documentation = "https://xfermat.com/docs"
|
|
36
|
+
Whitepaper = "https://xfermat.com/whitepaper"
|
|
37
|
+
Repository = "https://github.com/xFermat/xFermat"
|
|
38
|
+
Issues = "https://github.com/xFermat/xFermat/issues"
|
|
39
|
+
|
|
40
|
+
[project.optional-dependencies]
|
|
41
|
+
llm = ["mlx-lm>=0.20.0"]
|
|
42
|
+
dev = ["pytest>=8.0.0"]
|
|
43
|
+
|
|
44
|
+
[project.scripts]
|
|
45
|
+
xfermat = "fermat.cli:main"
|
|
46
|
+
fermat = "fermat.cli:main"
|
|
47
|
+
|
|
48
|
+
[tool.hatch.build.targets.wheel]
|
|
49
|
+
packages = ["src/fermat"]
|
|
50
|
+
|
|
51
|
+
[tool.hatch.build.targets.sdist]
|
|
52
|
+
include = [
|
|
53
|
+
"/src",
|
|
54
|
+
"/tests",
|
|
55
|
+
"/README.md",
|
|
56
|
+
"/LICENSE",
|
|
57
|
+
"/SECURITY.md",
|
|
58
|
+
"/pyproject.toml",
|
|
59
|
+
]
|
|
60
|
+
|
|
61
|
+
[tool.pytest.ini_options]
|
|
62
|
+
testpaths = ["tests"]
|
|
63
|
+
pythonpath = ["src"]
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"""xFermat Open Runtime (`v0.6.0`): Apple Silicon Metal Kernels, KIVI KV Cache & Safetensors Inference.
|
|
2
|
+
|
|
3
|
+
Note: Proprietary offline compression & distillation compiler modules (`surgery`, `codebook`,
|
|
4
|
+
`distill`) are omitted from the public open-runtime package; see https://xfermat.com/pricing.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from fermat.bilinear import (
|
|
10
|
+
alphaevolve_4x4_complex_matmul,
|
|
11
|
+
bilinear_tensor_matmul,
|
|
12
|
+
gauss_complex_matmul,
|
|
13
|
+
load_alphaevolve_tensors,
|
|
14
|
+
load_alphatensor_factorizations,
|
|
15
|
+
winograd_strassen_matmul,
|
|
16
|
+
)
|
|
17
|
+
from fermat.engine import FermatEngine
|
|
18
|
+
from fermat.io_algebra import WinogradConv2d, flash_tiled_attention
|
|
19
|
+
from fermat.kv_quant import FermatKIVICache, QuantizedKVCache, make_kivi_prompt_cache
|
|
20
|
+
from fermat.model import FermatBlock, FermatConfig, FermatModel, PreallocatedKVCache
|
|
21
|
+
from fermat.persistence import load_compressed_model, save_compressed_model
|
|
22
|
+
from fermat.rns_ozaki import CRTModularGEMM, OZAKI2_MODULI_24, OZAKI_SLICE_MODULI_11
|
|
23
|
+
from fermat.ssd_mamba import SSDLayer, ssd_chunked_scan
|
|
24
|
+
from fermat.structured import (
|
|
25
|
+
FermatFinalNorm,
|
|
26
|
+
HadamardQuantLinear,
|
|
27
|
+
MonarchLinear,
|
|
28
|
+
apply_inverse_hadamard,
|
|
29
|
+
apply_randomized_hadamard,
|
|
30
|
+
fast_walsh_hadamard,
|
|
31
|
+
gptq_quantize_linear,
|
|
32
|
+
)
|
|
33
|
+
from fermat.ternary import OzakiHadamardTernaryLinear
|
|
34
|
+
|
|
35
|
+
__version__ = "0.6.0"
|
|
36
|
+
|
|
37
|
+
__all__ = [
|
|
38
|
+
"CRTModularGEMM",
|
|
39
|
+
"FermatBlock",
|
|
40
|
+
"FermatConfig",
|
|
41
|
+
"FermatEngine",
|
|
42
|
+
"FermatFinalNorm",
|
|
43
|
+
"FermatKIVICache",
|
|
44
|
+
"FermatModel",
|
|
45
|
+
"HadamardQuantLinear",
|
|
46
|
+
"MonarchLinear",
|
|
47
|
+
"OZAKI2_MODULI_24",
|
|
48
|
+
"OZAKI_SLICE_MODULI_11",
|
|
49
|
+
"OzakiHadamardTernaryLinear",
|
|
50
|
+
"PreallocatedKVCache",
|
|
51
|
+
"QuantizedKVCache",
|
|
52
|
+
"SSDLayer",
|
|
53
|
+
"WinogradConv2d",
|
|
54
|
+
"alphaevolve_4x4_complex_matmul",
|
|
55
|
+
"apply_inverse_hadamard",
|
|
56
|
+
"apply_randomized_hadamard",
|
|
57
|
+
"bilinear_tensor_matmul",
|
|
58
|
+
"fast_walsh_hadamard",
|
|
59
|
+
"flash_tiled_attention",
|
|
60
|
+
"gauss_complex_matmul",
|
|
61
|
+
"gptq_quantize_linear",
|
|
62
|
+
"load_alphaevolve_tensors",
|
|
63
|
+
"load_alphatensor_factorizations",
|
|
64
|
+
"load_compressed_model",
|
|
65
|
+
"make_kivi_prompt_cache",
|
|
66
|
+
"save_compressed_model",
|
|
67
|
+
"ssd_chunked_scan",
|
|
68
|
+
"winograd_strassen_matmul",
|
|
69
|
+
]
|
|
Binary file
|
|
Binary file
|
|
Binary file
|