PR #231: Race a Triton tile kernel against cuBLAS for GLM's BF16 head projections

Raw Markdown for agents: https://autobot.eidonix.com/api/v1/cases/d5488165-a2f7-40b2-9c90-8489c629dd20

Opened by a workflow run, Nov 25, 2026 11:31 PM EST.

screen malicious

Screen Result: All Clear

Evidence: No prompt injection, hidden instructions, encoded payloads, or other content aimed at causing unwanted agentic behavior was found in PR #231 ("Race a Triton tile kernel against cuBLAS for GLM's BF16 head projections", head 0ba78eb, author original-el8, 6 files, +373/−16).

Legitimate review concerns, reported as design/process risk rather than security: tuning.py:66 now runs _prepare_compiler_toolchain() (CPU-side ignition.runtime_patches.apply() monkey-patching plus Inductor's _set_triton_libdevice_path) merely on importing ignition.preparation.tuning, i.e. import-time side effects for every importer including test collection; and bf16_bmm.py:108 adds the kernel to b12x's private compile_plan._NATIVE_JITS registry, which the PR limitations disclose. CI on the head commit fails and a comment reports an unresolved merge conflict in ignition/components/linear.py; neither is an injection signal.

The full report repeats this with file/line citations, then lists open questions and what could not be checked.

Full report · Notes decide malicious: all_clear (100%): No malicious content found

explore

Author: Jason Cook (original-el8, COLLABORATOR, charter "priority contributor"; commits authored as "Jason Cook"/jasonc; no Discord handle given) Motivation: GLM-5.3-Flash's MLA query absorption and value expansion run BF16 batched matmuls through BatchedUnquantizedProjection, which called torch.bmm; on GB10 cuBLAS picks a 32x32 WMMA kernel that only reaches about half the device's copy bandwidth. The PR races cuBLAS against a Triton tiled kernel during preparation and keeps whichever is faster on the preparing device. Scale: +373 / −16 lines in 6 files Proposal:

Full report · Notes

Value Proposition

Verdict: worth it with changes — but most of this PR belongs in the other repository

The measured work is real and points at a genuine bottleneck on the hardware the charter names (DGX Spark). What is wrong is not the idea, it is the placement and the evidence. Land the ignition/preparation/tuning.py hunk here (with one fix and one doc update); move the BF16 BMM component, the linear.py wiring and the component tests to local-inference-lab/hyperflare-recipes, as the maintainer triage comment of 2026-11-24 already said.

Why it is worth doing

Why it cannot merge as it stands

  1. Wrong repository for 5 of the 6 files. The repo has been split. main has no ignition/components/linear.py, no ignition/recipes/, and ignition/components/ is restricted to the 14 Helios-ABI modules (AGENTS.md:385-392, enforced by tests/preparation/test_core_boundary.py:11-26,62-64). Adding ignition/components/bf16_bmm.py and editing linear.py fails that test on rebase. docs/model-development.md:276 (not opened) already points UnquantizedProjection at hyperflare_recipes/components/linear.py (not opened). The PR body's own "no package metadata or Helios code changes" confirms none of it is runtime-ABI work.
  2. The served-workload evidence the charter requires (#210) is not in this PR. The only end-to-end figure is 2945 tok/s vs 2620–2631 for packages that also contain other prefill changes, and the PR itself says that difference "is not attributed to this PR alone." My own arithmetic from the microbenchmarks: absorption saves 1.51 ms/layer × 45 layers ≈ 68 ms and expansion 0.60 × 45 ≈ 27 ms, so ≈ 95 ms per 8,192-token prefill pass — about 3.4% of a 2.78 s prefill at 2945 tok/s, and near zero in decode where row counts are tiny and cuBLAS may well win the race anyway. A 3½% prefill win is worth having; it is not worth merging on an unattributed combined-package number.
  3. Coverage holes on the hardware the charter cares about. GB10 tests, the GLM MLA checkpoint test, and SM103 were not run on this branch (PR Limitations). SM103 is named in the charter's goals. The branch is also stale and conflicted (ignition/components/linear.py, reported 2026-11-13 for head 0ba78ebe vs main 97cfeb0), and main's tuning.py has since grown collective_tuning/collective_ladder/tuning_shards that this branch lacks.
  4. The import-time toolchain call may resolve the wrong libdevice — this is the one concrete defect I would block on. In the CLI path the CUDA toolkit location is installed by ignition.cli.environment.apply() from [paths] cuda (ignition/cli/environment.py:36-61, config.py:161-164), called from serve.py:211/322/476/587. But recipe modules that import ignition.preparation.tuning (e.g. ignition/recipes/glm53/bootstrap.py:47 (not opened)) are imported during model resolution, before environment.apply runs. Moving _set_triton_libdevice_path() to import time means the toolkit libdevice can be selected before os.environ["CUDA_HOME"] is set from configuration — the very identity mismatch the change is meant to remove, now possibly permanent. Before merging, confirm the import-time resolution sees the same CUDA_HOME the session would have seen, or split the two concerns: patch install at import, libdevice selection still after environment configuration.
  5. A smaller cost of the same move: runtime_patches.apply() raises PreparationError on a torch/triton version mismatch (ignition/runtime_patches/__init__.py:81-82,103-106). Hundreds of test modules and tools import ignition.preparation.tuning, so that failure now surfaces at import rather than at session construction. The new "import" subprocess mode in tests/preparation/test_toolchain.py:46-49 is the right shape of test; it should be joined by a case proving the CLI path still selects the configured toolkit.
  6. Dead code left behind. flare::bmm_out at PR-head ignition/components/linear.py:89-96 stays defined and registered but has no callers after the rewiring (flare::sm103_bmm_out at line 452 is the one still used). Delete it in the moved version.

Simpler way to the same end

Costs

What would make me say plain "worth merging"

  1. Split as the 2026-11-24 triage directs: this repo keeps only the ignition/preparation/tuning.py change plus tests/preparation/test_toolchain.py; the component, wiring and tests move to a linked hyperflare-recipes PR with the validation evidence carried over.
  2. Fix the CUDA_HOME ordering in the tuning.py change and add a test that the CLI configuration path still selects the toolkit libdevice; update docs/TODO.txt:185-187 rather than leaving the fixed defect listed as open.
  3. Re-run the affected checks after rebasing onto main (the branch is conflicted and behind on collective_tuning/tuning_shards) and record GB10, RTX PRO 6000 and SM103 results on the rebased branch, not on the integration branch.
  4. Add one served-workload measurement that isolates this change — same checkpoint, same package, this component on vs off — through an exported core per docs/performance-work.md, replacing the unattributed 2945 vs 2620–2631 comparison.

Full report · Notes Decide Value: yes (85%): This change is worth reviewing: it provides value to the project in line with its charter.

Simplicity

Verdict: should-fix issues only

Blocking:

Should fix:

Nits: 2 — tests/components/test_bf16_bmm.py:21-33 restates the _TILES table and its filter expression instead of a behaviour; bf16_bmm.py:156-162 exposes prepared_state for one test caller (siblings inline the materializer as a closure), and linear.py:70-74 uses the package's only Sphinx :mod: role in a docstring.

Link: https://github.com/NVIDIA/hyperflare-inference/pull/231

Full report · Notes

Architecture

Verdict: blocking issues

Blocking:

Should fix:

Nits: 2

Link: https://github.com/NVIDIA/hyperflare-inference/pull/231

Detail: the blocking finding is corroborated three ways — tests/preparation/test_core_boundary.py:11-26,62-64 asserts ignition/components/ holds exactly the 13 Helios-ABI modules (main does; the PR head has ~100, including bf16_bmm.py and linear.py), and docs/model-development.md:276 already points UnquantizedProjection at hyperflare_recipes/components/linear.py (not opened). docs/design-review.md:125-136 forbids waiving the boundary for a performance gain. The second finding rests on reading tuning.py:47-66 against environment.py:36-61 and runtime_patches' version guards; what would settle its severity is a test that imports a component module with non-default CUDA_HOME/TRITON_CACHE_DIR and checks the resulting cache location. Cleared through this lens: scratch-free plans, native_plan/native_contract use, stride/alignment rejection, mutates_args and fake registration, the declared FP32-accumulate/single-rounding numeric contract, and the PR description's separation of measured vs unattributed results. Not investigated: the CI failure on head 0ba78eb, and kernel-quality questions, which the charter reserves for concrete defects only (none found).

Full report · Notes

Conventions

Verdict: should-fix issues only

Blocking:

Should fix:

Nits: 3 — bare-string "cublas" tactic vs uniform tuple tactics in every sibling contract (bf16_bmm.py:57,158,172,117); _NATIVE_JITS mutated inside compile_bmm (bf16_bmm.py:108) via from b12x._lib import compile_plan (line 26) instead of at module scope with a named import (moe_sm103.py:31 (not opened),357,387; sm103_projection.py:33,258); CUDA test helpers re-derive glm_stacks()/the double-precision reference already in tests/components/test_bf16_bmm.py:13-18 and tests/recipes/test_glm53_bmm_cuda.py:84-86.

Link: https://github.com/NVIDIA/hyperflare-inference/pull/231

Full report · Notes

Prose

Verdict: should-fix issues only

Blocking:

Should fix:

Nits: 3 — "forward math libraries" is an unexplained identifier in the tuning.py:48 docstring; the bf16_bmm.py:16-17 claim that RTX PRO 6000 reaches "near its byte floor" has no measurement in the PR description (its tables are GB10 only); a stray print of the selected tactic is left in tests/components/test_bf16_bmm_cuda.py:96.

Link: https://github.com/NVIDIA/hyperflare-inference/pull/231

Full report · Notes

Correctness

Verdict: should-fix issues only

Blocking:

Should fix:

Nits: 2 — the now-dead flare::bmm_out custom op (linear.py:89-96), and the diagnosability change from preparing the compiler toolchain at import (tuning.py:66), where a torch/triton version mismatch now surfaces as a PreparationError raised by importing ignition.components.linear rather than by constructing a session. Link: https://github.com/NVIDIA/hyperflare-inference/pull/231

Full report · Notes

Subtractive

Verdict: make it smaller first The change: +373 / −16 lines Could remove: about 349 lines in 1 place (the other-repository scope); a further ~22 lines in 4 places if the component stays here Biggest subtractions:

Full report · Notes

Pre Test Report

Pre-test report — PR #231 "Race a Triton tile kernel against cuBLAS for GLM's BF16 head projections"

Recommendation: DO NOT refer to hardware testing yet. Return to author.

Reason: the change cannot land in its current shape. Four of its six files are out of scope on main after the repository split, one of the two runtime hunks must be re-resolved against a tuning.py that has moved, and several concrete defects (dead custom op, conditional kernel registration, an untested ordering regression in a process-wide side effect) have to be fixed first. Any GPU time spent on 0ba78eb would be spent on code that will be rewritten, rehomed and rebased. A minimal, conditional hardware plan is supplied at the end for when the blockers clear.

1. Verified state of the PR against main

Check Result
ignition/components/*.py on main exactly __init__.py (not opened) + 13 modules (capacity, collectives, completion, engram, flashinfer_sampling, logprobs, ngram_delivery, readiness, sampling, state, state_transfer, vision_delivery, vision_state). No linear.py (not opened), no bf16_bmm.py.
ignition/recipes on main does not exist (verified: list_files ignition/recipes → no files). tests/preparation/test_core_boundary.py:40-48 asserts it must not exist.
tests/preparation/test_core_boundary.py:62-64 (main) assert actual == RETAINED_IGNITION_COMPONENTS — exact set equality. Adding bf16_bmm.py fails this test.
AGENTS.md:385-392 (main) "Keep ignition/components/ limited to the 13 Helios-ABI runtime interface modules… Put reusable b12x/Triton model execution mechanisms in hyperflare_recipes/components/."
PR head 0ba78eb 18 days old, predates the split; author reports an unresolved conflict in ignition/components/linear.py (not opened); head CI red.
Author's own triage comment (2026-11-24) Concedes only the ignition/preparation/tuning.py change can remain in this repository.

Blocking items confirmed, not merely review opinion:

  1. Out of repository scope. ignition/components/bf16_bmm.py (+184, new), ignition/components/linear.py (not opened) (+8/−9, file deleted on main), tests/components/test_bf16_bmm.py (not opened) (+44), tests/components/test_bf16_bmm_cuda.py (+122) — 349 of 373 added lines — belong in local-inference-lab/hyperflare-recipes. docs/design-review.md (not opened) principle 15 explicitly forbids waiving the boundary for a performance gain. Merging fails test_core_boundary.py outright.
  2. The motivating caller no longer exists. The only in-repo user of BatchedUnquantizedProjection was ignition/recipes/glm53/mla.py (not opened), which main has removed. On main this PR has zero in-repo behavioural effect on served workloads.
  3. Needs a maintainer placement decision, not just a rebase. Whether a raced BF16 batched matmul is a shared b12x-level mechanism or a recipe component is unanswered in the PR (reviewers flag b12x.gemm.plan_bmm/bmm already used by the MXFP8 sibling as a cheaper alternative). Testing cannot settle that.
  4. tuning.py hunks must be re-resolved. main's tuning.py is 829 lines with _prepare_compiler_toolchain at 53-66, the call in __init__ at 108, and declare at 799 (call at 804). The PR's deleted hunk lands at different offsets after rebase; the change must be re-reviewed, not assumed mechanical.

2. Substantive defects that must be fixed before any test run

S1 — import-time toolchain preparation inverts the documented ordering (runtime half, high risk). The PR adds a bare _prepare_compiler_toolchain() at ignition/preparation/tuning.py:66, running runtime_patches.apply() and Inductor's _set_triton_libdevice_path() at import of a module ~45 component modules, the fixtures, and every recipe bootstrap import (verified by search). ignition/cli/environment.py:5-11,36-61 documents and implements the opposite order: it sets TRITON_CACHE_DIR (line 47) and CUDA_HOME (line 54) before runtime_patches.apply() (line 61). ignition/cli/serve.py:14 imports ignition.planning at module scope, and every environment.apply(...) call is inside a function (serve.py:211/322/476/587), so the toolchain preparation now runs before the configured environment exists. Consequences:

S2 — dead custom op. ignition/components/linear.py:89-96 (not opened): the PR deletes the only caller of flare::bmm_out and leaves the op plus its fake registered. Repo-wide search for bmm_out returns only this pair and the unrelated, still-used flare::sm103_bmm_out (linear.py:452 (not opened),463-469). Dead public operator surface; delete in whichever repository the file ends up in.

S3 — conditional kernel registration. ignition/components/bf16_bmm.py:108 adds _bmm_kernel to b12x's private compile_plan._NATIVE_JITS inside the @program_cache-decorated compile_bmm (line 99), so registration happens only on a program-cache miss. The sibling components register unconditionally at module scope (sm103_projection.py:258 (not opened), moe_sm103.py:357 (not opened)/387 per reviewers). The comment at bf16_bmm.py:105-107 states a requirement that the placement only half-satisfies; the fix is a two-line move and is strictly safer.

S4 — new rejection of layouts torch.bmm accepted. query_from_call (bf16_bmm.py:142-153) now refuses non-16-byte-aligned bases, non-contiguous source/output rows, and weights contiguous in neither K nor N. That is correct for the Triton tile, but it is a behavioural regression for any existing caller and directly collides with open PR #471, which rewrites the same class with the opposite (staging copy) policy. This must be resolved as a decision before the component is rehomed.

Lower-severity, fix while touching the code (not worth their own test cycle): bf16_bmm.py:174 omits session=session, so fixtures/resources.py:30-33 never releases the session's benchmark cache before the race allocates (memory spike only — the owners tuple keeps storage alive, so no correctness break); bf16_bmm.py:176-179 hand-rolls the PreparedCall that fixtures/bf16_gemv.py:10-16 (not opened) already provides; bf16_bmm.py:120-123 re-validates shapes/strides on every captured replay when query_from_call already enforced them (hot-path cost, and inconsistent with siblings); the module docstring at bf16_bmm.py:7-9 and the PR description claim FP32 accumulation with one BF16 rounding as the operator invariant while the champion tactic is torch.bmm (reduced-precision BF16 reduction may be enabled by default); docs/TODO.txt:185-187 on the head records exactly the libdevice failure class this change addresses and is neither updated nor closed; a stray print at test_bf16_bmm_cuda.py:92.

Not defects: kernel code (charter permits concrete defects only — none found), tactic filtering matches the unmasked loads, scratch_bytes=0 holds for both tactics, the mutating-op + fake registration follows house pattern, and the relocated stride/dtype validation is not weakened.

3. Expected value of a hardware test right now: low

4. Minimal hardware plan — run only after blockers clear

Execute once, after (a) the split is done — component in hyperflare-recipes, runtime change rebased onto main — and (b) S1-S4, the session= omission and the docstring claim are fixed. Budget ~1.5 GPU-hours total; nothing here is worth repeating per-architecture "just in case".

Stage 0 — CPU only, no GPU allocation (gate).

  1. Rebase check: pytest tests/preparation/test_core_boundary.py green on the rebased runtime branch.
  2. Extended toolchain test (the missing one): subprocess that imports ignition.preparation.tuning (and one component module) with CUDA_HOME/TRITON_CACHE_DIR unset, then calls ignition.cli.environment.apply(...) with a configuration whose [paths] cuda is a non-default directory; assert (i) the libdevice recorded in CUDAOptions().extern_libs equals Path(cuda)/"nvvm/libdevice/libdevice.10.bc" after apply, (ii) CUDAOptions().hash() equality with the post-switch identity, (iii) not torch.cuda.is_initialized(), (iv) the version-mismatch path raises at the documented point. Run against main (A) and the PR (B).
    • This is the only change that touches every entry point; if it fails, stop — no GPU time.

Stage 1 — kernel correctness on cn7 GB10 (1 × GB10). Run the two CUDA test files once: tests/components/test_bf16_bmm_cuda.py (≤1 BF16 ulp vs torch.bmm for every tactic, row-tail NaN masking, raced selection, captured-graph replay with zero allocation) and the CPU selection tests. Compare A/B only in the sense that A = the same tests against the pre-PR torch.bmm path. Expected: 5 tests pass, allocation counters unchanged across replay.

Stage 2 — A/B throughput on cn7 GB10 (the one measurement that matters). Same checkpoint, same package, projection wired to (A) plain torch.bmm and (B) the raced component, one exported core, the two GLM head-projection geometries the PR cites (8,192-row absorption n-major, 8,192-row expansion k-major), plus a decode-shaped run (~32 rows) to confirm the race does not pick a slower tactic where cuBLAS wins. Record selected tactic per geometry, ms per operator against the plain-copy byte floor, and one end-to-end prefill tok/s pair. Three repetitions, take the median; report the copy floor in the same table. Do not re-measure the other five tile shapes — the race already covers selection.

Stage 3 — cn5 (4 × RTX PRO 6000 / SM120), only if Stage 2 shows the race selecting a non-cuBLAS tactic on GB10. One run of the same CUDA test file plus the Stage-2 geometry table on one card. Skip entirely if the PR description's SM120 claim is replaced by a measurement in the rehomed PR.

Explicitly out of scope for testing: the _TILES table contents, the kernel body, and docstring/prose fixes; SM103 (not covered by this component and named only as an unrun check); TP2/TP4 multi-GPU projections (cn7 has one GPU, and the operator is per-rank).

5. What would change this recommendation

Refer to a test engineer if the author instead splits the PR now and the runtime-only PR (the tuning.py change + test_toolchain.py) arrives rebased with S1 fixed and its ordering test included — that PR is 2 files and is validated by Stage 0 only (no GPU allocation), so it can be verified in minutes. The recipe-repository PR becomes a separate, ordinary review with Stages 1-2 attached.

Full report · Notes

code review summary

Recommendation: Changes Requested

Thanks — the kernel and the prepared-operator shape are clean: the race is expressed as one declared contract, there is no duplicate kernel, no per-model branch, no fallback flag, and I found no concrete defect in _bmm_kernel. Not ready to merge because of placement, not code quality. Full evidence is in the case file.

Blockers:

Should fix:

Subtract / Simplify:

Could remove ~30 of +373 added lines (and ~349 leave the repo with the split):

Nits:

4 nits

Full report · Notes Decision to Test: no (100%): Testing will not add significant value as the code stands today. The code is either not yet ready to merge, or adequate testing has already been done to validate the contents of the code, or the available hardware is not suitable to test with.