Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
1a2208c
Add checked BF16 Vulkan tensor operations and operator gate
joshuaswarren Oct 28, 2026
1695ae8
Add checked BF16 Vulkan norm and MLP operator gate
joshuaswarren Oct 28, 2026
d2e262c
Add native Vulkan attention, recurrent and greedy operator gates
joshuaswarren Oct 28, 2026
9310baa
Report the first residual-add class mismatch without changing acceptance
joshuaswarren Oct 28, 2026
2574eb5
Make attention and recurrent probes reject unwritten outputs and matc…
joshuaswarren Oct 28, 2026
ca3c480
Add the native Vulkan dense Qwen3.5-2B greedy engine and oracle probe
joshuaswarren Oct 28, 2026
754cff9
Qualify residual denormals by device float controls and request suppo…
joshuaswarren Oct 28, 2026
4f661d3
Fix Vulkan attention gate widening and diagnose GDN reference failures
joshuaswarren Oct 28, 2026
853e6a2
Separate Vulkan prefill snapshot dummy from read-only slot
joshuaswarren Oct 28, 2026
ab5a359
Match Vulkan decode raw-gate flag to the shader mask
joshuaswarren Oct 28, 2026
3f6a507
fix(vulkan): admit parsed checkpoint geometry and validate full load
joshuaswarren Oct 28, 2026
ad543c3
feat(vulkan): chunk Qwen3.5 prefill within the context ceiling
joshuaswarren Oct 28, 2026
decbcce
fix(vulkan): use one GDN path for prefill and decode
joshuaswarren Oct 28, 2026
c2adf45
build(vulkan): give the contract runner every operator's SPIR-V and a…
joshuaswarren Oct 28, 2026
c1127b3
contract(vulkan): the gdn group's GatedDeltaNet shaders under the ker…
joshuaswarren Oct 28, 2026
e161f15
contract(vulkan): fix the gdn group's fixture against the first devic…
joshuaswarren Oct 28, 2026
d3d40ef
contract(vulkan): keep the gdn split's served a_log normal and state …
joshuaswarren Oct 28, 2026
a7e2eb6
contract(vulkan): the datamove group's seven exact kernels through ga…
joshuaswarren Oct 28, 2026
05e5a96
contract(vulkan): the attention group over the engine's served shapes
joshuaswarren Oct 28, 2026
d675a0e
contract(vulkan): the greedy group's composed draw through gates 1-4
joshuaswarren Oct 28, 2026
8360b60
contract(vulkan): the pointwise group's six closures over the product…
joshuaswarren Oct 28, 2026
66f1a7d
build(vulkan): run the datamove host tests on the build host, not the…
joshuaswarren Oct 28, 2026
1c1abbe
contract(vulkan): refuse odd 16-bit edge shapes in the datamove casts…
joshuaswarren Oct 28, 2026
3ee1f3a
contract(vulkan): the gdn prefill's uploads must not slice out past w…
joshuaswarren Oct 28, 2026
57b9c9a
contract(vulkan): upload the greedy shell's guard pattern instead of …
joshuaswarren Oct 28, 2026
b303483
contract(vulkan): model the preserve add as the pipeline that is actu…
joshuaswarren Oct 28, 2026
fd84ca1
fix(vulkan): the GDN bf16 store keeps infinity infinity
joshuaswarren Oct 28, 2026
4eae870
contract(vulkan): record the preserve-add subnormal flush as a known …
joshuaswarren Oct 28, 2026
ca99293
contract(vulkan): the gated norm gate at the production per-head geom…
joshuaswarren Oct 28, 2026
3ad9625
style: zig fmt, one-line comments and the changelog entry for #1544
joshuaswarren Oct 30, 2026
fe8f362
style: every comment one line, the changelog credit for #1544
joshuaswarren Oct 30, 2026
11a4af2
style: shorten every added comment to one line of at most 120 columns
joshuaswarren Oct 30, 2026
ac0f979
style(vulkan): the attention header's comments one line each
joshuaswarren Nov 3, 2026
e970615
lean: the stage 2 fixture's cases in their own file
joshuaswarren Nov 3, 2026
4697f42
lean: the stage 3 fixture's cases in their own file
joshuaswarren Nov 3, 2026
fbf4d45
refactor(vulkan): the GDN geometry plans move to their own module
joshuaswarren Nov 3, 2026
a8f4b18
refactor(vulkan): the datamove contract's rig moves to its own module
joshuaswarren Nov 3, 2026
915c7ad
refactor(vulkan): the Qwen3.5 probe's receipt moves to its own module
joshuaswarren Nov 3, 2026
029ee78
build: the Vulkan stages' build steps move into their own file
joshuaswarren Nov 3, 2026
dadfae7
style: the trig header's comments are one line each
joshuaswarren Nov 3, 2026
db31834
style: split the stage 4 fixture and probe into lean files
joshuaswarren Nov 3, 2026
c2a6fa7
lean: the gdn contract's layers in their own files
joshuaswarren Nov 3, 2026
3739f5c
qwen3_5 Vulkan: drop stale full_every pin, honor prefill max_rows
joshuaswarren Nov 7, 2026
3b4aba4
vulkan: origin and copyright headers, plain comments, and our own nam…
joshuaswarren Nov 12, 2026
4bd2c82
vulkan: clarify oracle comments and naming
joshuaswarren Nov 13, 2026
8312c7f
feat(vulkan): qmm_q4_vec4, the q4 projection with 16-byte weight and …
joshuaswarren Nov 3, 2026
2994e9a
contract(vulkan): register qmm_q4_vec4 and run it through the same ga…
joshuaswarren Nov 3, 2026
96f996e
docs(vulkan): receipts for qmm_q4_vec4 on a 13-inch M1, and the chang…
joshuaswarren Nov 3, 2026
39e2e0f
docs(vulkan): contract runner output for qmm_q4_vec4 on a 13-inch M1
joshuaswarren Nov 3, 2026
b926e01
Rename ASH labels to oracle and correct file headers on the vulkan qm…
joshuaswarren Nov 9, 2026
35eddd4
style(vulkan): shorten the two renamed comments to 120 columns, so le…
joshuaswarren Nov 10, 2026
7703fb7
shaders: f32 activation variants for the wide layers 0-3 stores
joshuaswarren Nov 5, 2026
0ac8aae
vulkan ops: f32 activation pipelines for the wide-layer stores
joshuaswarren Nov 5, 2026
c66d485
qwen35 engine: per-layer activation kind, layers 0-3 f32
joshuaswarren Nov 5, 2026
5fd26e6
tests: f32 pipeline fixtures, the wide-layer sweep, lean formatting
joshuaswarren Nov 5, 2026
18b3adf
style: one-line comments at the layer-kind call sites
joshuaswarren Nov 5, 2026
7874653
style: keep the lean check at base parity
joshuaswarren Nov 5, 2026
ca89fe6
qwen35 vulkan: make the f32 layers 0-3 path run end to end
joshuaswarren Nov 5, 2026
736f780
cli: the backend flag lists only the choices this build serves
joshuaswarren Nov 9, 2026
4c877f3
docs: the credits page names what the vulkan qwen3.5 engine follows
joshuaswarren Nov 9, 2026
31bfc32
server: --backend choices list the whole set so unserved picks get th…
joshuaswarren Nov 10, 2026
64f168a
server: vulkan joins the backend choices; the credits name the omarch…
joshuaswarren Nov 11, 2026
174d84f
server: the backend-choice test moves to its own file under the 600-l…
joshuaswarren Nov 11, 2026
72e61fb
docs: qmm_q4_vec4 figures measured on the float32-fixed head
joshuaswarren Nov 11, 2026
6e96cb4
contract(vulkan): sync contract_qmm with main's adopt-based Fixture.p…
joshuaswarren Nov 10, 2026
2bf3086
feat(vulkan): qmm_q4_tile, the q4 projection over weights repacked in…
joshuaswarren Nov 3, 2026
9fd2ae0
contract(vulkan): register qmm_q4_tile and run it through the same ga…
joshuaswarren Nov 3, 2026
024abc8
fix(vulkan): the tiled image serves every n; the last tile is padded …
joshuaswarren Nov 3, 2026
6e626fe
docs(vulkan): receipts and the changelog line for qmm_q4_tile on a 13…
joshuaswarren Nov 3, 2026
ebdbef4
style(vulkan): one-line comments in the tile files, so lean_check add…
joshuaswarren Nov 3, 2026
fde403d
fix(vulkan): float32 layers stay on row weights, and each qmm fixture…
joshuaswarren Nov 11, 2026
980489b
style(vulkan): format weights.zig and keep the tile doc comment to on…
joshuaswarren Nov 11, 2026
22fb338
docs: qmm_q4_tile figures measured on the float32-fixed heads
joshuaswarren Nov 11, 2026
331cce7
vulkan: q4 tile image reads and stores f32 activations
joshuaswarren Nov 12, 2026
6529e5e
vulkan: kernel contract fixture for the f32 q4 tile image
joshuaswarren Nov 12, 2026
4f76809
vulkan: keep the tiledActivation comment on one line
joshuaswarren Nov 12, 2026
c803a0e
docs: pinned head-to-head timing and ten runner outputs for qmm_q4_ti…
joshuaswarren Nov 12, 2026
0dd5b42
docs: correct qmm vec4 attribution and ELF identity
joshuaswarren Nov 14, 2026
010d9c7
docs: record qmm tile ELF identities
joshuaswarren Nov 14, 2026
4132db9
docs: name the build behind each qmm tile digest after the #1990 restack
joshuaswarren Nov 14, 2026
73f9bcb
chore: restore the fabric/tp README and name the shader comments and …
joshuaswarren Nov 14, 2026
c5d99a5
Adapt PR #2015 to supplied main
ashhart Nov 22, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions THIRD_PARTY_NOTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,31 @@ The native engine carries that adaptation. `zig/kernels/metal/qwen3_5/gdn_pre.me
`zig/kernels/metal/core/deltanet.metal` and Flash Next's `zig/kernels/metal/flashnext/q4_gdn_*.metal` run the same
model math.

## Vulkan affine projections
## Vulkan shaders from omarchy-mlx

These files in `zig/kernels/vulkan/` come from [omarchy-mlx](https://github.com/joshuaswarren/omarchy-mlx),
MIT License, Copyright © 2026 Joshua Warren and mlx-omarchy contributors. The first lines of each file name its
source path and commit. The native Vulkan path does not link MLX.

- `argreduce_chunk.comp`
- `argreduce_combine.comp`
- `binary_vec.comp`
- `cast.comp`
- `conv_dw1d.comp`
- `copy_general.comp`
- `dequant.comp`
- `fast_norm.comp`
- `fast_norm_gated.comp`
- `fast_rope.comp`
- `gated_delta_decode.comp`
- `gated_delta_prefill_oracle.comp`
- `gather_take.comp`
- `gdn_conv_decode.comp`
- `omarchy_trig.h`
- `qmm.comp`
- `sdpa_decode_native.comp`
- `swiglu.comp`

`zig/kernels/vulkan/qmm.comp` adapts the GLSL shader from
[mlx-omarchy](https://github.com/joshuaswarren/omarchy-mlx), MIT License,
Copyright © 2026 Joshua Warren and mlx-omarchy contributors.
Its arithmetic is unchanged; the native Vulkan path does not link MLX.
See [the license text](LICENSES/mlx-omarchy-MIT.txt).

## Qwen Flash Next
Expand Down
5 changes: 4 additions & 1 deletion build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,10 @@ pub fn build(b: *std.Build) void {
if (with_hip) hip_build.steps(b, target, optimize, build_options, test_step, hip_options);
const with_vulkan = b.option(bool, "vulkan", "Enable the opt-in Vulkan backend and its host/device targets") orelse false;
const vulkan_options = vulkan_build.options(b); // declared on every target, used only with -Dvulkan=true
if (with_vulkan) vulkan_build.steps(b, target, optimize, test_step, vulkan_options);
if (with_vulkan) {
vulkan_build.steps(b, target, optimize, test_step, vulkan_options);
@import("zig/build/vulkan_model.zig").steps(b, target, optimize, test_step, vulkan_options, build_options);
}
exlr8_build.hostTests(b, target, test_step);
xpu_build.steps(b, target, optimize, build_options);
video_build.steps(b, target, test_step);
Expand Down
9 changes: 9 additions & 0 deletions docs/credits.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,15 @@ contributions are in it.
([lane_qmm.py](https://github.com/ashhart/TensorFold/blob/v0.6.6/src/tensorfold/kernels/qwen/dense/v1/lane_qmm.py)),
widening each group to nibbles for the 4-bit tensor op. The native `zig/kernels/metal/core/lane_projection.metal`
stages 2- and 3-bit codes the same way.
- The native Vulkan dense Qwen3.5-2B engine (`zig/src/families/qwen3_5/backend/vulkan/`) follows the same frozen
dense-lane design ([lane_qmm.py](https://github.com/ashhart/TensorFold/blob/v0.6.6/src/tensorfold/kernels/qwen/dense/v1/lane_qmm.py),
[#34](https://github.com/ashhart/TensorFold/pull/34)) for its per-lane qmm decomposition.
- Nine compute shaders are code-unchanged from Joshua Warren's MIT-licensed omarchy-mlx: `argreduce_chunk`,
`argreduce_combine`, `cast`, `conv_dw1d`, `copy_general`, `dequant`, `gather_take`, `gdn_conv_decode` and
`qmm.comp`. `omarchy_trig.h` is also code-unchanged; its comments are condensed.
- Eight compute shaders are adapted: `binary_vec`, `fast_norm`, `fast_norm_gated`, `fast_rope`, `gated_delta_decode`,
`gated_delta_prefill_oracle`, `sdpa_decode_native` and `swiglu`. Their headers record the changed lines.
- `attention_gate`, `finite_logits`, `gdn_split`, `qmm_q4_vec4` and the contract controls are new work for this engine.
- @di37 made the engine read the GPU generation once from `applegpu_gN`, and a virtual machine's GPU as none, in
[#209](https://github.com/ashhart/TensorFold/pull/209)
([device.py](https://github.com/ashhart/TensorFold/blob/v0.6.6/src/tensorfold/kernels/device.py)), as
Expand Down
48 changes: 48 additions & 0 deletions docs/receipts/vulkan-qmm-tile-m1/PREREG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# qmm_q4_tile pre-registration (written 2026-11-03 before any GPU run of this change)

## Question

Does storing each projection's weights, scales and biases in 32-column tiles (a load-time repack) make a Qwen3.5-2B run shorter
on the 13-inch M1, with byte-identical logits? The kernel is `qmm_q4_vec4` with only its address formulas changed, so every sum is the same.

## Arms (two ELFs of `tf-qwen35-model`, ReleaseSafe, aarch64)

- old: the vec4 build, commit `e742e023`, ELF `683fcf46...`.
- new: the same plus the tiled image: weights of every projection with n a multiple of 32 are repacked at load; the lm head is a second,
tiled copy of the embedding table (the embedding keeps the row layout). Projections with n = 16 keep the vec4 image.

## Gates (every process, both arms)

1. Exit 0 and a complete receipt (the house receipt check).
2. Generated ids equal the pinned ids.
3. Logits SHA-256 of every process equals one digest per case, the same digest the earlier vec4 runs gave (unicode-24 `e5447d9a...`,
document-256 `147a2d2e...`, document-1024 `7f9d8e65...`).
4. Before the pairs: the stage 1 probe on the GPU runs the tiled image on every tileable projection case and compares bytes to the default image.

## Metric and design

Run 2 duration from the probe's stderr milestones (prefill plus 63 decode steps plus the per-step logits readback), as before.
Three pairs per case, order old,new,new,old,old,new. Cases: unicode-24, document-256, document-1024.

## Decision rule

Speedup: median pair gain of at least 3 percent and all three pair gains positive and all gates hold. Otherwise reported as no speedup and not proposed.

## Forecast (a prediction; I do not know the answer)

Gain of 20 to 45 percent of run 2 on unicode-24 and similar on the documents. Why not more: qmm is about 63 percent of the run net of the submit
cost, the multi-row result showed qmm is not simply load-count limited, and the hardware cache may already hold part of the 1 KiB stride.
I give 20 percent to a gain under 3 percent, and 10 percent to a regression.

## Not claimed

Other chips, other models, other quantizations, the lm head on devices whose storage range is below the table size (they keep the row layout).
The software-device pass is not GPU evidence. Memory: the tied lm head adds about 320 MB of device memory.

## Addendum, written after the final pairs ran (2026-11-03)

The first contract run on the GPU refused the served shape 1x16x64: a registered kernel must serve every shape the contract serves, and the build
above kept the n = 16 projections on the vec4 image. The design changed before the final runs: the repack pads the last tile with zero columns, so the tiled
image serves every n, the n = 16 projections are tiled too, and the arms read "old: the vec4 build, new: the padded tile build". The gates, metric and
decision rule did not change. This addendum was written after the final pairs; the three earlier pairs on the unpadded build are kept in the receipts as an
earlier measurement and are not the result. The forecast above was for the unpadded build; it was not revised.
57 changes: 57 additions & 0 deletions docs/receipts/vulkan-qmm-tile-m1/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# qmm_q4_tile receipts, Apple M1 (13-inch)

The "old" arm is #1990 built from source commit `46571f111b2f0e92963561702b7eaab41868f823`, ELF SHA-256
`2a1d481c692900c1cefb08fa308d5852d2ec748ee7bc24c89ff013c26ac36d72` (6,089,352 bytes). The "new" arm is #2015 built
from source commit `6e6f47f228a662cb26dedf5b24bf7c50c780fe43`, ELF SHA-256
`b3b7f5e17752b31370490a7d4fe3f4ff92cf3593ed3bed447759f52c5561de41` (6,128,512 bytes). Both include the float32
fix. These two ELFs produced every time and digest in this file. The ELFs predate comment- and name-only commits.
The retained receipt does not record the shell build commands. The branch now sits on #1990's later head
`70ff845318d32e99e0598c82dc5c388f8b7a869d` (266d2f62 merged with 8267ec1). That head was measured separately
against its scalar twin in #1990's comments; no table here comes from it.
Each case ran three old and three new processes, interleaved in both orders (old,new,new,old,old,new). Every process ran under `taskset` on the four P cores (CPU 4-7). Run 2 is the prefill plus 63 decode steps plus the per-step logits readback. Linux 7.3.0-2-20261110.1-lab-ARCH, started 2026-11-12 16:16Z, GPU timeouts 0. All 18 processes returned 0 with the pinned ids and the pinned logits digest.

| Case | Old run 2 (median) | New run 2 (median) | Gain: median (pair range) | Logits digest, all six processes |
|---|---:|---:|---|---|
| unicode-24 | 11.8 s | 8.4 s | 28.6% (27.9 to 31.2) | `6bfbb1a55a3e` |
| document-256 | 26.9 s | 12.2 s | 54.4% (53.9 to 61.0) | `8901e17ccef7` |
| document-1024 | 76.9 s | 25.8 s | 66.8% (66.1 to 66.9) | `a472a62c7e22` |

`pinned-heads-summary.json` holds every process row of this run. It is generated from the raw run output.

An earlier run on the same chip did not pin the cores (old build `1e1b7d8c`, new build `b6d9a35b`, started 2026-11-11 19:15Z). Its gains were lower and its logits digests differ from the ones above; the two runs do not say which of the changes caused that:

| Case | Old run 2 (median) | New run 2 (median) | Gain: median (pair range) | Logits digest, all six processes |
|---|---:|---:|---|---|
| unicode-24 | 10.2 s | 9.1 s | 10.9% (6.7 to 22.2) | `e946185d64ae` |
| document-256 | 23.8 s | 15.3 s | 35.6% (32.4 to 37.1) | `3188aaae7d11` |
| document-1024 | 70.2 s | 38.7 s | 44.9% (34.8 to 45.1) | `82c353787e89` |

The gain depends on the environment. The first version of this receipt measured 19.3%, 49.9% and 62.6% on earlier builds with Linux 7.1.12-2-20261013.18-sep-ARCH and Mesa git-9323171c12 (digests `e5447d9a3ab5`, `147a2d2e0232`, `7f9d8e65e90e`). These runs do not separate the cause.

First version's table (earlier builds, earlier environment; old build the vec4 build `e742e023`, new build `618ed699`):

| Case | Old run 2 (median) | New run 2 (median) | Gain: median (pair range) | Logits digest, all six processes |
|---|---:|---:|---|---|
| unicode-24 | 9.2 s | 7.3 s | 19.3% (18.3 to 24.3) | `e5447d9a3ab5` |
| document-256 | 20.5 s | 10.2 s | 49.9% (48.5 to 50.6) | `147a2d2e0232` |
| document-1024 | 59.7 s | 22.3 s | 62.6% (61.4 to 64.0) | `7f9d8e65e90e` |

An earlier measurement, on the build before the last tile was padded (`a2dcaa1d`; the n = 16 projections kept the vec4 image):

| Case | Old run 2 (median) | New run 2 (median) | Gain: median (pair range) | Logits digest, all six processes |
|---|---:|---:|---|---|
| unicode-24 | 9.0 s | 6.9 s | 24.7% (19.5 to 27.6) | `e5447d9a3ab5` |
| document-256 | 20.6 s | 10.5 s | 48.8% (48.0 to 50.6) | `147a2d2e0232` |
| document-1024 | 59.6 s | 22.2 s | 62.8% (62.7 to 63.0) | `7f9d8e65e90e` |

Files:

- `pinned-heads-summary.json` holds every process row, the pairs, the ELF hashes and the setup of the pinned run in the first table. It is generated from the raw run output.
- `fixed-heads-summary.json` is the same for the unpinned run of 2026-11-11 in the second table.
- `summary.json` is the first version's summary (earlier builds, earlier environment, both tile builds). It stays as the record of those runs.
- `runners-2a5a06c2/` holds the output of the ten contract and stage runners at #2015's head (`2a5a06c2`, 2026-11-12, GPU timeouts 0), one file per runner, with `log.txt` listing the exit codes. `tf-vulkan-kernel-contract.txt` includes `qmm_q4_tile_f32`: four kernels pass gates 1 to 4, eight controls caught. `tf-stage1-gpu.txt` holds the projection cases with `tile=identical` (the tiled image against the default image, byte for byte, on the bf16 projections). No byte-level comparison of the f32 tile image against `qmm_f32` exists; the equal logits digests of the two heads are the identity evidence for it.
- `PREREG.md` was written before the first GPU run. Its addendum, written after the final pairs, says what changed and why.
- `raw-files-sha256.txt` lists the SHA-256 of every raw run file the summary was generated from (`final/` and `interim/`) for `summary.json`.

Byte identity: each process writes the SHA-256 of its full logits stream. A case passes only if all six digests are equal and the ids match the pinned ids.
The digests of #1990's head and #2015's head are equal on every input.
Loading
Loading