Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
d26859a
server: kept_probs reports each token's post-filter probabilities fro…
ashhart Nov 13, 2026
a675202
server: pin kept probabilities across projected reply channels
ashhart Nov 14, 2026
e2cca3b
server: adapt kept_probs to completion echo
ashhart Nov 26, 2026
8be7079
changelog: #3207 under Unreleased
ashhart Nov 28, 2026
53facce
Add checked BF16 Vulkan tensor operations and operator gate
joshuaswarren Oct 28, 2026
2794b64
Add checked BF16 Vulkan norm and MLP operator gate
joshuaswarren Oct 28, 2026
2aa37b3
Add native Vulkan attention, recurrent and greedy operator gates
joshuaswarren Oct 28, 2026
9394814
Report the first residual-add class mismatch without changing acceptance
joshuaswarren Oct 28, 2026
5c3b5fa
Make attention and recurrent probes reject unwritten outputs and matc…
joshuaswarren Oct 28, 2026
8939406
Add the native Vulkan dense Qwen3.5-2B greedy engine and oracle probe
joshuaswarren Oct 28, 2026
e008ff7
Qualify residual denormals by device float controls and request suppo…
joshuaswarren Oct 28, 2026
1ea1787
Fix Vulkan attention gate widening and diagnose GDN reference failures
joshuaswarren Oct 28, 2026
440e2da
Separate Vulkan prefill snapshot dummy from read-only slot
joshuaswarren Oct 28, 2026
81d80d8
Match Vulkan decode raw-gate flag to the shader mask
joshuaswarren Oct 28, 2026
bc08db3
fix(vulkan): admit parsed checkpoint geometry and validate full load
joshuaswarren Oct 28, 2026
2508f4f
feat(vulkan): chunk Qwen3.5 prefill within the context ceiling
joshuaswarren Oct 28, 2026
1e35147
fix(vulkan): use one GDN path for prefill and decode
joshuaswarren Oct 28, 2026
93f5acc
build(vulkan): give the contract runner every operator's SPIR-V and a…
joshuaswarren Oct 28, 2026
679ba44
contract(vulkan): the gdn group's GatedDeltaNet shaders under the ker…
joshuaswarren Oct 28, 2026
919727a
contract(vulkan): fix the gdn group's fixture against the first devic…
joshuaswarren Oct 28, 2026
07e1c1d
contract(vulkan): keep the gdn split's served a_log normal and state …
joshuaswarren Oct 28, 2026
896956b
contract(vulkan): the datamove group's seven exact kernels through ga…
joshuaswarren Oct 28, 2026
96fe6e7
contract(vulkan): the attention group over the engine's served shapes
joshuaswarren Oct 28, 2026
180e117
contract(vulkan): the greedy group's composed draw through gates 1-4
joshuaswarren Oct 28, 2026
5d5d74b
contract(vulkan): the pointwise group's six closures over the product…
joshuaswarren Oct 28, 2026
94b2a2e
build(vulkan): run the datamove host tests on the build host, not the…
joshuaswarren Oct 28, 2026
32d42ba
contract(vulkan): refuse odd 16-bit edge shapes in the datamove casts…
joshuaswarren Oct 28, 2026
d9ce631
contract(vulkan): the gdn prefill's uploads must not slice out past w…
joshuaswarren Oct 28, 2026
9cc12c3
contract(vulkan): upload the greedy shell's guard pattern instead of …
joshuaswarren Oct 28, 2026
fb80597
contract(vulkan): model the preserve add as the pipeline that is actu…
joshuaswarren Oct 28, 2026
2cf35d6
fix(vulkan): the GDN bf16 store keeps infinity infinity
joshuaswarren Oct 28, 2026
ff6cb8e
contract(vulkan): record the preserve-add subnormal flush as a known …
joshuaswarren Oct 28, 2026
0f55d0b
contract(vulkan): the gated norm gate at the production per-head geom…
joshuaswarren Oct 28, 2026
a9c4410
style: zig fmt, one-line comments and the changelog entry for #1544
joshuaswarren Oct 30, 2026
5fef018
style: every comment one line, the changelog credit for #1544
joshuaswarren Oct 30, 2026
fbeb663
style: shorten every added comment to one line of at most 120 columns
joshuaswarren Oct 30, 2026
80b9508
style(vulkan): the attention header's comments one line each
joshuaswarren Nov 3, 2026
c87a160
lean: the stage 2 fixture's cases in their own file
joshuaswarren Nov 3, 2026
c45f9b4
lean: the stage 3 fixture's cases in their own file
joshuaswarren Nov 3, 2026
9643dbb
refactor(vulkan): the GDN geometry plans move to their own module
joshuaswarren Nov 3, 2026
814519b
refactor(vulkan): the datamove contract's rig moves to its own module
joshuaswarren Nov 3, 2026
d29cea7
refactor(vulkan): the Qwen3.5 probe's receipt moves to its own module
joshuaswarren Nov 3, 2026
16ba28d
build: the Vulkan stages' build steps move into their own file
joshuaswarren Nov 3, 2026
40cf792
style: the trig header's comments are one line each
joshuaswarren Nov 3, 2026
aba9227
style: split the stage 4 fixture and probe into lean files
joshuaswarren Nov 3, 2026
50c785b
lean: the gdn contract's layers in their own files
joshuaswarren Nov 3, 2026
976245e
qwen3_5 Vulkan: drop stale full_every pin, honor prefill max_rows
joshuaswarren Nov 7, 2026
99c8729
vulkan: origin and copyright headers, plain comments, and our own nam…
joshuaswarren Nov 12, 2026
2495622
vulkan: clarify oracle comments and naming
joshuaswarren Nov 13, 2026
5371e5a
drop this PR's changelog line per the rebase task's CHANGELOG rule
ashhart Nov 22, 2026
1e9f082
vulkan: copied-file headers and notices read the statement's copyrigh…
joshuaswarren Nov 24, 2026
d91dae6
cli config: the stale backend refusal case uses an unlisted backend
joshuaswarren Nov 24, 2026
24c4180
vulkan: fix #1544 correctness bugs, contract gaps, specs, and clean-r…
joshuaswarren Nov 26, 2026
d113042
vulkan: clean-room rewrite of the 17 core/norm/MLP/attention/GDN/gree…
joshuaswarren Nov 26, 2026
c8c2246
vulkan: remove omarchy-mlx notices and tighten vulkan_trig.h lean/non…
joshuaswarren Nov 26, 2026
4540ded
vulkan: dequantized QMM nonfinite, gdn_conv_decode state_rows, nan_ma…
joshuaswarren Nov 26, 2026
0107015
contract(vulkan): add -0 and 0x0001 single-key V transport controls i…
joshuaswarren Nov 26, 2026
b9cb98f
feat(vulkan): clean-room qmm_q4_vec4, wide-F32 layers 0-3, and sdpa_r…
joshuaswarren Nov 26, 2026
e3b4cb3
feat(vulkan): clean-room qmm_q4_tile, qmm_q4_tile_f32, and qmm_f32 co…
joshuaswarren Nov 26, 2026
d4312eb
perf(vulkan): batched dispatch submission on clean-room stack (#2016)
joshuaswarren Nov 26, 2026
8f57dc3
feat(vulkan): clean-room qmm_q4_tile_rows on clean-room stack (#2017)
joshuaswarren Nov 26, 2026
f6c3e2c
perf(vulkan): barrier hazards, fence-tied descriptor checkout, and re…
joshuaswarren Nov 26, 2026
e30a373
vulkan: batch per-step, prefill, greedy readback and reset submissions
joshuaswarren Nov 26, 2026
9e00913
changelog: #5193 under Unreleased
ashhart Nov 28, 2026
4d31629
tests: lane host explore replay sends idle requests after an empty en…
Bizuayeu Nov 27, 2026
957d95f
changelog: #5386's line from lines/5386.txt in place of its own
ashhart Nov 28, 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
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ Each release's page on GitHub has its notes and measurements. See [the 1.0.0 rel

## Unreleased

- Tests: the lane host explore test's replay holds under load: once every request sent has ended, the test thread sends the next only once a whole engine turn has run after the one that ended the last (turns counted through the host's activity scope), so each send meets no prompt visit and lands at the same point on every run (#5386, fixes #5367).

- Vulkan on Apple silicon: submits batch dispatches into one command buffer per batch instead of one submission per dispatch, with hazard-tracked barriers between conflicting dispatches and one barrier owed to the previous submission at the next batch's start; the same logits, 2% to 20% less run time on a 13-inch M1 and a 16-inch M1 Max (#2038, part of #1420). Thanks to @joshuaswarren.

- Server: `"kept_probs": true` on `/v1/chat/completions` (with `logprobs: true`) and `/v1/completions` (with a `logprobs` count) adds a `kept_probs` list for each reply token: the tokens left after temperature, `top_k`, `top_p` and `min_p`, renormalized to sum to 1; a sampled request needs `top_k` from 1 to 20, and a nonzero `presence_penalty` or `frequency_penalty` or a grammar returns HTTP 400; the reply's tokens and every other field are the same with the option on or off (#3207, fixes #3182).

- The New Project Folder row keeps **Browse** on one line while the folder input shrinks. (#4824) Thanks @jamesadcock for the report.

- Inkling 2 CUDA gains grouped-expert and vision kernels, shared core attention/gamma operations, explicit orientation handling and exact arithmetic comparisons (#4127). Thanks to @ajensenwaud.
Expand All @@ -18,8 +24,6 @@ Each release's page on GitHub has its notes and measurements. See [the 1.0.0 rel

- CLI: `tensorfold log` also reads the request log `TENSORFOLD_REQUEST_LOG` writes: `list`, `show ID`, `follow` and `--json` show each reply beside its request, and a bare body is numbered by reader order, never keyed by fields inside it (#5246, refs #3666). Thanks to @devopsfortunato.



- Server: `--confidential` also refuses library search-path variables.
- Server: `--confidential` also refuses accelerator plugin and kernel library-path variables.
- Inkling 2 Mini: different requests on one server get different tool-call IDs, and whole and streamed replies agree; generated tokens are unchanged (#5401). Thanks @fcossutta. Thanks @fcossutta for the report.
Expand Down
21 changes: 0 additions & 21 deletions LICENSES/mlx-omarchy-MIT.txt

This file was deleted.

8 changes: 0 additions & 8 deletions THIRD_PARTY_NOTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,6 @@ 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

`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

The n-gram ID helpers translate Hugging Face transformers' `models/qwen4_exp/modeling_qwen4_exp.py` with renamed
Expand Down
5 changes: 4 additions & 1 deletion build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,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
13 changes: 13 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,19 @@ and `function_call` items. A stream sends them in the `response.output_text.delt
text, and each item's done events wait for them. `include` alone on an engine without logprobs answers without them;
`top_logprobs` there returns HTTP 400.

`"kept_probs": true` (chat with `logprobs: true`, or `/v1/completions` with `logprobs`) adds, for each reply token,
the probabilities the sampler drew it from: the tokens left after temperature, `top_k`, `top_p` and `min_p`, in the
rows' order, renormalized to sum to 1. Chat puts them in each `logprobs.content` entry as `kept_probs`, a list of
`{token, prob}`; `/v1/completions` adds a `kept_probs` list beside `top_logprobs`, one such list per token (with
`echo`, `null` at each prompt position, since only generated reply tokens have kept sets). A greedy request keeps
one token, the best, at probability 1. The server computes them from each token's logprob row with the sampler's
own cut, so they cost no engine work beyond asking for all 20 alternatives; `top_logprobs` still shows the count
asked for, and the reply's tokens and every other field are the same with the option on or off. A sampled request
needs `top_k` from 1 to 20, so the kept set always fits inside the 20 alternatives a row carries; other `top_k`
values (including none), a grammar, or a nonzero `presence_penalty` or `frequency_penalty` return HTTP 400.
The kept set is computed from the rows' 32-bit values, so a token whose cumulative `top_p` sum or `min_p` floor falls
within about 1e-6 of its cut can be listed on the other side of it, and a GPU sampler may skip a kept token more than
24 below the best in logit over temperature, whose listed probability is under 4e-11.
Nonstreamed `/v1/completions` also takes vLLM's `prompt_logprobs`, an integer from 0 through 20, on the same engine
and on GLM-5.3-Flash's CUDA engine.
`choices[0].prompt_logprobs` has one entry per prompt token: `null` for the first, then an object keyed by token id
Expand Down
8 changes: 6 additions & 2 deletions docs/credits.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ 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. All Vulkan compute shaders
and `vulkan_trig.h` under `zig/kernels/vulkan/` are written for TensorFold against the behaviour specifications in
`docs/vulkan-shader-specs/`.
- @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 Expand Up @@ -159,8 +164,7 @@ row-invariant linear, grouped experts and the 27B and Flash Next packs
([cuda/exl3](https://github.com/ashhart/TensorFold/tree/v0.6.6/src/tensorfold/cuda/exl3),
[exl3.md](https://github.com/ashhart/TensorFold/blob/v0.6.6/docs/recipes/exl3.md)). The native EXL3 decoder
(`zig/src/core/exl3_format.zig`, `exl3_projection.zig`) follows the format notes from #42, and the EXLR8 codebook
that serves GLM-5.3 builds on that decoder. The native CUDA engine serves EXL3 packs too: GLM-5.3-Flash's routed
experts, Qwen3.5's `mul1` and `mcg` checkpoints, and Muse Spark Open's 1.8-bit pack.
that serves GLM-5.3 builds on that decoder. The native engine does not serve EXL3 packs yet.

## More Python engine work

Expand Down
70 changes: 70 additions & 0 deletions docs/receipts/vulkan-barrier-hazards-m1/PREREG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Compute-to-compute dispatch barrier: pre-registration (2026-11-03, before any GPU run of this change)

## Question

The decode microbenchmark of `qmm_q4_tile` on the real decode shapes (400 dispatches, batched, 13-inch M1) gave 23.85 ms a decode step with the engine's barrier after every
dispatch and 16.99 ms with no barrier (a 16-column dispatch: 80 us against 3 us). The barrier costs about 70 us a dispatch. The engine's barrier lists the transfer stage and transfer
access among its destinations, which a dispatch followed by a dispatch does not need (copies and fills carry their own barriers in both directions). Does narrowing it to compute to compute
(source: shader write; destination: shader read and write) cut the cost? Nothing else changes, so the logits must stay byte-identical.

## Arms and gates

old: the two-columns build (`9eef5a52`). new: the same with the narrower barrier in `Pipeline.record`. Same pairs, order, gates and digests as `PREREG-rows.md`; all three cases.

## Decision rule

Median gain of at least 3 percent on unicode-24, every pair positive, all gates hold. Otherwise not proposed.

## Forecast (a prediction)

50 percent: no gain (under 3 percent; the driver already treats the barrier alike). 35 percent: 3 to 15 percent less time on unicode-24. 15 percent: more than 15 percent.

## Not claimed

Other chips and models. Barriers between dependent dispatches remain; this changes their kind, not their number.


# Hazard-tracked barriers: pre-registration (2026-11-03, before any GPU run of this change)

## Question

The decode microbenchmark on the 13-inch M1 (Honeykrisp Mesa 26.3.0-devel git-9323171c12, real Qwen3.5-2B decode shapes, 175 `qmm_q4_tile` dispatches a step, batched) gave
23.85 ms a decode step with the engine's barrier after every dispatch and 16.99 ms with none; a 16-column dispatch took 80 us against 3 us. A barrier narrowed to compute-to-compute
changed nothing (-0.14 percent on unicode-24), so the cost is the barrier, not its masks. The engine records a barrier after every dispatch, but many dispatches do not depend on the one
before (the q, k and v projections; the gate and up projections; the four GDN input projections). This build tracks the byte ranges every dispatch since the last barrier read and wrote
(each binding's buffer, offset, length and the pipeline's written-bindings mask) and records a barrier only before a dispatch that reads what an earlier one wrote, or writes what one read
or wrote. A full tracking list forces a barrier. Same dispatches in the same order: the logits must stay byte-identical.

## Arms and gates

old: the two-columns build (`9eef5a52`). new: the same plus hazard-tracked barriers. Same pairs, order, gates and digests as `PREREG-rows.md`: exit 0, pinned ids, one logits digest per
case across all six processes, run 2 duration, pairs alternated old,new,new,old,old,new. Cases: unicode-24, document-256, document-1024. A digest that differs from the pinned one fails the case
whatever the time.

## Decision rule

Median gain of at least 3 percent on unicode-24, every pair positive, all gates hold. Otherwise not proposed.

## Forecast (a prediction)

The no-barrier bound for the projections alone is 29 percent of a decode step (7 ms of 23.85), and decode is about 19 percent of the document-1024 run and about 90 percent of unicode-24's.
Dependent chains keep their barriers, so I expect a third to a half of the bound: 8 to 15 percent less time on unicode-24, 2 to 5 percent on document-1024. I give 20 percent to
a gain under 3 percent on unicode-24 (most dispatches are dependent), and 5 percent to a digest difference (a missed hazard).

## Not claimed

Other chips, models and drivers. The bound comes from the projections alone; the other kernels in a step are not in it.

## Record of the first build (added 2026-11-03, after its unicode-24 pair)

The first build of this change failed its digest gate on unicode-24: logits digest `e8535a02dd1e` against the pinned `e5447d9a3ab5` (the run was 5 percent shorter, which does not matter).
Cause: `greedy.zig` records its three dependent dispatches with `Pipeline.record` and relied on the barrier that call used to add, and its first fill needs the dispatches run before it fenced.
Fix: `record` keeps its barrier (it is the API of direct recorders); only `Pipeline.run` elides; `Commands.sync` fences open dispatches before a direct recorder starts. The corrected build is
a new pair under the same arms, decision rule and forecast.

## Restack on #2017's head `cf73ab96` (12 November)

Written to the idle-guard queue before the runs, as the row text. Arms: `cf73ab96` against `240216fe`, three inputs, old, new, new, old, old, new, a 13-inch M1 and a 16-inch M1 Max.
Forecast: a median gain of 5% to 25% at document-256 and document-1024 and under 5% at unicode-24, equal digests (the 16-inch figure at the old head was 22.4% at document-256).
Falsifier: a median gain under 0% at document-1024, any differing digest, or a cell whose three old (or three new) run 2 times differ by more than 5%.
Result: digests equal everywhere. 13-inch M1: 5.9%, 4.3%, 2.3% at unicode-24, document-256, document-1024, so document-256 and document-1024 fall under the 5% floor of the forecast and unicode-24 over its 5% ceiling; the 16-inch M1 Max: 19.7%, 12.6%, 14.0%, with unicode-24 over its ceiling and document-1024 old arm spread 6.2% (a falsifier hit). The forecast did not hold on the 13-inch M1.
9 changes: 9 additions & 0 deletions docs/receipts/vulkan-barrier-hazards-m1/PROVENANCE-M2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Provenance: Apple M2 Max runs at 1aa60a91

Host: 14-inch M2 Max (Apple M2 Max, G14C B1), Linux side.
Kernel: 7.1.12-2-7-ARCH. Driver: Honeykrisp, Mesa 26.2.2-arch1.1. Zig: 0.17.0.

The v2d packet's PROVENANCE.txt names a 16-inch M1 Max. That line is wrong. Runs were on the 14-inch M2 Max; the runner output and vulkaninfo both read "Apple M2 Max (G14C B1)". PROVENANCE.txt is not edited, because SHA256SUMS covers it.

Run: `tf-vulkan-kernel-contract`, head 1aa60a91, binary sha256 19d640ec553b0f97549670fd931284c26700e8988a721d37572b135aac5cb3d4, under `flock` on the GPU lock.
Result: rc 0, 48.5 s wall. SUMMARY: 4 kernels pass gates 1-4, 0 fail, 0 known findings; 9 controls caught, 0 missed; 0 limit failures.
Loading
Loading