Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
644d178
tests: the Metal limits check finds LFM3's launches again
ashhart Nov 8, 2026
501444f
changelog: #2565
ashhart Nov 8, 2026
1e4b426
lean: a new direct getenv of a TF_ or TENSORFOLD_ name is a finding
Bizuayeu Nov 8, 2026
8f30bfc
lean: a getenv of a name that is not a literal is a finding too, and …
Bizuayeu Nov 8, 2026
f1106ba
refactor(joint_schema): move the head's device plan into core
laudney Nov 7, 2026
73cac5a
refactor(qwen3_5): move the CUDA family's refusal words to a file
laudney Nov 7, 2026
a0d4336
feat(cuda): Clef's joint schema head on the GPU
laudney Nov 7, 2026
7d6bf2c
test(cuda): the joint schema head's kernels under the contract
laudney Nov 7, 2026
8fbc30b
feat(qwen3_5): serve Clef's joint schema head on CUDA
laudney Nov 7, 2026
173ffd9
feat(core): trace a cancel taken between two prompt calls
laudney Nov 7, 2026
983166f
test(cuda): run Clef's head alone on the GPU for gate 3
laudney Nov 7, 2026
fdf8a5f
docs(changelog): note Clef's joint schema head on CUDA
laudney Nov 7, 2026
694eabc
fix(cuda): sum the joint schema head's blocks with the shared helper
laudney Nov 7, 2026
4c20478
docs(api): say Clef on CUDA was checked on a GB10, not only there
laudney Nov 7, 2026
3a4c306
docs(changelog): say Clef on CUDA was checked on a GB10
laudney Nov 7, 2026
d42f3ef
kv pool: groups sized by bytes a row, padding reported at load (#2444…
jschmied Nov 8, 2026
eed44bb
kv pool: a layout that doesn't name its layers shows bytes a token; e…
jschmied Nov 8, 2026
c7c297a
changelog: the line names #2532, part of #2444
jschmied Nov 8, 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
2 changes: 1 addition & 1 deletion .github/workflows/no-gpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
python3 tools/zig/cuda_common_check.py
python3 tools/zig/cuda_fragment_check.py
python3 -m unittest discover -s tools/zig -p cuda_common_check_test.py -v
# The lean rule (600-line files, one-line comments within 120 columns): no problem the base branch lacks.
# The lean rule (600-line files, one-line comments within 120 columns, no direct getenv of a setting): no problem the base branch lacks.
- name: lean check
if: ${{ github.event_name != 'schedule' }}
env:
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@ Each release's page on GitHub has its notes and measurements. See [the 1.0.0 rel

## Unreleased

- Tests: the Metal kernel contract's limits pass checks LFM3's launches again; a rebase had dropped their five entries, so the pass stopped at the first LFM3 record with `UnknownLaunch` and left every later launch unchecked (#2565).
- HIP on gfx12 under `--policy matrix=on`: Qwen3 dense checkpoints load each layer's gate and up weights interleaved as one weight, and one WMMA product writes silu(gate) x up in its epilogue instead of two products and `tf_silu_mul`, with the same output bytes: Qwen3-Reranker-8B ranks 16 documents in 0.657 to 0.661 s instead of 0.687 to 0.697 s and Qwen3-Embedding-8B embeds 100 short inputs in 0.901 to 0.911 s instead of 0.940 to 0.948 s on a Radeon AI PRO R9700. The kernel contract checks both fused blocks byte for byte against the unfused launches (part of #2245). Thanks to @laudney.
- Nemotron on Macs: the masked prompt shader calls the shared `tf_paged_row` page helper again, so its prompt sources compile; #2322 had used the name #2283 retired the same day (#2548).
- CI: a nightly job runs 246 host checks that no per-PR job ran, in shards with their wall times printed; any move to per-PR jobs waits for those timings, and checks that fail on main stay off until fixed (#2554).
- Nemotron on Macs: the masked prompt shader calls the shared `tf_paged_row` page helper again, so its prompt sources compile; #2322 had used the name #2283 retired the same day (#2548). Thanks to @jschmied, who found it first (#2538).
- Tests: `zig build test-nemotron-prefill-metal-sources` compiles Nemotron's prompt shaders, including both masked sources, on a Metal device without running a kernel; it fails on the helper name #2548 fixed (#2558).

- Lean checks: each new `getenv` that reads a setting outside `platform/environment.zig` is a finding, whether it
names a `TF_*` or `TENSORFOLD_*` setting or takes a name that is not a literal, such as a new wrapper's; the reads
already on main, test files and `test` blocks are not counted (#2521). Thanks to @Bizuayeu.
- GLM-5.3-Flash on CUDA: with `TF_KV_SHARE=n`, the startup plan sets a slot aside in the prompt cache for each kept
state, so the cache keeps as many states as its slots hold, up to n, and the rest of it goes to the KV pool's pages;
the startup line names the slots and, when fewer than n fit, the `--prompt-cache-gib` that holds them all. A value
Expand All @@ -21,6 +25,9 @@ Each release's page on GitHub has its notes and measurements. See [the 1.0.0 rel
- HIP on gfx12 under `--policy matrix=on`: the WMMA dense tile's big block takes 64-deep K steps over swizzled LDS rows, its barrier orders LDS only, and the block thresholds are tuned again, with the same output bytes: Qwen3-Reranker-8B ranks 16 documents in 0.694 s instead of 0.720 s and Qwen3-Embedding-8B embeds 100 short inputs in 0.946 s instead of 0.974 s on a Radeon AI PRO R9700. The kernel contract checks the new block byte for byte against a frozen copy of the old one (part of #2245). Thanks to @laudney.
- HIP on gfx12 under `--policy matrix=on`: the WMMA dense tile's big block takes 64-deep K steps over swizzled LDS rows, its barrier orders LDS only, and the block thresholds are tuned again, with the same output bytes: Qwen3-Reranker-8B ranks 16 documents in 0.697 to 0.705 s instead of 0.720 to 0.727 s and Qwen3-Embedding-8B embeds 100 short inputs in 0.946 to 0.956 s instead of 0.969 to 0.995 s on a Radeon AI PRO R9700 (the best run of each of four alternated rounds). The kernel contract checks the new block byte for byte against a frozen copy of the old one (part of #2245). Thanks to @laudney.
- Fabric: a pipeline stage's boot and round loop is one driver, generic over an engine binding, so a CUDA, Metal or XPU stage writes only its binding; nothing uses it yet. A stop that a middle stage receives now passes on instead of closing the ring (#2241, part of #2005). Thanks to @jschmied.
- KV pool: a family's pool group is sized by its bytes a row over its layers, and a paged CUDA load prints a line of each group's rows a page and padding (the window rows and state outside or beside the pool too), apart from the unchanged startup line; every family stays one group, so nothing else changes (#2444 C2, refs #2444).
- KV pool: a family's pool group is sized by its bytes a row over its layers, and a paged CUDA load prints a line of each group's rows a page and padding (the window rows and state outside or beside the pool too), apart from the unchanged startup line; every family stays one group, so nothing else changes (#2444 C2, refs #2444). Thanks to @jschmied.
- KV pool: a family's pool group is sized by its bytes a row over its layers, and a paged CUDA load prints a line of each group's rows a page and padding (the window rows and state outside or beside the pool too), apart from the unchanged startup line; every family stays one group, so nothing else changes (#2532, part of #2444). Thanks to @jschmied.

- LFM2 on Macs: a non-finite value in a masked key no longer reaches prompt attention's output; finite prompts run the same kernels as before, and prefill is level (#2328, part of #1009).
- Release checks: on a Mac release binary, the private-path check no longer reads the code signature's hash bytes as text, which could spell a path by chance and refuse a clean build; the exact build root is still refused there, and the rest of the binary is checked as before (#2524).
Expand Down Expand Up @@ -127,6 +134,13 @@ Each release's page on GitHub has its notes and measurements. See [the 1.0.0 rel
- Docs: `WINDOWS.md` says what the host suite needs on a Windows machine with no usable GPU (Zig alone), how to read the build runner's `failed command:` lines, which tests skip there and why, and how to unzip the Zig download quickly (#2479). Thanks to @Whq02.

- The CUDA Qwen3.5 lanes fill readout prompts in pieces for the joint schema head that follows: from row 0, each piece's final-norm rows go to the readout, 1,024 rows a piece unless the lane host caps it, as on HIP (#2384, part of #2324). Thanks to @laudney.
- The CUDA Qwen3.5 lanes fill readout prompts in pieces for the joint schema head that follows: from row 0, each
piece's final-norm rows to the readout, 1,024 rows a piece unless the lane host caps it, as on HIP (#2384, part of
#2324). Thanks to @laudney.
- Clef-Flash on CUDA: `POST /v1/systemone` serves Cloudflare's BF16 `clef-flash` on one NVIDIA GPU (checked on a
GB10) with its joint schema head on the GPU (HIP's kernels and products, on cuBLASLt with FP32 compute), and chat
is refused by name; `TF_LANE_TRACE` gains a `cancel` line for a request cancelled between two prompt calls (#2458,
part of #2324). Thanks to @laudney.

## 1.2.4

Expand Down
5 changes: 3 additions & 2 deletions THIRD_PARTY_NOTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,9 @@ runs tensor parallelism over it, under the same copyright and Apache License 2.0
## Cloudflare Clef

`zig/src/server/clef_encode.zig` and `clef_answer.zig`, the host head in `zig/src/core/joint_schema/`
(`reference.zig`, `reference_attn.zig`) and the device head in `zig/src/hip/joint_schema/` with its kernels in
`zig/kernels/hip/joint_schema/joint_schema.hip` port Cloudflare's Clef release code, `joint_schema_model.py` in
(`reference.zig`, `reference_attn.zig`), the device heads in `zig/src/hip/joint_schema/` and
`zig/src/cuda/joint_schema/` with their kernels in `zig/kernels/hip/joint_schema/joint_schema.hip` and
`zig/kernels/cuda/joint_schema.cu` port Cloudflare's Clef release code, `joint_schema_model.py` in
[Cloudflare/clef](https://huggingface.co/Cloudflare/clef) and
[Cloudflare/clef-flash](https://huggingface.co/Cloudflare/clef-flash): the record rendering and encoding
(`render`, `question_options`, `encode_record`), the verbatim system prompt, the joint schema head
Expand Down
4 changes: 2 additions & 2 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ context window before the first is scored, so a refused request costs no GPU wor

`POST /v1/systemone` on a Clef checkpoint (Cloudflare's clef-flash: BF16 Qwen3.5 weights with
`joint_head_config.json` and `joint_head.safetensors`) answers each question from the joint schema head, the way the
model card's reference `systemone` does. The native server serves it on one HIP GPU; a Clef engine serves no chat, and
`--tp` is refused. On every other engine the route keeps llama-server's System One request. `capabilities --json`
model card's reference `systemone` does. The native server serves it on one HIP GPU or one NVIDIA GPU (CUDA, checked on a GB10); a Clef
engine serves no chat, and `--tp` is refused. On every other engine the route keeps llama-server's System One request. `capabilities --json`
lists such formats under `decisions` (`"qwen3_5": ["bf16"]`), apart from the `families` formats that serve chat.

```json
Expand Down
3 changes: 3 additions & 0 deletions docs/kernel-contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,9 @@ softmax over FP32 scores to 16,384 keys, GELU, BF16 widening and rounding, the s
rows by id (FP32 in prompt row order) and their means, step 5's option summary, and step 7's logits (prior, cosine and
the scorer's input rows) and their gate, each within float64's bound at the head's BF16 points. Two controls: a layer
norm summed in bf16 and a softmax that skips non-finite scores.
CUDA checks the same head (`joint_schema.cu`, `zig/tests/cuda/contract_js_*.zig`) with the same cases, plus the
lexical sums read from the engine's packed BF16 lm_head (`tf_js_lex_sums`) and the head's residual add and broadcast.
Every kernel has a planted control (`contract_js_controls.cuh`), each naming the gate that catches it.

HIP also checks the router over the rows a checkpoint already holds in bf16 (`tf_router_bf16`, and its fp16-activation
form), bit-equal to the fp32-rows router it replaces at 1 to 16 rows, with both kinds' non-finite plants through gate 1
Expand Down
1 change: 1 addition & 0 deletions docs/pr/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ Never leave a line blank or claim a check you did not run.
- Comments, docstrings, file length and source history follow [lean code and review](../../CONTRIBUTING.md#lean-code-and-review).
- Private identity, privacy and authorship follow [public identity and privacy](../../CONTRIBUTING.md#public-identity-and-privacy); check the author and committer of every outgoing commit with `git log --format='%an %ae | %cn %ce' origin/main..HEAD`.
- Add a setting only with a production caller and a measured benefit; never turn drafts off on an advertised path.
- Read a new setting through `platform/environment.zig`: register a rule in its `rules` table and call `read(T, name, default)`. Unset, empty or whitespace-only text keeps the default, a valid value keeps its meaning, and any other text stops the start with the name, the text and the accepted forms. Lean counts each new `getenv` outside the parser, the registry and the platform shims that names a `TF_*` or `TENSORFOLD_*` setting or takes a name that is not a literal, so a new wrapper is a finding at its `getenv`; calls through the wrappers already on main, test files and `test` blocks are not counted.
- Extend the existing shared cache, scheduler or operator; explain why it cannot be extended before adding a second one.
- Kill only the processes a script started, keep normal SSH host verification, and pin and inspect external reference code before running it.

Expand Down
45 changes: 36 additions & 9 deletions tools/clef_head_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
# usage:
# clef_head_gate.py cases <model dir> <records> <rows> <out> each record's spans, ids and rows paths (case.json)
# clef_head_gate.py reference <model dir> <cases> <out> --dtype bf16|fp64 [--device cuda|cpu]
# clef_head_gate.py native <tf-clef-test> <model dir> <cases> <out> [--piece N|whole]
# clef_head_gate.py compare <cases> <native> <bf16> <fp64> [--report FILE]
# clef_head_gate.py native <tf-clef-test|tf-cuda-test> <model> <cases> <out> [--piece N|whole] [--backend hip|cuda]
# clef_head_gate.py compare <cases> <native> <bf16> <fp64> [--report FILE] [--rule strict|margin]
# The strict rule: per question type, native mean and worst error against FP64 no larger than the reference BF16
# head's. The margin rule keeps the worst and lets the mean sit up to 10% above the reference's.
# The records are clef_backbone_rows.py's; their schema text comes again from its seeded generator, so each field's
# instruction and each option's description give the spans, as token ranges of the record by character offsets.
import argparse, importlib.util, json, math, os, subprocess, sys
Expand All @@ -18,6 +20,8 @@
"checkpoint": "Cloudflare/clef-flash@fb4417d31c1d0f9e7e77f1141b40aaede7491e00",
}
TYPES = {"noul": 0, "choice": 1, "score": 2}
# the margin rule's bound on the native mean error, as a multiple of the reference BF16 head's
MEAN_MARGIN = 1.10


def rows_tool():
Expand Down Expand Up @@ -130,8 +134,24 @@ def cmd_reference(a):


def cmd_native(a):
cmd = [a.binary, "head", a.model, a.cases, a.out] + (["--piece", a.piece] if a.piece else [])
head = ["clef", "head"] if a.backend == "cuda" else ["head"]
cmd = [a.binary, *head, a.model, a.cases, a.out] + (["--piece", a.piece] if a.piece else [])
subprocess.run(cmd, check=True)
if a.backend == "cuda":
check_pieces(a)


def check_pieces(a):
"""Each case's consumed pieces, as the runner recorded them: in order, covering the prompt, at the asked size."""
for name in json.loads((Path(a.cases) / "index.json").read_text())["cases"]:
c = json.loads((Path(a.cases) / f"{name}.json").read_text())
rows = int(np.load(c["ids"]).shape[0])
size = rows if a.piece in (None, "whole") else int(a.piece)
want = [[at, min(size, rows - at)] for at in range(0, rows, size)]
got = json.loads((Path(a.out) / f"{name}.json").read_text())["pieces"]
if got != want:
sys.exit(f"{name}: consumed pieces {got[:3]}... are not {size}-row pieces of {rows} rows")
print(f"pieces: every case consumed in {a.piece or 'whole'}-row pieces")


def errors(got, want):
Expand Down Expand Up @@ -167,26 +187,31 @@ def cmd_compare(a):
pooled[t]["bf16"].append(e_r)
names_of = {v: k for k, v in TYPES.items()}
table, ok = [], True
print("| type | logits | native mean | native worst | reference BF16 mean | reference BF16 worst | pass |")
print("|---|---|---|---|---|---|---|")
margin = MEAN_MARGIN if a.rule == "margin" else 1.0
print("| type | logits | native mean | native worst | reference BF16 mean | reference BF16 worst | strict | margin |")
print("|---|---|---|---|---|---|---|---|")
for t, p in pooled.items():
if not p["native"]:
continue
n, r = np.array(p["native"]), np.array(p["bf16"])
row = {"type": names_of[t], "logits": int(n.size), "native_mean": float(n.mean()), "native_worst": float(n.max()),
"bf16_mean": float(r.mean()), "bf16_worst": float(r.max())}
row["pass"] = row["native_mean"] <= row["bf16_mean"] and row["native_worst"] <= row["bf16_worst"]
worst_ok = row["native_worst"] <= row["bf16_worst"]
row["strict"] = row["native_mean"] <= row["bf16_mean"] and worst_ok
row["margin"] = row["native_mean"] <= MEAN_MARGIN * row["bf16_mean"] and worst_ok
row["pass"] = row["native_mean"] <= margin * row["bf16_mean"] and worst_ok
ok &= row["pass"]
table.append(row)
print(f"| {row['type']} | {row['logits']} | {row['native_mean']:.3e} | {row['native_worst']:.3e} | "
f"{row['bf16_mean']:.3e} | {row['bf16_worst']:.3e} | {'yes' if row['pass'] else 'NO'} |")
f"{row['bf16_mean']:.3e} | {row['bf16_worst']:.3e} | {'yes' if row['strict'] else 'NO'} | "
f"{'yes' if row['margin'] else 'NO'} |")
total = sum(len(p["native"]) for p in pooled.values())
print(f"paired: {total} logits, {same} identical to the reference BF16 head's; of the rest native is nearer FP64 in "
f"{nearer}, farther in {farther}, as near in {total - same - nearer - farther}")
if a.report:
paired = {"logits": total, "identical": same, "native_nearer": nearer, "native_farther": farther}
Path(a.report).write_text(json.dumps({"sources": SOURCES, "types": table, "paired": paired, "pass": ok}, indent=1))
print("PASS gate 3" if ok else "FAIL gate 3")
Path(a.report).write_text(json.dumps({"sources": SOURCES, "rule": a.rule, "types": table, "paired": paired, "pass": ok}, indent=1))
print(f"PASS gate 3 ({a.rule} rule)" if ok else f"FAIL gate 3 ({a.rule} rule)")
return 0 if ok else 1


Expand All @@ -205,10 +230,12 @@ def main():
for x in ("binary", "model", "cases", "out"):
n.add_argument(x)
n.add_argument("--piece")
n.add_argument("--backend", choices=["hip", "cuda"], default="hip")
m = sub.add_parser("compare")
for x in ("cases", "native", "bf16", "fp64"):
m.add_argument(x)
m.add_argument("--report")
m.add_argument("--rule", choices=["strict", "margin"], default="strict")
a = p.parse_args()
return {"cases": cmd_cases, "reference": cmd_reference, "native": cmd_native, "compare": cmd_compare}[a.cmd](a) or 0

Expand Down
Loading
Loading