Skip to content

gpu: the GDN prompt delta seeds only its high parts' term, so the smaller terms keep their own alignment - #1145

Merged
juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-q38-fix-1140-sm86
Nov 3, 2026
Merged

juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-q38-fix-1140-sm86

Conversation

@juliankang4

Copy link
Copy Markdown
Collaborator

GDN prompt 곱에서 큰 seed에 정렬되던 작은 항들을 따로 누적하도록 고쳐, RTX 5090에서 near-direction 절의 오차를 3.2e-6에서 1.1e-6으로 낮췄습니다.

What and why

The GDN prompt delta added the chunk's state term and its in-chunk query term as the accumulator seed of all six split terms of each product. The five smaller terms then aligned to the large seed in the tensor cores' truncating accumulator, which tripled the truncation error. On an RTX 5090 the gate_linear prompt clause with keys near one direction read o at 3.215e-6 and the lane at 2.732e-6 on the kernel before this change, over the 2e-6 PROMPT_BAND.

Refs #1140

split_mma now accumulates the five smaller terms from zero, adds the seed in one f32 rounding, and runs only the high parts' term on top of the seed. The seed still keeps a sum that the one-token rule keeps finite from overflowing. PROMPT_BAND stays 2e-6 and its PIN comment carries the new measurements. The gpu unsafe ratchet goes from 2992 to 2993 blocks for the extra MMA launch, which has its SAFETY line. The change reaches every model that runs the GDN prompt form, on any tensor-parallel size, because split_mma is a per-card kernel.

Release notes: Fixed: the GDN prompt delta's tensor-core accumulation error on keys near one direction is about a third of what it was, back under its 2e-6 band.

Code shape

  • No second copy. Logic two models (or two call sites) share has one common owner; I lifted it there instead of
    copying it (AGENTS.md "Common code first", docs/rust-quality.md R14). Where I found an existing copy, I
    named it below.
  • Model code holds only architecture facts. A model's own files carry only what its architecture forces
    (tensor shapes, the attention kind, the quant). A common owner gained no per-model branch, flag or trait method.
  • Dead code is gone. Nothing I made unused is left behind (functions, flags, gate clauses, docs).
  • No silent failure. Undefined input is a named error or panic, never a defined-looking output.
  • Comments state what is true now. No dates, issue numbers or how a bug was found (tools/check-comments.sh).
  • No relaxed gate. No band, tolerance or lint moved to make a check pass; a re-pin carries PIN(YYYY-MM-DD):
    and its reason.
  • cargo fmt and cargo clippy are clean on what I touched; the lint count did not go up.

Duplication found or removed (path:line), or "none": none. chunk_product (crates/gpu/src/linear/delta.rs:646) multiplies two shared-memory tiles from a zero accumulator and takes no seed, while split_mma (:707) is one 16-key step with A in registers onto a seed that must join after the smaller terms. SPLIT_TERMS stays the one owner of the term order.

What I ran

Base 0d6f89cb8e7b874047142a0e2555f174cc5f4566, head dd67f5bc9a785908287e5f558c6e3b7064f57d3a.

$ nvidia-smi
Tue Nov  3 16:40:01 2026       
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 595.99.02              Driver Version: 595.99.02      CUDA Version: 13.2     |
+-----------------------------------------+------------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|=========================================+========================+======================|
|   0  NVIDIA GeForce RTX 5090        Off |   00000000:01:00.0  On |                  N/A |
|  0%   43C    P8             14W /  400W |      34MiB /  32607MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+

+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI              PID   Type   Process name                        GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|  No running processes found                                                             |
+-----------------------------------------------------------------------------------------+
$ BLOOMERY_BOX_LOCAL=1 just gate-gpu-linear

o relative L2 error of the prompt clause against the one-lane rule (Base is the kernel before the change, Head the kernel after it):

Metric Base Head
o, m=16 8.325e-7 7.239e-7
o, m=1000 6.958e-7 5.685e-7
o, m=4096 6.930e-7 5.644e-7
o, m=4096, keys near one direction 3.215e-6 1.140e-6
lane 2 at its last whole chunk, m=4096, keys near one direction 2.732e-6 6.870e-7

PROMPT_BAND is 2e-6, so the near-direction row before the change is over it and the row after is under it. After the change, the f32-limit edge clause and the whole gate read:

prompt updates cancelling a state near f32's limit: o and state finite true, no fault true PASS
gate_linear: 197 clauses, 0 failed — PASS
$ BLOOMERY_BOX_LOCAL=1 just gate-ptx-spill
ptx-spill bin=gate_qwen3vl_tower entries=28 pinned=28 nonzero=none violations=0 PASS

The generate_ds41 line of the same run lists its pinned spill entries and reports no violations.

tools/check-unsafe.sh accepts the gpu ratchet at 2993 blocks.

Hardware (if the change is for a machine)

Card Driver CUDA
NVIDIA GeForce RTX 5090 595.99.02 13.2

AI help

AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.

…ller terms keep their own alignment

The prompt delta's o and state products start from the chunk's
D_t*S^T q_t and D*S, which keeps a sum the one-token rule holds finite
finite near f32's limit. Seeding all six split terms with them made
every smaller term's MMA align to the seed, and the tensor cores'
accumulator truncates the aligned sum, so the keys near one direction
clause of gate_linear read 3.2e-6 for o on an RTX 5090 and 4.2e-6 on an
RTX 3090, above its 2e-6 band on both.

split_mma now sums the five smaller terms from a zero accumulator, adds
the seed in one f32 rounding and runs the high parts' term on that, so
only the high term's sum aligns to the seed. On the RTX 5090 the clause
reads 1.14e-6 for o and 6.9e-7 for the lane, the other prompt clauses
5.6e-7 to 7.2e-7, and the clause with updates cancelling a state near
f32's limit stays finite. The RTX 3090 read 1.3x the RTX 5090 on the
seeded form, about 1.5e-6 here, so the band stays at 2e-6, about 2x the
worst measured, with its pin updated.
@github-actions github-actions Bot added gpu The card engine: crates/gpu*, crates/app needs-gpu Changes code a card must check, and carries no gate run on a card labels Nov 3, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: CLEAN: No must-fix defect found in the changed accumulation or gate pins.

Non-blocking

⚠ Complete the numeric-order evidence: crates/gpu/src/linear/delta.rs:717.
For each full 16-token chunk that commits state, the two output calls and sixteen state calls add 18 × 4 scalar f32 additions per thread [derived]; MMA and device-launch counts stay unchanged.
AGENTS.md classifies this as “float sum order or precision.” The supplied evidence lacks the required gate-gpu-e2e count-pin result and timed A/B. Attach these for the current head on the contributor's card, timing prefill and naming the card, model file, commit hashes, commands and output.

Checked

Duplicates: 0 new functions, types or constants; dryer reported 0 pairs. Grep found no second owner of the seeded split product; chunk_product has a different operand shape and no seed.
Complexity: crapper flagged none; split_mma adds one fixed-size loop.
Silent failure: 2 consumers followed, output and state; non-finite results still raise LinearDelta.
Tests: no assertions changed. Mutant: restore low-term accumulation onto the seed at split_mma. The PR reports 3.215e-6 on RTX 5090 at m=4096 before the fix, exceeding the existing near-direction check's 2e-6 band. No local CUDA run.
Gates: PROMPT_BAND remains 2e-6; its measurement comment and the unsafe-block ratchet carry dated PIN reasons.
Escape catalog: no C1–C4 patterns match.

Notes

The supplied GPU run names head dd67f5b; this review's head is 4f8fca6. Hardware results above come from the PR body.
Dryer did not search crates/gpu-gates; its changed hunk only updates the band comment.

Card check: gpu-evidence. This pull request changes crates/gpu-gates/src/bin/gate_linear.rs, crates/gpu/src/linear/delta.rs and carries a gate run on the author's card, which counts as verified.

🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)

@github-actions github-actions Bot added gpu-evidence Verified on the author's card: the pull request carries the gate run and its output and removed needs-gpu Changes code a card must check, and carries no gate run on a card labels Nov 3, 2026
@juliankang4

Copy link
Copy Markdown
Collaborator Author

The review is done and the contribution check passed, so I'm merging this.

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

Labels

gpu The card engine: crates/gpu*, crates/app gpu-evidence Verified on the author's card: the pull request carries the gate run and its output

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant