Architecture report · NVIDIA/hyperflare-inference #231

Raw Markdown for agents: https://autobot.eidonix.com/p/11e89e14-f72f-4dae-9dec-cad9ecba8463.md

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

  1. Blocking — five of six changed files are recipe-repository code. ignition/components/bf16_bmm.py (new, 184 lines), the BatchedUnquantizedProjection rewrite in ignition/components/linear.py:69-86, and both component test files implement a reusable BF16 projection block. The repository rules put that in hyperflare_recipes/components/ and reserve ignition/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.
  2. Should fix — the compiler-toolchain preparation now runs at module import of ignition.preparation.tuning. tuning.py:66 replaces the two former call sites (removed from RecordedPreparationSession.__init__ and declare()), so importing any of the ~60 modules that import ignition.preparation.tuning installs runtime patches and imports torch/Triton before ignition.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.

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:

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.

  1. Ordering inversion. ignition/cli/environment.py:5-11 documents the required order: "PyTorch, b12x, Triton, and the CuTe DSL read these variables when they are imported or first used. apply sets the environment before installing runtime patches." environment.apply() (environment.py:36-61) sets TORCH_CUSTOM_PYTHONPATH, CUDA_VISIBLE_DEVICES, B12X_COMPILE_CACHE_DIR, FLASHINFER_WORKSPACE_BASE, TRITON_CACHE_DIR, TORCHINDUCTOR_CACHE_DIR, CUDA_HOME and only then calls runtime_patches.apply(). After this PR, any module that imports ignition.preparation.tuning at module scope performs the patch installation and the Triton import first. The import graph makes that broad: 48 ignition/components/*.py modules import it directly, plus ignition/preparation/fixtures/*, ignition/preparation/startup_tuning.py:197 (not opened), ignition/planning.py:18 and every recipe bootstrap. Whether a given entry point (e.g. ignition/cli/serve.py importing a recipe before environment.apply) actually triggers it depends on import order; the risk that a cache directory or CUDA_HOME is frozen before configuration is applied is real and is exactly what environment.py's docstring warns about.
  2. Failure timing. A torch/triton mismatch that previously surfaced when a session was constructed or a declaration prepared now surfaces as ImportError-time PreparationError on import 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

  1. 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 of ignition/components/linear.py from main; 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.
  2. 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)

Open questions