Review of PR #231 — "Race a Triton tile kernel against cuBLAS for GLM's BF16 head projections"
Lens: Architecture and scope — does this belong in the repository, and is the approach right, judged against the charter, the rejection criteria, and the design principles as the repository states them. I did not review kernel quality (the charter, AGENTS.md:470-482, restricts GPU-kernel review to concrete defects, and I found none) or the throughput attribution question.
Rules I judged against: the project charter (read_charter), AGENTS.md (scope at lines 385-392 on main; contribution scope and rejection criteria at 155-212), docs/design-review.md (principles 3, 4, 15, 16), docs/model-development.md, docs/preparation-development.md, and tests/preparation/test_core_boundary.py.
Key findings
- Blocking — five of six changed files are recipe-repository code.
ignition/components/bf16_bmm.py(new, 184 lines), theBatchedUnquantizedProjectionrewrite inignition/components/linear.py:69-86, and both component test files implement a reusable BF16 projection block. The repository rules put that inhyperflare_recipes/components/and reserveignition/components/for Helios-ABI runtime interface modules. The PR's own triage comment states the same split and says only the toolchain change may remain here. - Should fix — the compiler-toolchain preparation now runs at module import of
ignition.preparation.tuning.tuning.py:66replaces the two former call sites (removed fromRecordedPreparationSession.__init__anddeclare()), so importing any of the ~60 modules that importignition.preparation.tuninginstalls runtime patches and imports torch/Triton beforeignition.cli.environment.apply()has set the cache and CUDA environment.
Everything else I checked through this lens is consistent with existing component patterns; the cleared items are listed at the end.
Blocking: the BF16 BMM component and its projection wiring belong in hyperflare_recipes, not this runtime repository
Where: ignition/components/bf16_bmm.py (whole new file), ignition/components/linear.py:69-86 (BatchedUnquantizedProjection), tests/components/test_bf16_bmm.py (new), tests/components/test_bf16_bmm_cuda.py (new).
What the rules say.
AGENTS.md:385-392(main): "Keepignition/components/in this repository limited to the 13 Helios-ABI runtime interface modules (capacity,collectives,completion,engram,flashinfer_sampling,logprobs,ngram_delivery,readiness,sampling,state,state_transfer,vision_delivery,vision_state), enforced bytests/preparation/test_core_boundary.py. Put reusable b12x/Triton model execution mechanisms inhyperflare_recipes/components/inlocal-inference-lab/hyperflare-recipes."AGENTS.md:9-13(main): "Official model recipes, reusable b12x model components, operator-tuning fixtures, numerical references, qualification drivers, and model test suites live in [local-inference-lab/hyperflare-recipes]."docs/design-review.md:31-37(principle 3,main): "Recipes (inlocal-inference-lab/hyperflare-recipesor external recipe repositories) own model composition and checkpoint mapping. Reusable projections, experts, collectives, and model execution blocks belong inhyperflare_recipes/components/; Helios-ABI runtime interface components belong inignition/components/." (The PR-branch copy of the same paragraph atdocs/design-review.md:30-33is the pre-split wording that still saysignition/components/; the head is on a stale base.)tests/preparation/test_core_boundary.py:11-26,62-64(main) asserts the exact set of 13 module stems inignition/components/.
What the code does. bf16_bmm.py:5-19 describes a general prepared BF16 batched matmul over caller-owned strided stacks, with two tactics (torch.bmm via flare::bf16_bmm, and a Triton tile), declared through native_plan/native_contract (bf16_bmm.py:36, and the plan/contract block below line 40). linear.py:69-86 rewires BatchedUnquantizedProjection to declare and execute that plan. Both are model execution mechanisms with no Helios ABI surface — not one of the 13 retained modules.
Corroborating evidence that this is not a judgement call:
- The PR's own triage comment (original-el8, 2026-11-24): "Repository-split triage: … [hyperflare-recipes]: the BF16 batched-matmul implementation, projection wiring, and component tests. This runtime repository: the compiler-toolchain initialization change in
ignition/preparation/tuning.py. … The runtime portion can remain here after removing recipe-owned files." ignition/components/linear.pydoes not exist onmain:list_files ignition/components/*.pyatmainreturns 13 modules plus__init__.py; at the PR head it returns ~100, includingbf16_bmm.pyandlinear.py, because the head predates the split. The author's own comment of 2026-11-13 reportsgit merge-treeconflicts withmainfor exactlyignition/components/linear.py.docs/model-development.md:276(main) already directsUnquantizedProjectiontohyperflare_recipes/components/linear.py(not opened), so projection components are documented as living in the recipe repository.
Why it matters. docs/design-review.md:125-136 (principle 15) forbids waiving this: "Feature requests, performance gains, passing tests, flags, and temporary paths cannot waive architectural invariants … Do not make a violating contribution acceptable by weakening its governing rule." Merging a new ignition/components/ module would also break test_core_boundary.py::test_ignition_components_keeps_only_helios_abi_modules on main, and the file it edits no longer exists there.
Fix. Split the PR: keep ignition/preparation/tuning.py plus the corresponding tests/preparation/test_toolchain.py coverage here (a runtime change to the preparation library, which is in scope), and open a linked PR against local-inference-lab/hyperflare-recipes carrying bf16_bmm.py, the BatchedUnquantizedProjection change, and the two component tests with their validation evidence. If there is an argument that this operator is a shared mechanism the runtime should own, it needs an explicit maintainer decision recorded on the design (AGENTS.md:201-206), not a silent placement.
Should fix: toolchain preparation moved to import time of ignition.preparation.tuning
Where: ignition/preparation/tuning.py:47-66 — _prepare_compiler_toolchain() is now called at module scope (line 66), replacing the call deleted from RecordedPreparationSession.__init__ and the one deleted from declare() (see the diff hunks at the former lines 112 and 735).
What the code does. _prepare_compiler_toolchain() imports ignition.runtime_patches and calls runtime_patches.apply() (tuning.py:49-51), then imports torch._inductor.config and torch._inductor.runtime.compile_tasks._set_triton_libdevice_path (52-53) and switches the libdevice path under config.patch(emulate_precision_casts=...) (62-63). runtime_patches.apply() imports triton (ignition/runtime_patches/__init__.py apply_triton) and raises PreparationError when torch/triton versions do not match the pinned ones.
Why it matters.
- Ordering inversion.
ignition/cli/environment.py:5-11documents the required order: "PyTorch, b12x, Triton, and the CuTe DSL read these variables when they are imported or first used.applysets the environment before installing runtime patches."environment.apply()(environment.py:36-61) setsTORCH_CUSTOM_PYTHONPATH,CUDA_VISIBLE_DEVICES,B12X_COMPILE_CACHE_DIR,FLASHINFER_WORKSPACE_BASE,TRITON_CACHE_DIR,TORCHINDUCTOR_CACHE_DIR,CUDA_HOMEand only then callsruntime_patches.apply(). After this PR, any module that importsignition.preparation.tuningat module scope performs the patch installation and the Triton import first. The import graph makes that broad: 48ignition/components/*.pymodules import it directly, plusignition/preparation/fixtures/*,ignition/preparation/startup_tuning.py:197(not opened),ignition/planning.py:18and every recipe bootstrap. Whether a given entry point (e.g.ignition/cli/serve.pyimporting a recipe beforeenvironment.apply) actually triggers it depends on import order; the risk that a cache directory orCUDA_HOMEis frozen before configuration is applied is real and is exactly what environment.py's docstring warns about. - Failure timing. A torch/triton mismatch that previously surfaced when a session was constructed or a declaration prepared now surfaces as
ImportError-timePreparationErroronimport ignition.preparation.tuning, which also breaks test collection and any tooling that only wants to read declarations or types.
Fix direction. Keep the ordering owner where it already is: leave the call in RecordedPreparationSession.__init__ and declare(), and additionally prepare the toolchain at the one place that compiles Triton programs before a session exists — the component's own compile entry point (for this PR, that means the recipe-repo component), or make _prepare_compiler_toolchain() idempotent and expose it for those callers. A module-level side effect in a widely imported preparation module is the wrong lever regardless of where the component lives.
What would settle the severity. A test that imports a component module in a subprocess with non-default CUDA_HOME/TRITON_CACHE_DIR (as tests/preparation/test_toolchain.py already does for the "import" case added in this PR) and asserts the resulting Triton/Inductor cache location and that the configured CUDA_HOME wins. The added "import" parametrization only checks the libdevice identity, not the environment ordering.
Nits
- Stale branch makes the review partly about history, not design. The head (
0ba78eb) is 18 days old and predates both the repository split and the removal ofignition/components/linear.pyfrommain; CI on the head failed (not investigated by me). Rebase before the split is done, or the blocking finding will be resolved by conflict rather than by decision. - PR description vs. required explanation scheme.
docs/design-review.md:137-145(principle 16) requires why/why-this-approach, what changed, claimed benefit, and supporting evidence, with expected vs measured distinguished. The description does this well and explicitly disclaims attributing the 2945 vs 2620-2631 tok/s prefill result to this PR alone — worth keeping that wording when the PR is split, since only the SM120 and GB10 component numbers (3.53→2.02 ms TP2 absorption, etc.) belong in the recipe-repo half.
Checked and cleared (no finding)
bf16_bmmdeclares throughnative_plan/native_contractand reportsscratch_bytes = 0; the cuBLAS tactic runstorch.bmm(..., out=)inState.runand allocates no scratch — consistent with the no-steady-state-allocation rule.query_from_callrejects non-3D/dtype/device mismatches, non-contiguous rows, and non-16-byte-aligned bases;State.runre-validates shapes and strides.- The custom op
flare::bf16_bmmdeclaresmutates_args=("output",)and registers a fake, matching existing patterns (e.g.flare::sm103_dense_outinlinear.py). - The declared numerical contract (FP32 accumulate, one BF16 rounding, one-ulp tolerance in the CUDA test, NaN sentinels past
rows) is stated and tested; no silent requantization or weakened bounds. - No per-model branching, boolean policy flags, or
ignition→hyperflare_recipesimport is introduced here; the component is model-agnostic despite the GLM motivation, so principle 3's anti-special-case clause is satisfied in kind — it is only the placement that violates it.
Open questions
- Is the intended home for a raced cuBLAS/Triton BF16 batched matmul
hyperflare_recipes/components/only, or does the maintainer want a shared b12x-level replacement so every recipe benefits? That decision changes whether this PR is two changes or three. - Does
b12xalready offer a raced dense/BF16 batched matmul tactic (the triage comment asks reviewers to check "existing b12x alternatives")? I foundignition/components/sm103_projection.py:38(not opened) usingb12x.preparation.tuningknobs, which suggests the race could be expressed as a b12x tactic rather than a newignition/componentsmodule — unresolved, and it is the strongest argument for moving rather than keeping the code. - Not verified: whether any current entry point imports a recipe (and therefore
ignition.preparation.tuning) beforeignition.cli.environment.apply(). If none does today, finding 2 is latent rather than active — the test proposed above decides it.