Skip to content

tools: check every PTX shape table for missing entries and filtered pins - #709

Merged
juliankang4 merged 6 commits into
midagedev:mainfrom
juliankang4:fix-ptx-shape-rows
Oct 23, 2026
Merged

juliankang4 merged 6 commits into
midagedev:mainfrom
juliankang4:fix-ptx-shape-rows

Conversation

@juliankang4

Copy link
Copy Markdown
Collaborator

PTX 기준표의 누락을 모든 표에서 검사하고, 범위를 좁힌 검사가 범위 밖 pin을 오판하지 않게 고칩니다.

Part of #565. Tracked in #699.

What and why

Two checks guard the per-kernel PTX resource tables in tools/ref/ptx-shapes/, and both had a gap.

  1. tools/ptx-spill-check.sh builds the expected pin set for a binary from every row of its table, but the scan it compares against only covers entries that match the binary's name filter (for example gate_qwen3vl_tower:vis_). A valid pin outside the filter was reported as stale. This came in with 0a3ff0259466.
  2. tools/check-ptx-names.py compared only the first table against the declared kernels in both directions. The tables beside it were checked for stale rows only, so a kernel could lose its row there and the static check said nothing. This came in with 84f77b01bef2 (tools: gate-ptx-spill reads a table per PTX arch and card capability, with cc 12.1 tables for sm_86 and sm_121 #170). Kernel additions in 3ee9c8af7d01 and e53cabebbb9b (gpu: normalize independent BF16 output heads to MXFP8 #665), 8c8b5e7cdb50 (gpu: HC prompt projections use the shared BF16 tensor-core dispatch #693) and 5b302b32abb6 (qwen38: load the checkpoint folder MTP draft in its stored formats #682) left rows out of the cc 12.1 tables, and e4364b6cb65d (gpu: run routed NVFP4 prompt GEMM on FP4 tensor cores #687) added an incomplete native table. On a cc 12.1 card the spill gate then reports unpinned entries.

Changes:

  • tools/ptx-spill-check.sh applies the scan's substring filter to the expected pins too. Stale, unpinned and spill differences inside the filter still fail.
  • tools/check-ptx-names.py runs one comparison for every table. Each table must hold the unconditional entries, and a target-only module's entries are required in the tables whose # cfg: line matches the module's guard. A row in another table no longer excuses a missing one. The # cfg: guards are read once per source file.
  • tools/ref/ptx-shapes/sm_86-cc12.1.tsv gets 42 rows, sm_121-cc12.1.tsv gets 42 rows and sm_121a-cc12.1.tsv gets three rows, taken from a scan on a DGX Spark.
  • The sm_121 spill pins for ds41_expert_gate_up_tiles (716 to 680), kq_gate_up_act_q4k_tiles (756 to 752) and kq_gate_up_act_q5k_tiles (836 to 832) are lowered to the measured values. The JIT local values are unchanged, and the earlier PIN history stays in the table.
  • docs/contrib/dgx-spark.md and the header comments describe what the checks do now.

No kernel, inference code or public Rust item changes.

Release notes: internal: the PTX resource gates now catch a kernel row missing from any table and no longer flag valid pins under a name filter.

Code shape

  • No second copy. The compare loop in tools/check-ptx-names.py is the one path for the first table and the tables beside it; the old separate stale-only loop is gone.
  • Model code holds only architecture facts. No model code changes.
  • Dead code is gone. The stale-only table loop was removed.
  • No silent failure. A missing row in any table is a named unpinned error.
  • Comments state what is true now.
  • No relaxed gate. Both checks are stricter. The three lowered sm_121 pins carry the measured values and keep their PIN(...) history.
  • cargo fmt and cargo clippy: no Rust files change.

Duplication found or removed (path:line): the table loop in tools/check-ptx-names.py::check was written twice, once for the first table and once for the tables beside it. It is now one loop.

What I ran

Run against the unchanged checks, the new self-test cases and the tree without the rows give:

FAIL-FIRST spill=1 names=1 tree=0

With the fix, both self-tests report ok, and the fixed name check refuses the tree that lacks the 87 rows:

ptx-spill-check: self-test ok
check-ptx-names: self-test ok
FIXED-TESTS spill=0 names=0 unfilled-tables=1

On the DGX Spark I built the generate_ds41 (gpu,deepseek41), gate_qwen3vl_tower and oxart_jit (vision) binaries for sm_86, sm_121 and sm_121a and ran tools/ptx-scan.sh on each. Against the original tables the comparison returns 1 on every target, because of the missing rows and the three old spill values:

PTXPINS-BASE-COMPARE sm_86 rc=1
PTXPINS-BASE-COMPARE sm_121 rc=1
PTXPINS-BASE-COMPARE sm_121a rc=1

With the corrected tables, the same scans compare clean on all three targets, and the name check reports ok:

CAPTURED-PTX sm_86 rc=0
CAPTURED-PTX sm_121 rc=0
CAPTURED-PTX sm_121a rc=0
check-ptx-names: ok (2 binaries, 426 rows = 426 declared entries; 3 tables beside it checked for stale and unpinned entries; gate_e2e covered (bloomery-gpu by generate_ds41))
PTXPINS-FINAL-PASS targets=3 scans=6 static=ok

The corrected-table comparison reused the saved scans and ran with PTX_SPILL_CACHE=off, so it did not repeat the driver JIT. A later commit only moved one existing pin row next to its comment; entry names and values are the same.

Not run: the JIT on a cc 8.6 card, the runtime arithmetic gates and any speed comparison. This change touches the cc 12.1 tables and the checkers; the default cc 8.6 values and all inference code are as before.

Reproduce the static part with:

bash tools/ptx-spill-check.sh --self-test
python3 tools/check-ptx-names.py --self-test
bash tools/check-ptx-names.sh

The scan needs a cc 12.1 card: build each binary for the target, then run bash tools/ptx-scan.sh <bin> [vis_] and compare against the table with tools/ptx-spill-check.sh.

Hardware

DGX Spark, one GB10 card, cc 12.1:

| NVIDIA-SMI 595.84                 Driver Version: 595.84         CUDA Version: 13.3     |
|   0  NVIDIA GB10                    On  |   0000000F:01:00.0 Off |                  N/A |

ptxas version 13.3.73. The self-tests and the name check ran on a Linux CPU host.

What I ran into

This does not block the PR. The new rows were measured on the Spark only, and the existing sm_86 rows of the cc 12.1 table all matched that measurement. The cc 8.6 tables are untouched.

AI help

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

@github-actions github-actions Bot added dgx-spark The DGX Spark (aarch64, GB10) port documentation Improvements or additions to documentation tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo labels Oct 23, 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: The filtered comparison and per-table checks preserve the pinning contract.

Checked

Duplicates: 0 new functions, types or constants. The existing comparison loop now owns all tables. No dryer pairs were available.

Complexity: No Rust files changed.

Silent failure: Three sites followed: two empty-row defaults and the missing-module-owner branch. Missing required rows reach named unpinned errors.

Tests: Python parsing and shell syntax checks pass. The PR reports both self-tests and the full-tree name check passing. At tools/ptx-spill-check.sh:741, removing filtering would fail the filtered-scan assertions; rejecting an empty filter would break the unfiltered assertion. Dropping the stale or unpinned comparison would break its new assertion. At tools/check-ptx-names.py:683, skipping secondary tables would break the missing-row, filtered-row and explicit-path assertions. Requiring or omitting conditional entries at line 688 would break the target assertions. Additional cases reject a missing default row, an unrecognized binary and a source guard that does not match the table.

Gates: 87 rows added, none removed. Three spill pins lowered; each has a dated PIN with measurement conditions. The PR records failure before the fixes and success afterward.

Escape catalog: No changed code matches C1–C4. No inference hot path changed.

Notes

Dryer and crapper did not run because no Rust file changed.

GPU evidence is incomplete: the PR includes the GB10/driver identification and scan summaries, but lacks the paired commit hashes and exact just gate-* commands with output.

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

@juliankang4

Copy link
Copy Markdown
Collaborator Author

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

@juliankang4
juliankang4 merged commit f5a352c into midagedev:main Oct 23, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dgx-spark The DGX Spark (aarch64, GB10) port documentation Improvements or additions to documentation tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant