Skip to content

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

Merged
juliankang4 merged 3 commits into
midagedev:mainfrom
juliankang4:dgx-spark-ptx-sm121
Oct 14, 2026
Merged

juliankang4 merged 3 commits into
midagedev:mainfrom
juliankang4:dgx-spark-ptx-sm121

Conversation

@juliankang4

@juliankang4 juliankang4 commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

What and why

gate-ptx-spill has one table, tools/ref/ptx-shapes.tsv, pinned on the RTX 3090 at sm_86. On a DGX Spark (GB10, compute capability 12.1) the gate is red at the default sm_86, and at sm_121 it stops with "the shape pins are sm_86 only". The spill column comes from ptxas -arch=<arch>, so it follows the PTX arch. The jit_local column comes from the driver JIT, so it follows the card's capability. One table cannot hold both cards. Part of #53.

This PR adds two tables in tools/ref/ptx-shapes/, sm_86-cc12.1.tsv and sm_121-cc12.1.tsv, pinned on GB10. The recipe names the base table and the directory tools/ref/ptx-shapes/. tools/ptx-spill-check.sh reads each binary against the table that matches the arch= and jit-cc= of its scan banner. tools/ptx-scan.sh's blk/SM column also takes the cc 12.x limits for sm_120 and sm_121, so a scan at sm_121 runs instead of being refused.

The rows of the base table do not change. Its header gains one line, # jit-cc: 8.6, because every table now names its capability (see commit 3). On the RTX 3090 the gate still compares against the base table only. It reads the headers of all three tables on every card, so a malformed header in any of them is a usage error (rc 2) on the 3090 too.

About the red rows: #42 had 13 generate_ds41 rows and 8 gate_e2e rows red at sm_86 on GB10. At 02d874bd there were 14 and 9, because gqa_flash_seg_k192_ring landed in both binaries after #42. All 23 are jit_local rows; the spill column matches the base pins everywhere. On 22 rows the cc 8.6 JIT keeps no local memory and the cc 12.1 JIT keeps some. On one row, ds41_attn_seg_stage, it grows from 8 to 16 bytes. The largest is q4k_gemv_tiles, 184 bytes a thread. At sm_121, ptxas also spills on the same 23 rows and the JIT gives the same jit_local as at sm_86. gate_qwen3vl_tower (16 entries) has none. Each nonzero row has a PIN(2026-10-14): line that gives the JIT registers, the .minnctapersm or register bound it works under, and the cc 8.6 value, for example:

# PIN(2026-10-14): on cc 12.1 the driver JIT gives q4k_gemv_tiles 48 registers (.minnctapersm 5: 5 blocks of 256 threads an SM) and keeps 184 bytes a thread in local memory, where the cc 8.6 JIT keeps 0 (tools/ref/ptx-shapes.tsv); ptxas -arch=sm_121 assembles it at the same registers and spills 708 bytes.

These rows record what the toolchain does today. Whether any of these kernels should change for cc 12.1 is a separate question.

The change, in three commits:

  1. 794c2f69 ptx-scan.sh reads its occupancy limits from one row per arch (a case that sets OCC, which awk splits into L[1..7]). It is a refactor only. At sm_86, the scans of all three binaries are byte-identical to the scans made with the script at 02d874bd.
  2. 05e884af ptx-scan.sh gets a cc 12.x row for sm_120 and sm_121 (with a and f), and the header gives its sources. From the CUDA Programming Guide v13.4.2, section 5.1, Tables 30 and 31: 65536 registers and 100 KB of shared memory an SM, and 48 resident warps on both 8.6 and 12.x; 16 resident blocks on 8.6 and 24 on 12.x. From the toolkit's cuda_occupancy.h, the same for 8.x and 12.x: registers allocated 256 a warp (cudaOccRegAllocationGranularity), shared memory in units of 128 bytes (cudaOccSMemAllocationGranularity), and the driver's 1 KB reservation a block (reservedSharedMemPerBlock). GB10 reports the same values through cuDeviceGetAttribute (MAX_BLOCKS_PER_MULTIPROCESSOR 24, MAX_SHARED_MEMORY_PER_MULTIPROCESSOR 102400, RESERVED_SHARED_MEMORY_PER_BLOCK 1024, MAX_REGISTERS_PER_MULTIPROCESSOR 65536, MAX_THREADS_PER_MULTIPROCESSOR 1536). Any other arch is still refused with rc 64. The column takes the limits of the arch ptxas assembled for, as before. The self-test's one-warp fixture entry (.reqntid 32) is held by the block cap alone, so a wrong cap shows there.
  3. d9bb0ce4 The tables and the check:
    • The gate-ptx-spill recipe names tools/ref/ptx-shapes.tsv tools/ref/ptx-shapes/. ptx-spill-check.sh takes its leading arguments that hold a / as tables, reads one that ends in / as every *.tsv in that directory, and takes the rest as binaries. tools/recipes.py reads a directory named on a recipe line as an input of that recipe, so just affected selects gate-ptx-spill when a table in tools/ref/ptx-shapes/ changes or is added, and the recipe's ledger key reads every file under that directory (tools/recipes.py:7531). The cc 12.1 tables are in a directory for two reasons. check-recipes refuses an arch literal (sm_ and a digit) anywhere in the justfile outside the arch definition, so the recipe cannot name them by file. A glob on the recipe line would be a tree walk to the ledger key, which would then cover the whole tree.
    • Every table has exactly one # arch: line and one # jit-cc: line, each with one value of the right shape. The arch shape is tools/arch.sh's (ARCH_SHAPE, which bloomery_arch now reads too); the capability is <M>.<m>, as the scan banner prints it. A missing line, a second line, an empty value, two values, a value of another shape, or two tables of one arch and capability is a usage error (rc 2).
    • Before it scans, the check refuses an arch that no table pins (rc 64, naming the pairs it has). For each binary it then picks the table that matches the scan banner. A binary scanned on a capability that no table pins for that arch is a FAIL line ("no table for sm_86 on cc 9.0"). It never passes, and it is never read against another card's rows. The compare is as before: exact, and a missing or stale row fails.
    • tools/check-ptx-names.py takes the tables from the same recipe call, reads the directory the same way (a directory that holds no table is refused), and reads the two cc 12.1 tables for stale rows only (see "What I ran into" for why).
    • Docs that this makes stale: docs/contrib/dgx-spark.md (P3 is done, section 6 "Pins that follow the compute capability", section 10, answer 7, the sparkprep S3 row), docs/contrib/dgx-spark.md's gate-ptx-spill bullet in the Spark notes and the current state under section 11, answer 4, docs/contrib/local-check.md row 6 and its contributor list (which kept gate-ptx-spill off), docs/contrib/new-model.md (where a new entry's cc 12.1 row comes from), docs/cuda-oxide.md (the gate bullet), the gate-ptx-spill recipe comment, and comments in tools/arch.sh and tools/narrow-scan.sh. narrow-scan.sh still refuses an arch other than sm_86; its message now gives its own reason (it builds both sides at sm_86), not ptx-scan.sh's old one.

Code shape

  • No second copy. The occupancy limits are one case row per arch, read by the one awk function. The list of tables is the recipe line's, and both readers take it from there. The arch shape is tools/arch.sh's. Two rules of ptx-spill-check.sh's argument list have a second copy in check-ptx-names.py, which reads the same call from the recipe text. The leading arguments that hold a / are tables (tools/ptx-spill-check.sh:178, tools/check-ptx-names.py:287). One that ends in / is every *.tsv in that directory, and a directory with none is refused (tools/ptx-spill-check.sh:178, tools/check-ptx-names.py:321). The base already parses the binary arguments (<bin>:<substring>) in both files the same way. I kept both copies. One is bash and the other is Python, and no existing owner holds these rules: tools/recipes.py reads a named directory only as a path prefix for just affected and the ledger key (tools/recipes.py:1740), not as a list of tables. A single owner would need a new mode in ptx-spill-check.sh that prints the tables it resolved, for check-ptx-names.py to call, and that adds more than the copy removes. Each file's self-test has a case for a directory with no table.
  • Model code holds only architecture facts. No model code changes.
  • Dead code is gone. The sm_86-only refusal in ptx-scan.sh and its message are replaced, not kept beside the new one.
  • No silent failure. A binary whose banner matches no table is a FAIL line. An arch no table pins is rc 64 before any scan. A malformed or duplicate header, and two tables with one key, are rc 2. No table falls back to a default capability.
  • Comments state what is true now.
  • No relaxed gate. The base table's rows are identical; its header gains # jit-cc: 8.6. The new tables are exact pins, and each nonzero row carries PIN(YYYY-MM-DD): and its reason.
  • cargo fmt and cargo clippy are clean on what I touched; no Rust file is touched.

Duplication found or removed (path:line), or "none": tools/ptx-spill-check.sh:178 against tools/check-ptx-names.py:287 and tools/check-ptx-names.py:321 (kept, see "No second copy").

What I ran

The runs below are at a5e5d57a. The head d9bb0ce4 differs from it only in docs/contrib/dgx-spark.md and docs/contrib/local-check.md (the contributor list there now keeps gate-ptx-spill where its tables pin the card) and in the rebase onto 166921f5.

On the DGX Spark

The tree of this branch (head a5e5d57a), built from a clean target/ in the project's dev container on a DGX Spark. The cc 12.1 pins come from scans on another DGX Spark of the same setup ("Hardware"), so this run also reads the pins on a second unit.

The gate-ptx-spill recipe body at BLOOMERY_ARCH=sm_86, rc 0 (the scan banner and verdict lines; the cargo build output is left out):

ptx-scan bin=target/release/generate_ds41 section=.oxart bytes=10588400 ptxas=/usr/local/cuda/bin/ptxas ptxas-version=13.3.73 arch=sm_86 modules=2 jit-card=NVIDIA_GB10 jit-cc=12.1 jit-cuda=13.3
ptx-spill bin=generate_ds41 table=tools/ref/ptx-shapes/sm_86-cc12.1.tsv arch=sm_86 jit-cc=12.1
ptx-spill bin=generate_ds41 entries=301 pinned=301 nonzero=cand_select(spill=0,jit_local=8),ds41_attn_seg(spill=0,jit_local=24),ds41_attn_seg_sel(spill=0,jit_local=24),ds41_attn_seg_sel_stage(spill=0,jit_local=32),ds41_attn_seg_stage(spill=8,jit_local=16),ds41_expert_gate_up_tiles(spill=0,jit_local=144),flash_latent_mma(spill=0,jit_local=8),gemm_q6k(spill=0,jit_local=32),gqa_flash_seg_k192_ring(spill=0,jit_local=8),kq_gate_up_act_q4k_tiles(spill=0,jit_local=136),kq_gate_up_act_q5k_tiles(spill=0,jit_local=136),q4k_gemv_tiles(spill=0,jit_local=184),q5k_gemv_tiles(spill=0,jit_local=104),qwen35moe_router_norm_m(spill=0,jit_local=8) violations=0 PASS
ptx-scan bin=target/release/gate_e2e section=.oxart bytes=8532272 ptxas=/usr/local/cuda/bin/ptxas ptxas-version=13.3.73 arch=sm_86 modules=1 jit-card=NVIDIA_GB10 jit-cc=12.1 jit-cuda=13.3
ptx-spill bin=gate_e2e table=tools/ref/ptx-shapes/sm_86-cc12.1.tsv arch=sm_86 jit-cc=12.1
ptx-spill bin=gate_e2e entries=234 pinned=234 nonzero=cand_select(spill=0,jit_local=8),flash_latent_mma(spill=0,jit_local=8),gemm_q6k(spill=0,jit_local=32),gqa_flash_seg_k192_ring(spill=0,jit_local=8),kq_gate_up_act_q4k_tiles(spill=0,jit_local=136),kq_gate_up_act_q5k_tiles(spill=0,jit_local=136),q4k_gemv_tiles(spill=0,jit_local=184),q5k_gemv_tiles(spill=0,jit_local=104),qwen35moe_router_norm_m(spill=0,jit_local=8) violations=0 PASS
ptx-scan bin=target/release/gate_qwen3vl_tower section=.oxart bytes=570640 ptxas=/usr/local/cuda/bin/ptxas ptxas-version=13.3.73 arch=sm_86 modules=1 filter=vis_ jit-card=NVIDIA_GB10 jit-cc=12.1 jit-cuda=13.3
ptx-spill bin=gate_qwen3vl_tower table=tools/ref/ptx-shapes/sm_86-cc12.1.tsv arch=sm_86 jit-cc=12.1
ptx-spill bin=gate_qwen3vl_tower entries=16 pinned=16 nonzero=none violations=0 PASS

The same at BLOOMERY_ARCH=sm_121, rc 0:

ptx-scan bin=target/release/generate_ds41 section=.oxart bytes=10586304 ptxas=/usr/local/cuda/bin/ptxas ptxas-version=13.3.73 arch=sm_121 modules=2 jit-card=NVIDIA_GB10 jit-cc=12.1 jit-cuda=13.3
ptx-spill bin=generate_ds41 table=tools/ref/ptx-shapes/sm_121-cc12.1.tsv arch=sm_121 jit-cc=12.1
ptx-spill bin=generate_ds41 entries=301 pinned=301 nonzero=cand_select(spill=8,jit_local=8),ds41_attn_seg(spill=40,jit_local=24),ds41_attn_seg_sel(spill=48,jit_local=24),ds41_attn_seg_sel_stage(spill=56,jit_local=32),ds41_attn_seg_stage(spill=32,jit_local=16),ds41_expert_gate_up_tiles(spill=716,jit_local=144),flash_latent_mma(spill=24,jit_local=8),gemm_q6k(spill=132,jit_local=32),gqa_flash_seg_k192_ring(spill=12,jit_local=8),kq_gate_up_act_q4k_tiles(spill=756,jit_local=136),kq_gate_up_act_q5k_tiles(spill=836,jit_local=136),q4k_gemv_tiles(spill=708,jit_local=184),q5k_gemv_tiles(spill=412,jit_local=104),qwen35moe_router_norm_m(spill=32,jit_local=8) violations=0 PASS
ptx-scan bin=target/release/gate_e2e section=.oxart bytes=8530944 ptxas=/usr/local/cuda/bin/ptxas ptxas-version=13.3.73 arch=sm_121 modules=1 jit-card=NVIDIA_GB10 jit-cc=12.1 jit-cuda=13.3
ptx-spill bin=gate_e2e table=tools/ref/ptx-shapes/sm_121-cc12.1.tsv arch=sm_121 jit-cc=12.1
ptx-spill bin=gate_e2e entries=234 pinned=234 nonzero=cand_select(spill=8,jit_local=8),flash_latent_mma(spill=24,jit_local=8),gemm_q6k(spill=132,jit_local=32),gqa_flash_seg_k192_ring(spill=12,jit_local=8),kq_gate_up_act_q4k_tiles(spill=756,jit_local=136),kq_gate_up_act_q5k_tiles(spill=836,jit_local=136),q4k_gemv_tiles(spill=708,jit_local=184),q5k_gemv_tiles(spill=412,jit_local=104),qwen35moe_router_norm_m(spill=32,jit_local=8) violations=0 PASS
ptx-scan bin=target/release/gate_qwen3vl_tower section=.oxart bytes=570528 ptxas=/usr/local/cuda/bin/ptxas ptxas-version=13.3.73 arch=sm_121 modules=1 filter=vis_ jit-card=NVIDIA_GB10 jit-cc=12.1 jit-cuda=13.3
ptx-spill bin=gate_qwen3vl_tower table=tools/ref/ptx-shapes/sm_121-cc12.1.tsv arch=sm_121 jit-cc=12.1
ptx-spill bin=gate_qwen3vl_tower entries=16 pinned=16 nonzero=none violations=0 PASS

The scans of this run against the scans the pins were made from (tree on 02d874bd), with tools/ref/ptx-canon.py --scans, rc 0 for each binary at both arches. For generate_ds41 at either arch:

ptx-canon: scans method=decl1 entries base=301 new=301 only-base=0 only-new=0
ptx-canon: table rows identical=301 moved=0
ptx-canon: md5 identical=301 moved=0

gate_e2e (234 entries) and gate_qwen3vl_tower (16) print the same with their counts. Every entry's PTX and resource row is the same as in the pinning scans, so the comparisons below, made on those scans, hold for this head.

For comparison, the sm_86 scans of the pinning build, made with 02d874bd's ptx-scan.sh and read against 02d874bd's base table, differ on the 23 rows above (jit_local only, the other 528 entries match); 02d874bd's check refuses sm_121 by name.

FAIL first, in the same run, on the same binaries: ptx-spill-check.sh with copies of the tables in the recipe's form (<copy>/ptx-shapes.tsv <copy>/ptx-shapes/), one table edited. The sm_86 run had one edit in its cc 12.1 table (a jit_local value); the sm_121 run had two in its table (a spill value, and the touch row renamed to a kernel that does not exist). Both runs exit 1. The violation lines and verdicts:

sm_86:
generate_ds41 q4k_gemv_tiles jit_local=184 pinned=176 ABOVE
ptx-spill bin=generate_ds41 entries=301 pinned=301 ... violations=1 FAIL
ptx-spill bin=gate_e2e entries=234 pinned=234 ... violations=0 PASS
ptx-spill bin=gate_qwen3vl_tower entries=16 pinned=16 ... violations=0 PASS

sm_121:
generate_ds41 gone_kernel stale
generate_ds41 touch unpinned spill=0 jit_local=0
ptx-spill bin=generate_ds41 entries=301 pinned=301 ... violations=2 FAIL
gate_e2e q5k_gemv_tiles spill=412 pinned=404 ABOVE
ptx-spill bin=gate_e2e entries=234 pinned=234 ... violations=1 FAIL
ptx-spill bin=gate_qwen3vl_tower entries=16 pinned=16 ... violations=0 PASS

The occupancy column, on the pinning sm_121 build (its scans are identical to this head's, above):

  • blk/SM equals the driver's cuOccupancyMaxActiveBlocksPerMultiprocessor (on the module the JIT loaded, with the entry's .reqntid and no dynamic shared memory) for all 551 entries of the three binaries. Ptxas registers also equal jit_regs for every entry.
  • With the cc 12.x block cap set back to 16, 22 of the 301 generate_ds41 entries differ from the driver (for example card_sel, 16 against 24).

On a Mac, at a5e5d57a

The rebases onto 1678b4fa and then 166921f5 changed none of the scripts and tables this PR touches, so the mutation and FAIL-first runs below, made on the same files before the rebase, still apply.

Apple M4 Pro, macOS 27.0.1. The three shell self-tests ran twice: with bash on PATH resolving to the macOS /bin/bash 3.2.57, and to Homebrew bash 5.3.20. They start the scripts under test with the bash on PATH, so both runs exercise the scripts themselves under that bash. Both runs print the same lines, rc 0:

$ bash tools/ptx-spill-check.sh --self-test
ptx-spill-check: self-test ok
$ bash tools/ptx-scan.sh --self-test
ptx-scan: self-test ok (16 cases, 0 failed)
$ bash tools/narrow-scan.sh --self-test
narrow-scan: self-test ok (71 cases, 0 failed)

The rest, rc 0 (Python 3.15.0):

$ python3 tools/recipes.py --self-test
self-test: ok (159 gate recipes, 0 failures)
$ python3 tools/check-ptx-names.py --self-test
check-ptx-names: self-test ok
$ python3 tools/check-ptx-names.py check
check-ptx-names: ok (3 binaries, 551 rows = 551 declared entries; 2 tables beside it read for stale rows)
$ bash tools/check-comments.sh
check-comments: ok (858 files, 130340 comment lines; tools/ cites no doc by line number, 0 allowed by CITE_ALLOW; no retired word, 1 line(s) allowed by WORD_ALLOW)
  • ptx-spill-check.sh --self-test covers: a cc 12.1 table picked by the banner, a row present only in the cc 8.6 table read as unpinned on cc 12.1, a capability with no table as a FAIL, sm_121 read against its own table, the cc 12.1 tables passed as a directory, a directory with no table (rc 2), no table argument, two tables with one key, sm_90 refused with 64 before any scan, and the headers: no # arch:, two # arch: lines, an arch of another shape, no # jit-cc:, two # jit-cc: lines, # jit-cc: with no value, with two values, and with a value of another shape. Each mutant of the header parser and the argument split turns cases red (dropping the shape check of either key, the missing-line refusal, the second-line refusal or the duplicate-key refusal; reading only the first argument as a table; reading a directory argument as one file).

  • The header check, FAIL first: a cc 8.6 scan read against a base table whose # jit-cc: line is broken. The script before this revision used only a # jit-cc: line with exactly one value and skipped the others, and a base table with no such line was cc 8.6 by default. So it read the first two headers below as no line and the base table as cc 8.6, and in the third it read the first line and skipped # jit-cc: 12.1 x:

    base table header                 before        this branch
    # jit-cc:                         rc 0, PASS    rc 2, the table ... declares '# jit-cc:', not one jit-cc as in '# jit-cc: 8.6'
    # jit-cc: 12.1 extra              rc 0, PASS    rc 2, the table ... declares '# jit-cc: 12.1 extra', not one jit-cc as in '# jit-cc: 8.6'
    # jit-cc: 8.6, # jit-cc: 12.1 x   rc 0, PASS    rc 2, the table ... declares 2 `# jit-cc:` lines: a table pins one jit-cc
    # jit-cc: 8.6                     rc 0, PASS    rc 0, PASS
    
  • The real tables' headers, stopped before any scan by an arch no table pins:

    $ BLOOMERY_ARCH=sm_90 bash tools/ptx-spill-check.sh tools/ref/ptx-shapes.tsv tools/ref/ptx-shapes/ generate_ds41
    ptx-spill-check: no ptx-shapes table for sm_90; the tables pin sm_86 on cc 8.6, sm_121 on cc 12.1, sm_86 on cc 12.1
    

    rc 64. diff of the base table's non-comment lines against 1678b4fa: identical.

  • ptx-scan.sh --self-test, mutants of the cc 12.x row and the arithmetic, one at a time: the block cap at 16 or at 32, the register unit at 128, the reservation at 0, the shared memory at 131072, the warps at 64, the register rounding removed, and if (L[4] < b) b = 16. Each turns at least one case red. The one-warp entry gives 16 on 8.6 and 24 on 12.x; under the cap-32 mutant it would give 32 and under the last mutant 16 [derived]. Before this revision that entry had 64 threads, where the warp limit also gives 24, and those two mutants passed.

  • just affected, on two commits on top of a5e5d57a: one edits a pin of sm_121-cc12.1.tsv, one adds a table sm_90-cc9.0.tsv:

    $ python3 tools/recipes.py affected a5e5d57a..<edit> --no-box
      gate-ptx-spill  tools/ref/ptx-shapes/sm_121-cc12.1.tsv  [named directory]
    recipes: gate-ptx-spill
    unmapped (0):
    $ python3 tools/recipes.py affected a5e5d57a..<added table> --no-box
      gate-ptx-spill  tools/ref/ptx-shapes/sm_90-cc9.0.tsv  [named directory]
    recipes: gate-ptx-spill
    unmapped (0):
    

    In the earlier revision, an edit of one pin of either cc 12.1 table printed 0 of 159 gate-recipes selected and the table under unmapped (1). tools/recipes.py's self-test now checks that the base table, a cc 12.1 table and a new table in tools/ref/ptx-shapes/ each select gate-ptx-spill.

  • check-ptx-names.py --self-test has a case for a table directory that holds no table. With that refusal removed, the case is red (rc 0, want 1).

  • shellcheck -x 0.11.0 on ptx-spill-check.sh, ptx-scan.sh, arch.sh and narrow-scan.sh: 8, 1, 0 and 39 findings, the same counts and codes as at 1678b4fa; none new. Without -x (so tools/arch.sh is not read), ptx-spill-check.sh has one more note than at 1678b4fa: SC2153 on $ARCH, which tools/arch.sh sets, suggesting the new BARCH.

  • just mac-static 1678b4fa at a5e5d57a on a second Mac (Apple M5): rc 0, every step green. That is fmt-check, lint (41 warnings, equal to tools/lint-ratchet.txt), combos, and the 11 checks, among them check-recipes (its recipes.py self-test prints ok (159 gate recipes, 0 failures), and ptx-spill-check: self-test ok), check-arch and check-ptx-names. just mac-test on the same Mac: 1199 passed and 1 failed, bloomery-refset's arch::draft::tests::a_plain_target_with_no_draft_beside_is_the_family_path (crates/refset/src/arch/draft.rs:536: on macOS, where the temporary directory /var/... resolves to /private/var/..., ROW.places lists the draft path beside the target under both spellings, and the test expects only the resolved one). This PR changes no file under crates/, and run alone on the first Mac, the test fails the same way.

Not run: gate-ptx-spill on the RTX 3090, which needs the maintainers' workstation (CONTRIBUTING.md, "How a pull request is verified and merged"). On the 3090 the gate compares against the base table only, and that table's rows are unchanged. The sm_86 scans of all three binaries with this branch's ptx-scan.sh are byte-identical to those of 02d874bd's script (the scan code has not changed since that comparison), so the scan side of that run cannot move. The headers of all three tables pass the real parser on the Mac (above).

What I ran into

  • A kernel added on a cc 8.6 card cannot get its cc 12.1 rows there: those come from a scan on a cc 12.1 card. Until a Spark scan adds them, gate-ptx-spill on a Spark names the entry unpinned. This happened while the branch was being written: vis_attn_group and vis_mean_groups landed with zero pins in the base table, and on GB10 both were unpinned until a scan at 02d874bd added their rows (0 and 0 on both arches). So that this does not block a 3090-only contributor, check-ptx-names.py reads the cc 12.1 tables for stale rows only and does not require every declared entry there. The docs say this (docs/contrib/dgx-spark.md section 6, docs/contrib/new-model.md).
  • AGENTS.md:49 ("against tools/ref/ptx-shapes.tsv"), .github/review/reviewer.md:204 and tools/review/labels.py:63 (the generated-file list) name the base table only. A change to AGENTS.md, .github/ or tools/review/ needs a person's approval (.github/review/README.md), so this PR leaves them as they are. The tables in tools/ref/ptx-shapes/ are generated the same way as the base table, so that directory could join the generated-file list.

Hardware (if the change is for a machine)

Two DGX Spark units of the same setup: GB10, compute capability 12.1, 48 SMs, driver 595.84 (CUDA 13.3 driver API, 13030), the project's dev container with CUDA 13.3.1, ptxas 13.3.73 (cuda_13.3.r13.3/compiler.38244171_0), cargo-oxide at the toolchain pin 87bc9518. BLOOMERY_BOX_LOCAL=1 (local mode). The pins, the pinning scans and the occupancy check were made on one unit; the gate-ptx-spill runs, the FAIL-first runs and the scan comparison at a5e5d57a on the other.

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 14, 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: MUST_FIX: Contributor instructions still exclude the GB10 spill gate that this PR enables.

Must fix

1. Correct the contributor instructions for the repaired spill gate

Kind B: misleading documentation with a mechanical fix. docs/contrib/dgx-spark.md:147 still says gate-ptx-spill is red on GB10. docs/contrib/local-check.md:174 still excludes it because its table is sm_86 only; the same exclusion appears at line 161. The changed justfile:2169 supplies the cc 12.1 tables, and table selection matches both arch and capability. These instructions tell Spark contributors to skip the repaired gate. Correct them with this change before contributors copy the obsolete list.

Replace the Spark bullet at lines 147–148 with:

- **`gate-ptx-spill`** runs on GB10 at `sm_86` and `sm_121` using the cc 12.1 tables (section 6).

Replace local-check lines 161–162 with:

**Which gates.** The contributor's list is `just affected` minus the real-file and real-only gates and the timing
runners; a fixture-only gate stays ([`dgx-spark.md`](dgx-spark.md) section 11, answer 4). No command prints it

Replace local-check line 174 with:

command. Your list is the items of the second kind. Include `gate-ptx-spill` only when the tables pin your PTX arch
and card capability: `sm_86` on cc 8.6, or `sm_86`/`sm_121` on cc 12.1.

Checked

Documentation: both obsolete exclusions are present and conflict with the changed gate; no review exclusion or ledger lesson suppresses this finding.
Table selection: the recipe passes the directory; the checker selects by arch and capability and fails on unsupported pairs.
Gates: all 551 base data rows are unchanged. Both new tables have the same entry set as the base table.
Performance: the diff changes tools and documentation, with no engine hot path changes.

Notes

Validation used source reads and table comparisons. Self-tests and GPU runs were not repeated.

🔨 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

Fixed in c3a8cace; the change is docs only.

  • docs/contrib/dgx-spark.md: the Spark notes' bullet now says gate-ptx-spill runs on GB10 at sm_86 and sm_121 against the cc 12.1 tables (section 6). The current-state line under section 11, answer 4 says the gate is on the list where its tables pin the card; the answer itself is left as recorded.
  • docs/contrib/local-check.md: the "Which gates" rule no longer takes gate-ptx-spill out, and the end of the dry-run paragraph keeps it on the list only where its tables pin the PTX arch and the card capability (sm_86 on cc 8.6, sm_86 or sm_121 on cc 12.1).

No other doc still keeps the gate off a Spark's list (git grep ptx-spill -- '*.md'). The runs in the body are at a5e5d57a, which differs from c3a8cace only in these two files; the body says so.

github-actions[bot]
github-actions Bot previously approved these changes Oct 14, 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: Table selection preserves the existing pins and rejects unsupported or malformed inputs.

Checked

Duplicates: the shared arch pattern has one owner in tools/arch.sh. The short shell/Python argument rules have no shared owner that reduces elements.
Complexity: the changed branches select tables and reject invalid headers in tool code; no Rust function or engine hot path changes.
Silent failure: missing or duplicate headers return 2; an unsupported arch returns 64; an unmatched capability produces FAIL.
Tests: tools/ptx-spill-check.sh:249: selecting table 0, reading only the first argument (178), or dropping header/arch refusals (199–220) makes the fixture assertions red.
Tests: tools/ptx-scan.sh:376: eight mutants of the caps, allocation units and arithmetic changed the asserted occupancy results in a read-only evaluation of the production awk function.
Tests: tools/check-ptx-names.py:333: dropping the stale-row loop or empty-directory refusal (326), or checking missing side-table rows, makes the fixture's expected status wrong. Shell syntax and Python parsing pass.
Tests: justfile:2169: removing the table-directory argument makes both edited-table and added-table recipe-selection assertions red.
Gates: all 551 base pins are unchanged. Both new tables contain the same entry set; each table's 23 nonzero rows has a dated PIN reason. The body includes FAIL-first spill and stale-row output.
Adversarial checks: malformed headers cannot select a default table; a cc 12.1 scan cannot use cc 8.6 rows; deleted kernels leave stale side-table rows that the check rejects. Table selection resets for each binary, so a mixed-card run uses each scan's own capability.
Escape catalog: none of C1–C4 matches the added code.

Notes

No Rust file changed. Full self-tests and GPU gates were not rerun during validation.
The body includes GB10 gate output and commit IDs, but lacks the required nvidia-smi line and exact just gate-ptx-spill command transcript. GPU-evidence documentation is incomplete; this does not change the verdict.

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

… arch

The occupancy constants were literals inside the awk function. They are
now one row of seven limits per arch, in the order the arithmetic reads
them, and sm_86 is still the only row, so every scan prints what it did.
The next change adds the cc 12.x row.
… sm_121

A scan at sm_120 or sm_121 (with or without a or f) was refused, because
blk/SM held only cc 8.6's limits. The cc 12.x row is the same as 8.6's
except for 24 resident blocks per SM, where 8.6 has 16 (CUDA Programming
Guide v13.4.2, section 5.1, Tables 30 and 31). The allocation units and
the per-block reservation come from the toolkit's cuda_occupancy.h, which
gives the same values for 8.x and 12.x. The header used to credit those
three to the guide, which does not list them.

blk/SM follows the arch ptxas assembled for, not the card the JIT ran on,
so an sm_86 scan prints the same column on any card. Any other arch is
still refused with 64.

The self-test scans the fixture at sm_121: a one-warp block is held by the
block cap alone, 24 where sm_86 gives 16 and the warp limit would allow 48;
a 90-register block is held to 21 by the 256-register unit, and a
25000-byte block is held to 3 by shared memory with the 1 KB reservation.
… with sm_86 and sm_121 on cc 12.1

spill follows the arch ptxas assembles for and jit_local the capability the
driver JITs for, so one table cannot hold both cards. On a DGX Spark (GB10,
cc 12.1, driver 595.84) the recipe was red at sm_86 on 23 jit_local rows,
and refused sm_121 by name.

tools/ref/ptx-shapes.tsv keeps its rows and is the sm_86 table for cc 8.6;
its header gains a `# jit-cc: 8.6` line. Two tables sit beside it in
tools/ref/ptx-shapes/, sm_86-cc12.1.tsv and sm_121-cc12.1.tsv, pinned from
full scans on GB10 with ptxas 13.3.73. Every table names its arch on one
`# arch:` line and its capability on one `# jit-cc:` line; a table with
no such line, with two, or with a value that is not one arch or
capability is refused (rc 2). The arch's shape is tools/arch.sh's.

The recipe names the base table and the directory tools/ref/ptx-shapes/.
A directory a recipe names is an input of that recipe, so `just affected`
selects gate-ptx-spill and the ledger key covers it when a table there
changes or is added; the justfile still spells no arch, and the recipe
line holds no glob, which would key the recipe on the whole tree.
ptx-spill-check.sh takes the leading arguments that hold a `/` as the
tables, one that ends in `/` as every *.tsv in it, and reads every binary
against the table of its own scan's banner (arch= and jit-cc=); a scan
with no such table fails by name, and an arch no table pins is still
refused before any scan.

The cc 12.1 tables have the base table's entries. Their 23 nonzero rows
are the same kernels at both arches, each with a PIN line: the 512-thread
entries at the 128-register cap and the .minnctapersm tile kernels keep
local memory on cc 12.1 that cc 8.6 does not. check-ptx-names reads the
other tables the recipe names for stale rows only (a directory that holds
none is refused), so a kernel added on a cc 8.6 card is not blocked on a
row it cannot measure; gate-ptx-spill on a Spark names it unpinned until a
scan there pins it.

The docs that described the sm_86-only state now describe this one, and
narrow-scan names its own reason for staying at sm_86.

@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 gate selects pins by scan architecture and card capability, rejects invalid tables, and preserves the base pins.

Checked

Duplicates: 5 new functions/constants and the renamed parser checked. The short Bash/Python argument rules have no smaller common owner. No other duplicate found; no dryer pairs supplied.

Complexity: No crapper candidates. Changes add table validation and selection; occupancy reuses one arithmetic owner. No inference hot path changes.

Silent failure: 8 added error sites followed. Unreadable tables, invalid headers and duplicate keys exit 2; an unsupported architecture exits 64; a scan with no matching table fails with exit 1. Scan errors and skipped JIT readings remain failures.

Tests, mutation inspection: tools/ptx-spill-check.sh:178 protects directory expansion; tools/ptx-spill-check.sh:205 protects header shapes; tools/ptx-spill-check.sh:212 protects unique keys; tools/ptx-spill-check.sh:249 protects capability selection. Removing each guard or expansion, or selecting by architecture alone, breaks the corresponding asserted status or output.

Tests, mutation inspection: tools/check-ptx-names.py:325 and tools/check-ptx-names.py:333 protect empty-directory refusal and stale rows. Dropping either check breaks its assertion; requiring missing side-table rows breaks the partial-table case. Removing the directory from justfile:2170 breaks the new-table selection assertions.

Tests, executed arithmetic: tools/ptx-scan.sh:523 and its register/shared-memory calculations match the fixture expectations. Eight mutants, including a 16-block cap, dropped register rounding and zero reservation, change asserted occupancy values. All four shell scripts and both Python files pass syntax checks; the real name check passes for 551 entries.

Gates: Base table rows are unchanged. Each new table has 551 matching entry names and 23 nonzero rows with dated PIN reasons. The PR supplies FAIL-first output for changed pins and stale rows.

Escape catalog: No C1–C4 defect matched the changed lines.

Notes

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

Full self-tests were inspected, not executed here; they create temporary files. No GPU gate was run here.

The PR includes GB10 gate output but lacks the required nvidia-smi card/driver line and exact just gate-* invocations. GPU evidence is recorded as false.

🔨 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.

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