Skip to content

gguf, placement, gpu: a type's card columns in its QROWS row, read by every card operation and layout - #588

Merged
juliankang4 merged 7 commits into
midagedev:mainfrom
juliankang4:dgx-spark-card-type-table
Oct 21, 2026
Merged

juliankang4 merged 7 commits into
midagedev:mainfrom
juliankang4:dgx-spark-card-type-table

Conversation

@juliankang4

@juliankang4 juliankang4 commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

카드 커널 표를 타입별 QROWS 행의 열로 옮겨, 호스트와 카드가 한 행을 읽도록 합니다. 동작은 바뀌지 않습니다.

Follows #570, its card type table item, and #565 round 1.

What and why

This PR puts each type's card-side facts in that type's row of QROWS (crates/gguf/src/qtype.rs), the direction the maintainer suggested in #565. A type now has one row for its host path and its card path. Behavior stays the same: the card kernel choices, layouts and admission answers stay the same, and one test pin moves for IQ2_XXS (see "What I ran into"). It makes no speed claim.

Before, the card facts lived in several matches over GgmlType: six in placement/src/kernels.rs, the CardFormat constructors and its holds list, and seven copies in gpu (site.rs, qwen3moe/body.rs, gemm/grouped.rs, card_leg.rs, head.rs, iq.rs, quant_sel.rs). Adding a type meant finding and editing every one of them.

Now a row carries a Card value with eight columns: layout, routed, gate_up, down, gemm, dense, head and embed. The operations in placement::kernels read ty.card().<column>, so their names and signatures stay as they were. The gpu copies read those same functions.

Release notes: Under the hood: the card kernel table is a column set on the QROWS rows, and the per-type matches in placement and gpu read it.

Code shape

  • No second copy. QROWS is the one owner of a type's card columns. The gpu copies of the table now read placement::kernels. SiteTy::entry() is the one map from a site type to its entry.
  • Model code holds only architecture facts. No model file gained a branch. qwen3moe/body.rs lost its site_ty and ggml_ty helpers.
  • Dead code is gone. IqFormat::of had no caller and is removed. The placement card_types! table from the earlier design is not part of this PR.
  • No silent failure. A row without a card column does not compile, because QRow has no Default. Two rows naming one dense entry, or no row naming one, fail the build. GemmWeight::from_ggml and head_out_w still reject unsupported types by name.
  • Comments state what is true now.
  • No relaxed gate. One pin changed: gemm_admits_exactly_the_pinned_pairs gained the IQ2_XXS row, with a PIN(2026-10-21) line and the reason.
  • cargo fmt and cargo clippy are clean on what I touched; the lint count did not go up. I did not run just lint here, so the clippy count is unchecked.

Duplication found or removed (path:line): the per-type matches in crates/placement/src/kernels.rs, CardFormat::of, of_routed and holds (now crates/gguf/src/card.rs), and the gpu copies in crates/gpu/src/site.rs, crates/gpu/src/arch/qwen3moe/body.rs, crates/gpu/src/gemm/grouped.rs, crates/gpu/src/card_leg.rs, crates/gpu/src/head.rs and crates/gpu/src/quant_sel.rs.

What changed

  1. crates/gguf/src/card.rs (new): the Card column type, Card::NONE, the card! row macro and GgmlType::card(). The entry enums (GateUpEntry, DownEntry, DownAct, GemmEntry, SiteEntry, SiteAct, HeadEntry, EmbedEntry) and CardFormat moved here from placement, because QROWS is in gguf, a crate below placement, and Rust does not allow an inherent impl on another crate's type. placement::kernels re-exports the enums, so existing paths still work. SiteEntry::ty answers from a const table in constant time, and the build refuses a table where two rows or no row name a dense entry.

  2. crates/gguf/src/qtype.rs: QRow has a card field. All 39 rows set it.

  3. crates/placement/src/kernels.rs and placement.rs: the operations read the row. CardFormat::of_role stays in placement as card_format_of_role(ty, role) because Role lives in the models crate.

  4. crates/gpu/src/* (commit 2): site.rs, qwen3moe/body.rs, gemm/grouped.rs, card_leg.rs, head.rs, iq.rs and quant_sel.rs read the table. In quant_sel.rs a const assert per line ties its gate/up and down entries to the type's columns.

  5. docs/contrib/new-model.md and tools/gate-paths.tsv: the "Kernel table" row points at the QROWS columns, and crates/gguf/src/card.rs has a gate path row.

  6. crates/gpu/src/site.rs (tests only): the separate Q5_0, NVFP4 and MXFP8 site pin tests are folded into every_family_is_the_tables_dense_row_of_one_type, with a PIN(2026-10-21) line. All 21 assertions of the old tests are kept. I broke the product behavior behind each one in turn, 21 mutants, and the merged test failed on every one.

SiteTy::kgemv_order stays an exhaustive match. Whether the kgemv launcher reads rows or tokens is a launcher fact, not a card column, and a _ arm would let a new type default silently. A test ties its answer to the table's activation column.

What I ran

The commands in this section ran on one machine at the earlier head 67e660d62c4d596a032069b4e8b86cfa8838c13e, base a0f1b62fbd6dcb72bf7ff603e29a801f3651c53c. The site pin merge and the GPU gate in "GPU Evidence" ran at head 79bdeb50834c43b690ea83cb93b4f70ec480ff16.

nvidia-smi --query-gpu=name,driver_version --format=csv,noheader
# NVIDIA GeForce RTX 5090, 595.99.02
cargo check --workspace --all-targets --features <the `just check` feature list>
# rc=0
cargo test --release -p bloomery-gguf --lib
# test result: ok. 42 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
cargo test --release -p bloomery-placement --lib
# test result: ok. 164 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
cargo test --release -p bloomery-model --test placement
# test result: ok. 6 passed; 0 failed; 5 ignored; 0 measured; 0 filtered out
bash tools/gate.sh --oxide -p bloomery-gpu --release --lib
# test result: ok. 262 passed; 0 failed; 67 ignored; 0 measured; 0 filtered out
bash tools/gate.sh --oxide -p bloomery-gpu --release --lib -- --include-ignored card_leg::tests::hw_a_stack_routes_by_the_tables_gemm_entry
# test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 328 filtered out
cargo test --release -p bloomery-model --lib
# test result: ok. 422 passed; 0 failed; 5 ignored; 0 measured; 0 filtered out

BLOOMERY_ARCH was unset, so the build targeted sm_86.

Behavior is unchanged where it matters for the card's kernels: BLOOMERY_BOX_LOCAL=1 bash tools/canon-check.sh a0f1b62fb reports

canon-check: 3 bins, 972 entries: 972 identical, 0 reordered-only, 0 differs, 0 only-on-one-side; rows equal (jit columns not compared: no-jit both)

Two pin tests, the_card_layouts_are_the_pinned_pairs and each_layout_holds_exactly_the_pinned_types, already held on the base code before the change and still hold on the head. They show that the planner's inputs (CardFormat::of, of_routed, holds, buffer_bytes, kernels::*) answer the same for every GgmlType and for an unknown tag. I did not dump a plan per fixture to compare bytes.

I also planted nine mutants, one at a time, and restored the tree after each. Each one makes a test or the build fail: a wrong routed column for Q5_K, a deleted holds line, the IQ2_XXS gemm column removed, two rows sharing a dense entry, a dense entry no row names, a row without a card column, a deleted IQ2_XS gate/up column (the quant_sel.rs assert), a wrong SiteTy::Q4K entry, and GemmEntry::Iq2xxs mapped to None (the card hardware test above catches it).

Not run: just lint (clippy), check-comments, and the other workstation gates. tools/owners_check.py check reports 7 findings, and the base reports the same 7. On a second machine with fewer than 8 hardware threads, two ccd tests in bloomery-model --lib fail on the base and on the head alike.

GPU Evidence

The card is an RTX 5090. nvidia-smi on that machine, before the run, reports:

| 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 |
|   0  NVIDIA GeForce RTX 5090        Off |   00000000:01:00.0 Off |                  N/A |

The gate that covers the card table's consumers (MXFP8, FP8_B128, Q8_0 and F32 loads and site runs on synthetic tensors) ran at head 79bdeb50834c43b690ea83cb93b4f70ec480ff16:

BLOOMERY_BOX_LOCAL=1 just gate-gpu-mxfp8
gpu-gate.sh: gate_mxfp8 ran 11 s (exit 0)

The output has 236 PASS lines and no FAIL line.

Hardware (if the change is for a machine)

NVIDIA GeForce RTX 5090, driver 595.99.02, Linux, sm_86 build (BLOOMERY_ARCH unset). The card checks above ran there. No timing was measured.

What I ran into

This does not block the PR. The IQ2_XXS gemm row exists to keep the old behavior. Before this PR, GemmWeight::from_ggml accepted IQ2_XXS, and the NemotronH prefill path calls it. Once from_ggml reads the table, a missing IQ2_XXS row would change that answer, so the row stays. The other kernels::gemm callers answer the same for IQ2_XXS, because accepts.rs also needs gate/up and down entries, which IQ2_XXS does not have, and the shared leg's card_gate_up_runs(IQ2_XXS) is false. The only test change is IQ2_XXS moving to the grouped-path list in card_leg.rs and in the gemm_admits_exactly_the_pinned_pairs pin.

This PR does not move the GLM tile match in ffn.rs or the leg columns. The line count is nearly flat across the 17 changed files, because the moved docs and the CardFormat arithmetic make up most of it, so I do not claim a smaller change.

AI help

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

…y card operation and layout

The card operations (gate_up, down, gemm, dense, head, embed) and
CardFormat::of and of_routed each held their own exhaustive match over
GgmlType, so a new type was decided in eight places. Each type's QRow now
carries its card columns (gguf::card::Card): its card layout, its routed
layout and its entry in each operation, written beside the row's other
facts by card!. QRow has no Default, so a row without its card columns
does not compile. placement::kernels reads the columns by operation, and
CardFormat::holds takes the file's blocks for the types whose routed
gate·up or down entry reads them (GateUpEntry::layout, DownEntry::layout)
in place of its own list. SiteEntry::ty gives a dense entry's file type
from the row that names it, and the build refuses a dense entry that no
row or two rows name.

The column types move to gguf::card with the rows that hold them: the
entry enums, which placement::kernels re-exports, and CardFormat with its
byte arithmetic, which placement re-exports. CardFormat::of_role reads a
placement Role, so it stays in placement as card_format_of_role.

The GEMM column gains IQ2_XXS (gemm_iq2xxs): GemmWeight::from_ggml decodes
it and the latent MoE body launches it, but its row had no GEMM entry. The
card leg's route test moves IQ2_XXS's words to the grouped routes. Every
other pinned pair is unchanged; two new pins hold the card and routed
layouts, and the types each layout holds, to what the matches gave.
SiteTy kept its own type list in of_ggml, gemm_weight, reads and Display,
and the qwen3moe body a second pair of maps (site_ty, ggml_ty). The family
now maps to its dense entry once (SiteTy::entry); of_ggml reads
kernels::dense, SiteTy::ggml the file type of the row that names the
entry, gemm_weight the row's GEMM entry, and Display the file type's name.
site_ty and ggml_ty are gone, their callers on SiteTy::of_entry and
SiteTy::ggml. GemmWeight::from_ggml and the card leg's route read the GEMM
entry through GemmWeight::of_entry, and the lm_head picks its gemv by
kernels::head. The quant_sel invocation keeps its lines, which name its PTX
entries, and a const assert per line holds its gate·up and down entries to
the row of its type. IqFormat::of, which no caller used, is gone.

No launch changes: every entry is chosen as before, which the site test
pins over every type (family, file type, name, GEMM and kgemv layout).
@github-actions github-actions Bot added documentation Improvements or additions to documentation gpu The card engine: crates/gpu*, crates/app model The CPU engine and model files: crates/model, models, hf, gguf, tokenizer, jinja needs-gpu Changes code a card must check, and carries no gate run on a card placement Placement planning: crates/placement tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo labels Oct 21, 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 finding remains; the move proof needs an update.

Non-blocking

⚠ Refresh the move proof: crates/gpu/src/site.rs:172 replaces the GEMM dispatch match with table lookups used by site::gemm.
The reported canon-check uses earlier commits. Attach just canon-check ea128adff06f352c445e27ed05ef46df15235878 at the current head, plus graph node counts, eager/replay equality, and e2e set equality required by the move class in AGENTS.md.

Checked

Duplicates: Both dryer pairs compare labels from different domains and share only a match shape.
Complexity: Diagnostics report 22 for CardFormat::buffer_bytes; its definition is identical to the base.
Silent failure: Site admission refuses unsupported types; constant evaluation rejects missing or duplicate dense entries.
Tests: The site test asserts family/type mappings, labels, GEMM weights, and activation/layout relationships. Mutation results were not independently rerun.
Gates: The IQ2_XXS GEMM pin and merged site pins have dated reasons.
Escape catalog: C1–C4 do not match the retained finding.

Notes

Validation used source inspection and a definition comparison. Rust builds, hardware gates, and Python mutation checks were not run during validation.

Card check: gpu-evidence. This pull request changes crates/gpu-gates/src/act_rule.rs, crates/gpu-gates/src/bin/gate_deepseek41_chain_glue.rs, crates/gpu/src/arch/qwen3moe/body.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 Oct 21, 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

documentation Improvements or additions to documentation 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 model The CPU engine and model files: crates/model, models, hf, gguf, tokenizer, jinja placement Placement planning: crates/placement 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