Skip to content

qwen35: dense BF16 loading and native prompt logprobs - #2020

Open
akol1 wants to merge 41 commits into
ashhart:mainfrom
akol1:codex/qwen35-bf16-after-gdn
Open

akol1 wants to merge 41 commits into
ashhart:mainfrom
akol1:codex/qwen35-bf16-after-gdn

Conversation

@akol1

@akol1 akol1 commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

Adds an experimental dense BF16 Qwen3.5 format with native nonstreamed /v1/completions prompt_logprobs through the existing CUDA lanes. Stored FP32 GDN parameters stay FP32; scoring uses BF16 inputs, FP32 head sums/output and full-vocabulary normalization. Existing formats retain their generation/scoring admission. The review follow-up adds finite, opt-in observation of the production prompt body for diagnosis; no numerical tolerance or kernel arithmetic changes.

Checks on this head

  • Head commit: 47dd8cadc6f09ece60dd72613630c839b44bfe21. Measured native/capture source is 9416f0cf94bddbea49becb4c14047d0c16d08faf. After the later main/parent integration, the complete Qwen CUDA family and all CUDA kernel sources remain byte-identical to that producer. New upstream load/cache/stage changes are covered by the refreshed host checks; no device execution is relabeled. Transformers capture source is b54d8ff7691385fe420399e72272c932a881e29e; the source and binary identities in the assets are not relabeled.
  • Lean checker on main and final head, with the same checker: 425 inherited / 425 candidate / zero new findings. zig fmt --check build.zig zig and git diff --check pass. The registry stays within 600 lines by registering the receipt test through the existing bounded test module.
  • macOS: zig build test test-kernel-contract test-golden fuzz-cortheon dev-tools --test-timeout 10m -j8 --summary all, 917/917 steps, 7417/7487 executed tests passed, 70 skipped, other results cached, exit 0, on this refreshed integration head.
  • Linux: zig build test test-kernel-contract test-golden fuzz-cortheon -j8 --summary all, 599/599 steps, 7396/7455 executed passed, 59 skipped, other results cached, exit 0, on b54d8ff7. Native/capture and plain builds at 9416f0cf pass; plain is 30/30 steps.
  • python3 -m unittest discover -s tools/zig -p 'test_qwen35*.py' -v: 20/20 passed with the pinned reference dependencies; 17 passed / 3 skipped without the optional ML dependencies. The complete source fixes a superseded partial-export setup failure, retained in the packet.
  • The trace control is red when the callback implementation is removed and 1/1 passes when restored. The scoped BF16 suite passes 19/19. Comparison controls enforce a nonzero CLI exit for planted drift, reject incomplete/nonfinite captures and keep an unscored-final-row difference separate from the primary served-row verdict.
  • CI on this exact head: format and No GPU were cancelled by the maintainer while queued, at 09:34/09:35 UTC. GitHub check annotations identify the cancellation actor; no newer head or replacement runs exist. This is a maintainer-controlled cancellation, not a passing check or a demonstrated code failure. An approved CI path requires maintainer direction; no cancellation is overridden.
  • Not run: a complete CUDA device-suite rerun after the rebase, other physical chips/backends, multiple ranks and optional grammar/tool paths. The review follow-up changes observation/parser integration, not GPU arithmetic. The earlier complete CUDA execution retains its actual producer below; compilation/resource inspection does not qualify another device.

Receipt

The refreshed host log and exact source/overlap checks are attached in the integration supplement. The original 217-file device/reference packet remains unchanged.

Layer diagnostic and reproduction, compact result, archive hashes, immutable evidence.

  • Environment: one RTX PRO 6000 Blackwell Max-Q workstation GPU, sm_120/rank 1, 96 GB class; Linux x86_64, Ryzen 9 9950X3D, 128 GB RAM class; Zig 0.17.0, NVCC 13.0.88, ReleaseFast. Public Qwen/Qwen3.5-27B, revision fc05daec18b0a78c049392ed2e771dde82bdf654; all 11 actual shard hashes/sizes match pinned public LFS after capture. CPU reference: Python 3.12.3, Torch 2.15.0+cu132, Transformers 5.22.1, accelerate 1.15.0, safetensors 0.8.0, NumPy 2.5.4, eager attention, CUDA disabled. Both arms preserve all 96 stored FP32 parameters. Promoted FP32 uses the stored BF16 checkpoint values, not a separate FP32 training checkpoint.
  • Paths/platforms: the diagnostic uses the production CUDA prompt forward. Its trace defaults off and has no serving configuration. Native capture has no CPU/RAM cgroup limit; the CPU reference has 16 CPUs/96 GiB. This synchronized capture is not a four-CPU/32-GiB latency benchmark. Original running deployments and active-service health were restored. Other physical chips/backends and multiple ranks are unqualified; offered GB10 cells remain with the maintainer.
  • Exactness: traced versus fresh-cache untraced final BF16 logits match. Transformers BF16 final hidden rows equal its public library entry point; promoted-FP32 layers 0, 3 and 63 equal independently cloned FP32 layers. The earlier 32/32 API, drafted/plain, concurrent/solo, retained/fresh and cancellation checks are retained at their actual serving producer b168b36d, not claimed as new executions on this head.
  • Decode speed before/after: no new performance run in this diagnostic follow-up. Historical measurements at b168b36d remain fully linked: native/SGLang C4 aggregate decode is about 9/109.5 tokens/s. Performance remains unqualified.
  • Prompt speed before/after: no new timing claim from synchronized layer capture. Historical cold 64k TTFT is 1601.814 s native / 24.608 s SGLang. The original serving quota was four CPUs/32 GiB, distinct from this diagnostic. Complete warm/cold, sampled, concurrency, memory and cache constraints remain in the serving receipt.
  • Licence of new weights/drafter: n/a; no new checkpoint or drafter is supplied. References use the pinned public checkpoint.

Requested layer comparison

The exact 32-token public fixture has 31 hidden rows used by served prompt scores. The last input row is retained in a separate all-32-row view. At each boundary the rule is max |native − FP32| <= max |Transformers BF16 − FP32|, with no added allowance.

The first excess is zero-based layer 0, the first linear-attention block. Embeddings match exactly. Layer 0's worst coordinate is input row 21, hidden column 3994: native 15.5625, FP32 15.63897705078125, BF16 reference 15.625.

Boundary Worst native−FP32 Worst BF16−FP32 Within own maximum
Embedding 0 0 passed
Layer 0 residual 0.07647705078125 0.056326866149902344 failed
Layer 1 residual 0.09848594665527344 0.09848594665527344 passed
Layer 2 residual 0.19491863250732422 0.1948375701904297 failed
Layer 3 residual 0.199066162109375 0.188201904296875 failed
Layer 63 residual 4.7076416015625 7.054046630859375 passed
Final normalization 0.31170082092285156 0.4594573974609375 passed

The rule fails at 18/64 residual layers. Both row scopes find the same first layer. All 66 boundaries, maxima/medians/RMS, worst coordinates and 198 unchanged tensor arrays are external. Later boundaries returning inside their maximum do not waive the separately failed served-logprob rule. This locates observed drift in the first block; it does not establish an isolated accumulation bug or an unavoidable format floor.

The earlier direct HTTP comparison remains failed at all four prompt lengths, over all 4511 scored positions, including the 4097-ID seam, in both reference arms. At 32 IDs, worst/median native−FP32 logprob distance is 0.0415096283 / 0.004390716553, against own BF16−FP32 worst 0.02388763428. Same-weight FP64 checks still cover the head on native rows, not the whole body. No broader hidden-state bound replaces these failures.

The 217-file supplement includes full build/capture/audit logs, exact IDs, numerical failures and actual source/binary identities. Archive/member checksums and normalized header identities are recorded; all three public downloads were rehashed successfully. Source, outgoing history, JSON metadata and the complete packet were reviewed for private identifiers/credentials, with zero findings; approved public contributor aliases/noreply credit remain.

Kernel contract and historical producer

The BF16 copy/dense/FP32 scoring and FP32-scale RMS operators remain registered with their planted controls; no numerical tolerance or known exemption is added. The CPU five-SM audit at native producer 9416f0cf passes, with no stale records or applicable launch failures, and every planted launch control red. This inspects compiled resources; it is not five physical-device runs.

The complete historical sm_120 command at b168b36d0cc3503ae69e8bffcad494574019caf5, unchanged in the existing asset, is:

SUMMARY 559 kernels: 559 pass gates 1-4, 0 fail, 6 known findings; 367 controls: 367 red as planted, 0 missed; 0 limit problems; gates 4023784 ms, limits 760889 ms
exit: 0

The same six declared NaN findings remain; no new known entry is added. A complete device-suite rerun on the rebased head is not run, and this historical SUMMARY is not relabeled. Other CUDA chips, Metal/HIP and multiple ranks are unqualified. GB10 execution remains with the maintainer.

Checklist

  • Title, description, receipt and stack match the published head and distinguish actual execution producers.
  • Negative controls fail as planted, restored implementations pass, and optional ML dependencies skip cleanly.
  • Source modules are bounded, comments/docstrings remain one line, and there are zero new lean findings.
  • Source, outgoing commits and evidence contain no private identifiers or credentials; approved public attribution remains, with no AI trailers.
  • Serving stays on native lanes; the finite diagnostic adds no serial serving path or draft-disable setting.
  • No precision or tolerance is traded for speed; independent numerical failures are disclosed.
  • New-head full token/lifecycle and performance qualification: historical results are retained; no new claim from the diagnostic.
  • Final-head hosted pass: runs were maintainer-cancelled; awaiting maintainer direction.
  • Maintainer landing decision, parent cleanup after landing and offered GB10 execution.

@akol1

akol1 commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Qualification update on 91197649ca24d2234f9cde2ff8e6e68b7a09b730: the public API/FP64 reports and exact fixtures are now committed under docs/receipts/qwen35-bf16-scoring/. The complete strict CUDA contract is still running; this remains a draft.

Hosted format passed. The No GPU run was cancelled before completion, as was the previous head's run. There has been no subsequent push to supersede this head. The macOS zig build dev-tools step completed successfully, but that does not establish a complete hosted pass. The unprivileged Linux host suite passed locally, with the counts retained in the PR description.

Could a maintainer confirm whether the repeated cancellation is intentional and how to obtain the remaining hosted checks? I have not changed workflow policy or repeatedly retried cancelled runs. The outstanding checks remain explicitly unchecked.

@akol1

akol1 commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

The complete strict CUDA run is now retained in the receipt, including its full text output and binary identity:

SUMMARY 550 kernels: 550 pass gates 1-4, 0 fail, 6 known findings; 365 controls: 365 red as planted, 0 missed; 342 limit problems; gates 4013421 ms, limits 726300 ms
exit: 1

The numerical gates and every planted control passed their intended checks; six existing NaN findings reproduce. All four new function records pass live sm_120 checks, and all 20 new function/SM records are current in the five-SM asset audit.

The remaining failure is 188 registry problems plus 154 live record/device mismatches. The separate parent/candidate five-SM audits both exit 1 with 637 problems and identical diagnostic multisets; the comparison retains those diagnostics. The parent's full/live-only run was not run, so this is not presented as a matching parent live SUMMARY or a clean qualification.

Could the maintainer advise the appropriate catalog-resolution scope for these existing records? The PR stays draft. Native serving measurements have resumed, with performance, lifecycle, cold-prefill and existing-format receipts still pending.

@ashhart

ashhart commented Nov 3, 2026

Copy link
Copy Markdown
Owner

Thank you, @akol1. This is careful work: the dense BF16 path keeps every existing checkpoint on main's code, the
prompt scores have their own FP32 head with planted controls, and your callback-lifetime fix in commit 8 found a real
bug in the base we stacked under you. We'll take that fix into #1762 with credit. Three requests before this can land.
First, please drop the four base commits once #1762 is in, and keep only the summary receipts here, moving the
per-request dumps and the full contract log to a linked asset with their checksums. Second, the FP64 check covers the
score head on the engine's own rows; could you add a comparison of the served prompt logprobs against a transformers
forward of the pinned checkpoint, bounded by transformers' own BF16 distance from FP32? Third, a small wording change
in the recipe's line about the GPU lock, and a fuller message on the main commit. We'll run the GB10 cells on our side.

@ashhart

ashhart commented Nov 3, 2026

Copy link
Copy Markdown
Owner

Your callback fix (d8f5efbc93) is now on #2008 under your name (789846adb), so it lands with the base. You can drop it from this branch when you rebase.

akol1 added a commit to akol1/TensorFold that referenced this pull request Nov 4, 2026
Load the dense Qwen3.5-27B checkpoint from its stored BF16 safetensors and
serve per-token prompt logprobs from the rows the prompt path scores. Dense
attention and MoE projections keep the checkpoint's BF16 weights and
activations; FP32 sums and the stored GDN scales are unchanged, and no
tolerance moves.

Score the served rows locally: `prompt_logprobs` follows `/v1/completions`,
`top` accepts 0/1/20, the first entry stays null, and an unknown `top` or an
input id at the vocabulary sentinel is a 400. The head accumulates in FP32 and
takes its logsumexp over the full vocabulary.

Add an independent FP32 head over the same captured BF16 normalized rows, with
its own build, a FP64 dot/logsumexp tool and planted controls, so a score can
be checked without trusting the production head. Register the new
function/SM and record identities with byte replacements; existing
declarations and tolerances stay as they are.

The CUDA contract still fails 342 launch limits, so this is qualification
input, not a passed contract. Refs ashhart#1762, ashhart#2020.
akol1 added a commit to akol1/TensorFold that referenced this pull request Nov 4, 2026
…erence

The receipt tree carried 3.26 MB of per-request dumps and the complete CUDA
contract log beside the summaries. Remove the per-request dumps, the two
per-request concurrency bodies and the cold replay bodies; asset.json pins the
sha256 and byte count of every removed file, and of the transformers payload and
run log kept out of the tree with them, so the tracked receipts stay auditable
against what was removed. The removed files themselves stay with the author and
are not published.

Add tools/zig/qwen35_transformers_reference.py, which runs the pinned checkpoint
on CPU in two arms, stored BF16 and every decoder layer's stored parameters and
buffers promoted to FP32, and transformers-comparison.json, which compares the
served prompt scores against that forward and adds the tables to the receipt.
The transformers arm's own BF16-to-FP32 distance bounds the comparison: 18/18
rows stay inside their bound, the worst tracked native-to-transformers difference
is 0.830 on one prompt row at position 255, the other 17 rows are at or under
0.018, and 408/415 argmax rows agree. The BF16 arm's hidden states are bitwise
equal to a plain library forward, and extending a prompt by the served
continuation tokens leaves the prompt rows bitwise unchanged.

Also name the existing GPU lock and admission guard, with one model process per
test machine, in the recipe's serving line, and re-pin the commit ids the topic
rewrite changed in the required checksum records.

Refs ashhart#1762, ashhart#2020.
@akol1
akol1 force-pushed the codex/qwen35-bf16-after-gdn branch from b651e8b to adfe474 Compare November 4, 2026 02:42
akol1 added a commit to akol1/TensorFold that referenced this pull request Nov 4, 2026
Load the dense Qwen3.5-27B checkpoint from its stored BF16 safetensors and
serve per-token prompt logprobs from the rows the prompt path scores. Dense
attention and MoE projections keep the checkpoint's BF16 weights and
activations; FP32 sums and the stored GDN scales are unchanged, and no
tolerance moves.

Score the served rows locally: `prompt_logprobs` follows `/v1/completions`,
`top` accepts 0/1/20, the first entry stays null, and an unknown `top` or an
input id at the vocabulary sentinel is a 400. The head accumulates in FP32 and
takes its logsumexp over the full vocabulary.

Add an independent FP32 head over the same captured BF16 normalized rows, with
its own build, a FP64 dot/logsumexp tool and planted controls, so a score can
be checked without trusting the production head. Register the new
function/SM and record identities with byte replacements; existing
declarations and tolerances stay as they are.

The CUDA contract still fails 342 launch limits, so this is qualification
input, not a passed contract. Refs ashhart#1762, ashhart#2020.
akol1 added a commit to akol1/TensorFold that referenced this pull request Nov 4, 2026
…erence

The receipt tree carried 3.26 MB of per-request dumps and the complete CUDA
contract log beside the summaries. Remove the per-request dumps, the two
per-request concurrency bodies and the cold replay bodies; asset.json pins the
sha256 and byte count of every removed file, and of the transformers payload and
run log kept out of the tree with them, so the tracked receipts stay auditable
against what was removed. The removed files themselves stay with the author and
are not published.

Add tools/zig/qwen35_transformers_reference.py, which runs the pinned checkpoint
on CPU in two arms, stored BF16 and every decoder layer's stored parameters and
buffers promoted to FP32, and transformers-comparison.json, which compares the
served prompt scores against that forward and adds the tables to the receipt.
The transformers arm's own BF16-to-FP32 distance bounds the comparison: 18/18
rows stay inside their bound, the worst tracked native-to-transformers difference
is 0.830 on one prompt row at position 255, the other 17 rows are at or under
0.018, and 408/415 argmax rows agree. The BF16 arm's hidden states are bitwise
equal to a plain library forward, and extending a prompt by the served
continuation tokens leaves the prompt rows bitwise unchanged.

Also name the existing GPU lock and admission guard, with one model process per
test machine, in the recipe's serving line, and re-pin the commit ids the topic
rewrite changed in the required checksum records.

Refs ashhart#1762, ashhart#2020.
@akol1
akol1 force-pushed the codex/qwen35-bf16-after-gdn branch 2 times, most recently from d397c8c to 54f9459 Compare November 4, 2026 02:57
akol1 added a commit to akol1/TensorFold that referenced this pull request Nov 4, 2026
Load the dense Qwen3.5-27B checkpoint from its stored BF16 safetensors and
serve per-token prompt logprobs from the rows the prompt path scores. Dense
attention and MoE projections keep the checkpoint's BF16 weights and
activations; FP32 sums and the stored GDN scales are unchanged, and no
tolerance moves.

Score the served rows locally: `prompt_logprobs` follows `/v1/completions`,
`top` accepts 0/1/20, the first entry stays null, and an unknown `top` or an
input id at the vocabulary sentinel is a 400. The head accumulates in FP32 and
takes its logsumexp over the full vocabulary.

Add an independent FP32 head over the same captured BF16 normalized rows, with
its own build, a FP64 dot/logsumexp tool and planted controls, so a score can
be checked without trusting the production head. Register the new
function/SM and record identities with byte replacements; existing
declarations and tolerances stay as they are.

The CUDA contract still fails 342 launch limits, so this is qualification
input, not a passed contract. Refs ashhart#1762, ashhart#2020.
akol1 added a commit to akol1/TensorFold that referenced this pull request Nov 4, 2026
…erence

The receipt tree carried 3.26 MB of per-request dumps and the complete CUDA
contract log beside the summaries. Remove the per-request dumps, the two
per-request concurrency bodies and the cold replay bodies; asset.json pins the
sha256 and byte count of every removed file, and of the transformers payload and
run log kept out of the tree with them, so the tracked receipts stay auditable
against what was removed. The removed files themselves stay with the author and
are not published.

Add tools/zig/qwen35_transformers_reference.py, which runs the pinned checkpoint
on CPU in two arms, stored BF16 and every decoder layer's stored parameters and
buffers promoted to FP32, and transformers-comparison.json, which compares the
served prompt scores against that forward and adds the tables to the receipt.
The transformers arm's own BF16-to-FP32 distance bounds the comparison: 18/18
rows stay inside their bound, the worst tracked native-to-transformers difference
is 0.830 on one prompt row at position 255, the other 17 rows are at or under
0.018, and 408/415 argmax rows agree. The BF16 arm's hidden states are bitwise
equal to a plain library forward, and extending a prompt by the served
continuation tokens leaves the prompt rows bitwise unchanged.

Also name the existing GPU lock and admission guard, with one model process per
test machine, in the recipe's serving line, and re-pin the commit ids the topic
rewrite changed in the required checksum records.

Refs ashhart#1762, ashhart#2020.
@akol1

akol1 commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Rebased and reworked — head is now 54f945941 (13 commits: the four base commits still carried under this branch while #1762/#2008 are open, plus our nine). Our callback fix is gone from here: it landed on #2008 as 789846adb, so it travels with the base, as you said. Every receipt that cited a build commit now cites the rebased id (manifest.source_commit, inference_build_commit, stack_parent, host-and-ci, limits-comparison, exl3-admission), and the tree is the same content as before the rebase.

Receipts: the per-request dumps and the full contract log are out of the tree. README.md keeps summaries only; asset.json pins the sha256 and byte count of each removed file, the dumps tarball's 21 members, and the exact command lines. I have not published them — no release, no upload — because those captures came from a private machine and the author asked to keep them private. The checksums are in the tree so a later publication, if authorized, is verifiable; nothing else about them is claimed.

Transformers comparison (transformers-comparison.json, tracked; script tools/zig/qwen35_transformers_reference.py, pinned revision fc05daec18b0a78c049392ed2e771dde82bdf654): a CPU-only transformers forward of the pinned checkpoint, attn_implementation: eager, compared against the served prompt logprobs. The sweep runs the forward twice, BF16 and FP32, so the BF16 arm's own distance from FP32 is measured rather than assumed. On fixture 3 that distance is up to |Δlogprob| 4.035 (pos 216; mean 0.061, 408/415 argmax and 388/415 rank agreement); fixtures 1 and 2 stay ≤0.0577. Served scores sit inside that envelope on all 18 captured rows (15 metas: prompt and decode, plus repeats): the largest |served − BF16 arm| is 0.830 on one prompt row (fixture 3, pos 255) and the other 17 rows are ≤0.0179. So the scores match the pinned checkpoint's own forward within the distance that forward's BF16 arithmetic shows from FP32, and the comparison records the bound per row, not a single global tolerance.

Wording: the recipe line now reads "Use the existing GPU lock and admission guard, with one model process per test machine", matching docs/recipes/SKILL.md. The main commit message now spells out the FP32 head arithmetic, the independent FP32 head and FP64 tool, the identity byte-replacements, and the 342 known launch-limit findings as qualification input rather than a passed contract.

The four base commits stay only until the base lands; once #1762/#2008 are in I drop them and keep the nine. CI is queued on the new head; I'll report anything that goes red. Refs #1762.

@akol1

akol1 commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Follow-up on 07034aa264af49baa0e21d3953f20f4590809a5b:

  • The three evidence files are now linked immutably with hashes outside the source branch. All 21 archive members and both additional payloads were reviewed for identifying metadata/secrets; their published bytes match the recorded SHA-256s.
  • The earlier reference status overstated acceptance. The broader hidden-distance diagnostic passes, but the measured BF16-distance comparison does not: three captured rows fail against the FP32 reference (fixture 3 positions 255/256/260); one fails against the alternate BF16-reference envelope (position 256). The existing head-rounding allowance is retained. These are captured native rows, not yet a direct served HTTP prompt-score comparison. The 4097-token fixture has no FP32 arm. Counterexamples stay failed; no hidden-distance term is used to waive them.
  • Split the 1729-line finite reference into bounded modules, preserving all 32 non-CLI executable ASTs. CPU head bytes and FP64 profiles match. Seven verdict/privacy tests pass on Python 3.11/3.14 and Linux 3.12; lean 473→430, zero new. Forward qualification now exits nonzero on the failed envelope; future JSON exports scrub runner identifiers/paths.
  • Restored original tested commit/binary/CI identities in historical receipts. Rebased IDs are ancestry mappings, not new executions. The PR body now matches this head and its outstanding gates.

#2008 remains open, so the four inherited base commits stay pending its landing; this follow-up does not touch native conflict paths or force-push history. Recipe lock wording and the fuller main commit message are retained. Native fidelity, catalog/performance acceptance and post-base qualification remain outstanding; GB10 cells remain with the maintainer as offered.

Before changing native arithmetic, please confirm whether the intended acceptance is error relative to the Transformers FP32 arm bounded by its BF16 error, or distance directly to its BF16 arm. Both failing directions are reported explicitly. The previous broadened bound is not presented as satisfying either request.

@akol1

akol1 commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Readiness work is proceeding on the reconciled candidate 2475f27c (native build source 7308aa0c). Ordinary merges include current main 785da95d and the declared #2008 dependency 789846adb, including the credited callback fix. The image-list conflict retains both gdn_prefill and main's nvfp4_experts32. No history is force-pushed; inherited dependency history remains until the parent lands.

The final release-compiler build, complete host checks and full pinned Transformers reference (including the previously missing 4097-token FP32 arm) are running. A finite client now collects actual HTTP prompt scores against both reference arms with exact per-position/token coverage and zero-cache checks.

Gate scope is the original agreement: same-weight FP64 prompt/decode worst-row/token evidence, the reduction/control, server integration and unchanged existing formats. As that agreement states, the other-engine tolerance need not pass. We will keep both measured distance directions visible and will not use the broader hidden-distance diagnostic as a substitute. The earlier blanket “fidelity fixes required” status overstated the agreed gate; the missing direct served comparison and 4097-token reference coverage are being completed.

ATC overlap coverage is incomplete (pullFilesLimit). Two concrete remaining overlaps are #2086 (qwen3_5/cuda_geometry.zig, layer-pattern parsing beside the new BF16 format field) and #2011 (qwen3_5/cuda_prompt.zig, paging beside the BF16-only unfused FP32-scale post). Their landing order needs coordination: keep each PR's parsing/paging behavior and this format's FP32 GDN-scale guard. Existing shared contract-record overlaps remain disclosed. This does not claim conflict-free integration with every open branch or take over either PR's work.

@akol1
akol1 force-pushed the codex/qwen35-bf16-after-gdn branch from b168b36 to 55dbec4 Compare November 4, 2026 07:12
akol1 added a commit to akol1/TensorFold that referenced this pull request Nov 4, 2026
Load the dense Qwen3.5-27B checkpoint from its stored BF16 safetensors and
serve per-token prompt logprobs from the rows the prompt path scores. Dense
attention and MoE projections keep the checkpoint's BF16 weights and
activations; FP32 sums and the stored GDN scales are unchanged, and no
tolerance moves.

Score the served rows locally: `prompt_logprobs` follows `/v1/completions`,
`top` accepts 0/1/20, the first entry stays null, and an unknown `top` or an
input id at the vocabulary sentinel is a 400. The head accumulates in FP32 and
takes its logsumexp over the full vocabulary.

Add an independent FP32 head over the same captured BF16 normalized rows, with
its own build, a FP64 dot/logsumexp tool and planted controls, so a score can
be checked without trusting the production head. Register the new
function/SM and record identities with byte replacements; existing
declarations and tolerances stay as they are.

The CUDA contract still fails 342 launch limits, so this is qualification
input, not a passed contract. Refs ashhart#1762, ashhart#2020.
akol1 added a commit to akol1/TensorFold that referenced this pull request Nov 4, 2026
…erence

The receipt tree carried 3.26 MB of per-request dumps and the complete CUDA
contract log beside the summaries. Remove the per-request dumps, the two
per-request concurrency bodies and the cold replay bodies; asset.json pins the
sha256 and byte count of every removed file, and of the transformers payload and
run log kept out of the tree with them, so the tracked receipts stay auditable
against what was removed. The removed files themselves stay with the author and
are not published.

Add tools/zig/qwen35_transformers_reference.py, which runs the pinned checkpoint
on CPU in two arms, stored BF16 and every decoder layer's stored parameters and
buffers promoted to FP32, and transformers-comparison.json, which compares the
served prompt scores against that forward and adds the tables to the receipt.
The transformers arm's own BF16-to-FP32 distance bounds the comparison: 18/18
rows stay inside their bound, the worst tracked native-to-transformers difference
is 0.830 on one prompt row at position 255, the other 17 rows are at or under
0.018, and 408/415 argmax rows agree. The BF16 arm's hidden states are bitwise
equal to a plain library forward, and extending a prompt by the served
continuation tokens leaves the prompt rows bitwise unchanged.

Also name the existing GPU lock and admission guard, with one model process per
test machine, in the recipe's serving line, and re-pin the commit ids the topic
rewrite changed in the required checksum records.

Refs ashhart#1762, ashhart#2020.
@ashhart

ashhart commented Nov 4, 2026

Copy link
Copy Markdown
Owner

Thanks @akol1. The rebase is clean on our side: outside the receipts, the code is line for line what we reviewed, so every existing format still takes main's path. Your MLX 4-bit and NVFP4 runs, 20 of 20 token hashes equal, back that. The receipt tree is down from 52,508 lines to 9,250. We checked the 21 kept-out files' hashes in asset.json against the copies we reviewed last round, and all 21 match. The recipe wording matches our own contributor guide, which is fine.

Two things are left:

  1. The transformers comparison. Running both a BF16 and an FP32 forward was the right way to measure the
    distance, and judged per length the served scores sit inside it (worst 0.0046 at 32 tokens, 0.0001 at 129 and
    2.38 at 257). But it compares only 18 captured rows, six of them prompt rows, and nothing at 4,097 tokens, where
    the FP32 arm was skipped. That's the fixture that crosses the chunk seam, so it matters most. The served
    prompt_logprobs in your API responses already hold every row. Could you compare all of them against both arms
    (415 rows across 32, 129 and 257, plus the 4,097 fixture) and report the worst and median |served − FP32| per
    length, next to that length's own BF16-vs-FP32 worst? If the FP32 forward at 4,097 is too heavy on CPU, the last
    few hundred rows of that fixture would do. We'd rather use that simple per-length rule than the bound with the
    hidden-distance terms, which grows with exactly the drift we want to see.
  2. The lean check. On our main, tools/zig/qwen35_transformers_reference.py adds 47 problems: it's 1,729 lines,
    over the 600-line limit, with 37 multi-line comments and 9 multi-line docstrings. Please split it into modules of
    600 lines or fewer, with one-line comments.

When this lands, we'll squash the receipt commits, so the full contract text and dumps added and then removed in this series don't stay in history. The four base commits come out once #1762 and #2008 are in, as you said. The 342-problem limit catalog is ours to clear, and we'll run the GB10 cells on our side.

@akol1
akol1 marked this pull request as ready for review November 4, 2026 11:09
@akol1

akol1 commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Completed on 8f1202644cfadf12c70bfcdca42e28051b69d10c, ready for review as an experimental functional text/scoring format.

  • The complete CUDA command exits 0: 559 kernels pass, 367/367 controls red, zero gate/launch-limit failures, with the same six declared known findings. The final-head format and all six No GPU jobs pass. Device executions retain source b168b36d; equivalent parent receipt tables, host-only tests, the optional reference dependency guard and condensed docs are identified separately.
  • Per-request/capture results and complete logs are now in immutable evidence assets, with archive and member checksums. The 387-file current payload and all 53 original source-tree receipts were reviewed; the three earlier assets remain unchanged. The packet and the per-length supplement downloads match their recorded hashes. The actual BF16 shard hashes/sizes match the pinned public Qwen LFS manifest before and after serving. Submitted text/metadata/history contain no private infrastructure identifiers or credentials; approved public aliases/noreply credit remain.
  • The requested actual HTTP prompt-logprob comparison is complete at all 4511 scored positions, including the 4097-ID seam, in both Transformers BF16/promoted-FP32 arms. All 96 stored FP32 parameters are restored and byte-verified. Strict measured-distance checks fail: 1719 positions in the FP32-reference direction and 1911 in the BF16-reference direction. Those counterexamples remain in the asset; no wider hidden-state bound substitutes for them. This supersedes the earlier captured-row acceptance statement. The agreed issue gate separates this diagnostic from the passing same-weight FP64 checks. Model equivalence and performance qualification remain unclaimed; slow BF16 prefill/concurrency and all sampled/negative cells are disclosed.
  • The former 1729-line reference entry point is now 266 lines; its compare/forward/inputs/fixture modules are 375/396/380/281 lines, with one-line comments/docstrings. Final-head Linux CI's lean check passes, and the same-checker comparison is 425 baseline/425 candidate/zero new findings. The recipe's GPU-lock wording matches the contributor skill, and the fuller main-commit message is preserved. CUDA: #1764's BF16 prompt tile for Qwen ModelOpt, Nemotron and Dory, plus two exact Qwen prompt kernels (#1762) #2008 is still open at 30e9b872; the credited callback fix travels with that parent. Parent-stack cleanup/rebase remains conditional on landing, and the offered GB10 cells remain with the maintainer. The latest ATC scan is incomplete (pullFilesUnavailable, timeLimit) and reports conflicts with qwen CUDA: a faster opt-in paged path (TF_QWEN_KV_PAGES=256), --parallel a cap with pages set #2011 and glm cuda: EXL3 mcg experts at any whole-bit width, mixed by projection #2094; the description identifies the FP32-scale guard, registry sets and per-compiler records to preserve at integration.

The source receipt keeps summaries and reproduction inputs. Unrun physical chips/backends, multiple ranks and optional paths remain explicit.

The maintainer-requested simple per-length report uses every scored position, with no hidden-distance term or extra allowance:

Prompt IDs Scored rows Worst |served - FP32| Median |served - FP32| Same-length worst |BF16 - FP32| Worst within own BF16 distance
32 31 0.0415096283 0.004390716553 0.02388763428 failed
129 128 0.04362297058 3.433227539e-05 0.0426158905 failed
257 256 5.546443939 0.001540184021 5.224838257 failed
4097 4096 0.04362297058 1.907348633e-06 0.0426158905 failed

The simple length-level rule fails at all four lengths. Median uses statistics.median over all rows of that length. This covers the 415 smaller-fixture positions plus all 4096 scored positions of the 4097-ID seam. The full-precision derived report and reproduction script pin the published input member SHA-256. The stricter row-level counts above remain separate diagnostics.

@ashhart

ashhart commented Nov 4, 2026

Copy link
Copy Markdown
Owner

Thanks @akol1, for doing the full comparison and for reporting it straight: all 4,511 positions, the 4,097 seam included, both arms, no extra allowance. The reference script split is clean too, and lean is unchanged on our main.

The per-length rule fails at all four lengths. Most clearly at 32 tokens, where the worst served row is 0.0415 from FP32 against the BF16 arm's own 0.0239. At 129 and 4,097 the worst rows sit just above (0.0436 against 0.0426). Your FP64 check shows the head is exact on the rows it's given, so the drift comes from earlier in the BF16 body. Could you run a layer-by-layer comparison on the 32-token fixture against transformers FP32, to find the layer where the served rows first leave the BF16 arm's distance? That tells us whether it's one accumulation we can fix or the format's floor. We'll come back on whether it lands as an experimental format with those numbers stated.

One more thing: main's layer-pattern change now conflicts with the BF16 branch in cuda_geometry.zig's parse, so it needs a rebase. The GB10 cells are still ours.

@akol1

akol1 commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor Author

Completed the rebase and requested 32-token layer diagnostic on 47dd8cadc6f09ece60dd72613630c839b44bfe21.

The shared layer-pattern reader now runs before the BF16 return in cuda_geometry.zig::parse. The FP32-scale guard is preserved. Main 9200a306 and the original #2008 parent are ancestors; the refreshed parent's host-test placement is retained. GitHub reports this PR mergeable against main. Remaining partial-coverage ATC overlaps reproduce on main or main plus the parent.

The first observed excess is zero-based layer 0, the first linear-attention block. Embeddings match exactly. Across the 31 hidden rows actually used by served prompt scores, layer 0's worst native–FP32 distance is 0.07647705078125, versus the BF16 arm's own 0.056326866149902344. At the worst native coordinate (input row 21, hidden column 3994), native/FP32/BF16 values are 15.5625 / 15.63897705078125 / 15.625. The all-32-input-row view finds the same first layer. The maximum rule fails at 18/64 residual layers. Later boundaries returning inside their maximum do not waive the separately failed logprob rule.

This localizes observed drift to the first block; it does not establish one faulty accumulation or an unavoidable format floor. No tolerance or kernel arithmetic was changed. The existing four per-length failures remain stated.

The capture uses the production CUDA prompt forward and passes traced/fresh-cache-untraced logit identity. Transformers BF16 final hidden rows equal the public library entry point; promoted-FP32 layers 0, 3 and 63 equal independently cloned FP32 layers. All 96 stored FP32 parameters are preserved, and all 11 public checkpoint shard hashes match pinned LFS after capture.

Diagnostic/reproduction · compact result · immutable archives and member manifest. The 217-file packet contains all 66 boundaries, both row scopes and 198 unchanged arrays. All three public downloads match their recorded hashes. Private identifiers/credentials were excluded from source, outgoing history, logs, metadata and archive headers; approved public contributor attribution remains.

The refreshed macOS host/contract/golden/fuzz/developer-tool command passes 917/917 steps, 7417 passed and 70 skipped, with other results cached. The full Qwen CUDA family and all CUDA kernel sources are byte-identical to the actual native producer. Earlier Linux host checks retain their recorded producer. The plain build and CPU five-SM resource audit pass at 9416f0cf; the unchanged reference suite passes 20/20 with dependencies, and the current same-checker lean result is 425/425 with zero new findings. The final-head format and No GPU runs were maintainer-cancelled while queued, without a newer head or replacement run. GitHub annotations identify the cancelling actor. No hosted pass is claimed. Please confirm the intended CI path for this head; the cancelled runs have not been restarted. The full 559-kernel CUDA SUMMARY retains its original b168b36d producer; it is not relabeled as a rerun after rebasing.

The refreshed integration supplement records main 9200a306 and parent d19ff3f0, the complete host log and every detected overlap's inherited conflict-file proof. It adds no device or performance execution.

The parent's later f332655d only updates the GDN resource assertion; this branch already has that measured check plus a missing-receipt negative control. No production change is omitted from the pinned-parent integration.

The offered GB10 cells and experimental-format landing decision remain with the maintainer. Original running deployments and active-service health were restored.

akol1 and others added 28 commits November 23, 2026 18:17
…erence

The receipt tree carried 3.26 MB of per-request dumps and the complete CUDA
contract log beside the summaries. Remove the per-request dumps, the two
per-request concurrency bodies and the cold replay bodies; asset.json pins the
sha256 and byte count of every removed file, and of the transformers payload and
run log kept out of the tree with them, so the tracked receipts stay auditable
against what was removed. The removed files themselves stay with the author and
are not published.

Add tools/zig/qwen35_transformers_reference.py, which runs the pinned checkpoint
on CPU in two arms, stored BF16 and every decoder layer's stored parameters and
buffers promoted to FP32, and transformers-comparison.json, which compares the
served prompt scores against that forward and adds the tables to the receipt.
The transformers arm's own BF16-to-FP32 distance bounds the comparison: 18/18
rows stay inside their bound, the worst tracked native-to-transformers difference
is 0.830 on one prompt row at position 255, the other 17 rows are at or under
0.018, and 408/415 argmax rows agree. The BF16 arm's hidden states are bitwise
equal to a plain library forward, and extending a prompt by the served
continuation tokens leaves the prompt rows bitwise unchanged.

Also name the existing GPU lock and admission guard, with one model process per
test machine, in the recipe's serving line, and re-pin the commit ids the topic
rewrite changed in the required checksum records.

Refs ashhart#1762, ashhart#2020.
…dence

Keep the original measured source and CI identities after the history rewrite. Link the reviewed evidence assets outside the source branch with immutable hashes.

Split the finite Transformers reference into bounded modules without changing its numerical functions. Return failure for the measured BF16-distance counterexamples instead of treating a broader hidden-distance diagnostic as acceptance. Scrub identifying runner metadata in future JSON exports and retain seven verdict/privacy regressions.
Collect actual HTTP selected-token scores with exact row/token coverage and cache-off checks. Report both measured BF16-distance directions without replacing the agreed same-weight FP64 gate with an invented cross-engine threshold. Include the long-prompt FP32 arm and reject incomplete reference evidence.
Fill the four five-SM launch receipts from nvcc 13.0.88. Keep later
compiler records pending and test the real registry lookups and limits.
Restore the 96 FP32 GDN normalization and decay tensors that Transformers auto-dtype downcasts, and verify their original bytes before either precision arm. Keep repeated runs incomplete until they finish and exclude prose and request identifiers from HTTP evidence.

Repair two current-main verification prerequisites: reuse the unchanged canonical loads in the block-32 experts rather than adding primitive copies, and let the compiled-image limits command inspect files without initializing CUDA. No native Qwen arithmetic or precision is changed.
Keep the three stored-FP32 parameter checks active when torch and safetensors are installed. A host without those reference-only dependencies now reports three explicit skips instead of failing test discovery; missing transitive dependencies still fail.
Keep source-tree summaries and reproduction inputs, with immutable links and member checksums for complete serving, reference and CUDA evidence. Retain exact producer/binary identities, the failed strict cross-engine comparisons, historical attempts and performance limits. Record the full 559-kernel/367-control pass and zero launch-limit problems on sm_120, with six unchanged known findings; other hardware and production/performance qualification remain outside this experimental scope.
…ader cluster

The merge left the file at 606 lines, one over the lean gate's 600 against main;
the two control includes move up with the other headers and spare separators go,
so the planted moe-router and q35 score controls stay with no new lean problem.
@ashhart
ashhart force-pushed the codex/qwen35-bf16-after-gdn branch from 65784c2 to a9defd0 Compare November 23, 2026 18:19
@ashhart

ashhart commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Thanks @akol1, and thanks for your patience while this waited on our side.

What's confirmed on the current head:

  • The BF16 refusal holds. A plain BF16 Qwen3.5 checkpoint is still refused for chat on CUDA before your BF16 admission (zig/src/families/qwen3_5/cuda_native.zig:157), as we asked, and your test expects it.
  • Main is merged in. Both changes we named on 18 Nov are now in the branch: the FP32 1 + w norm scaling and BF16 image chat on CUDA.
  • No copied code. The reference tools drive Transformers' own modules as the reference.

Still needed from you: the layer-0 split. The receipts still stop at whole-layer residuals (docs/receipts/qwen35-bf16-scoring/layer-diagnostic.md). On the same 32-token fixture, on this head, how do the convolution, the gates, the recurrence and the output norm inside layer 0 each compare with FP32? That tells us whether the drift is one accumulation we can fix or the format's floor.

Ours, nothing needed from you:

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants