Architecture scratchpad · NVIDIA/hyperflare-inference #231

Raw Markdown for agents: https://autobot.eidonix.com/p/d6ae6170-02a2-4af4-a015-2afcd2d70684.md

#1 [high] Blocking: bf16_bmm component + projection wiring belong in hyperflare-recipes, not this runtime repo

Governing rules:

The PR adds ignition/components/bf16_bmm.py (184 lines, a reusable BF16 batched-matmul projection with its own Triton tiles), rewrites BatchedUnquantizedProjection in ignition/components/linear.py:69-86 to use it, and adds tests/components/test_bf16_bmm.py + test_bf16_bmm_cuda.py. None of that is a Helios-ABI runtime interface component; it is a reusable projection block, so it belongs in hyperflare_recipes/components/ per the rules above.

The PR's own triage comment (2026-11-24, original-el8) states exactly this: "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."

Also verify against main: at time of review, main's ignition/components/ contains only Helios-ABI interface components (capacity, collectives, completion, engram, flashinfer_sampling, logprobs, ngram_delivery, readiness, sampling, state, state_transfer, vision_delivery, vision_state) — ignition/components/linear.py no longer exists on main (read_file at ref main errors "not a file at that commit"; the author's own comment of 2026-11-13 reports the merge conflict in ignition/components/linear.py). So 5 of the 6 changed files are (a) in the wrong repository and (b) in a file that has since been removed from main.

Fix: keep only the ignition/preparation/tuning.py change (+ its tests/preparation/test_toolchain.py coverage) here, with a linked hyperflare-recipes PR carrying bf16_bmm.py, linear.py and the two component tests; or obtain an explicit maintainer decision to host it here (design-review.md:125-136 forbids waiving the boundary for performance gains).

#2 [high] Should fix: toolchain preparation moved to import time of ignition.preparation.tuning (module side effect ordering)

ignition/preparation/tuning.py (PR head): the module-level _prepare_compiler_toolchain() call at line 66 replaces the two previous call sites (deleted at RecordedPreparationSession.init and in declare()).

_prepare_compiler_toolchain() (lines 47-63) calls runtime_patches.apply() and then _set_triton_libdevice_path() under config.patch(emulate_precision_casts=...), which imports torch and torch._inductor and imports triton (runtime_patches/init.py:90-129 → apply_triton():75-87 imports triton).

Consequences to verify with a test:

  1. Ordering. ignition/cli/environment.py:5-11 documents the required order — "apply sets the environment before installing runtime patches" — and environment.apply() sets TRITON_CACHE_DIR, TORCHINDUCTOR_CACHE_DIR, B12X_COMPILE_CACHE_DIR, CUDA_HOME and then installs patches (environment.py:36-61). Any module that imports ignition.preparation.tuning now installs the patches and imports Triton first; Triton/b12x read these variables at import/first use (environment.py docstring), so the cache-directory configuration can be frozen before configuration.apply() runs. All ~60 component modules import ignition.preparation.tuning at module scope (grep from ignition.preparation.tuning import), so a single early import anywhere sets this.
  2. Failure timing. runtime_patches.apply() raises PreparationError when torch != 2.14.1+cu132 or triton != 3.8.0 (runtime_patches/init.py:81-82,103-105). Previously an incompatible environment failed when a session was constructed or a declaration prepared; now import ignition.preparation.tuning fails, which also breaks test collection and any tool that only wants to inspect declarations or types.
  3. The import cannot be made lazy again without giving up the fix, which suggests the fix belongs where the ordering is already owned: keep the call in RecordedPreparationSession.init and declare(), and add the toolchain readiness to the path that compiles a Triton program before any session exists (i.e., at the component's own import/compile entry point), or make _prepare_compiler_toolchain idempotent and expose it for those components. What settles the size of the risk: a test that imports a component module under a config where CUDA_HOME/TRITON_CACHE_DIR differ from the defaults and checks the resulting cache location.

#3 [high] Research summary

Reviewed PR #231 through the architecture-and-scope lens: read the charter, AGENTS.md, docs/design-review.md, docs/model-development.md, docs/preparation-development.md, the full diff, and the changed functions in context (ignition/preparation/tuning.py, ignition/components/linear.py, ignition/components/bf16_bmm.py, tests/preparation/test_toolchain.py, plus callers such as ignition/recipes/glm53/mla.py and ignition/cli/environment.py). Two findings recorded in the scratchpad.

Blocking — the BF16 BMM component belongs in hyperflare-recipes, not this runtime repository. docs/design-review.md:33-37 (principle 3) and AGENTS.md:9-13 assign reusable projections/model execution blocks to hyperflare_recipes/components/ and reserve ignition/components/ for Helios-ABI runtime interface components; docs/model-development.md:276 already points UnquantizedProjection at the recipe repo. Of the six changed files, five are this reusable projection block plus its tests, and the PR's own 2026-11-24 triage comment says the same thing explicitly, leaving only the toolchain change here. On top of that, ignition/components/linear.py no longer exists on main (the author's 2026-11-13 comment reports the merge conflict there, and main's ignition/components/ now holds only ABI components), so the projection wiring is also in a file the default branch has removed.

Should fix — moving _prepare_compiler_toolchain() to import time of ignition.preparation.tuning. The module-level call at tuning.py:66 replaces the two former call sites. _prepare_compiler_toolchain() imports torch/torch._inductor and installs runtime_patches.apply(), which imports triton and raises PreparationError on a version mismatch. That inverts the order documented in ignition/cli/environment.py:5-11 ("apply sets the environment before installing runtime patches"; environment.apply sets TRITON_CACHE_DIR/TORCHINDUCTOR_CACHE_DIR/B12X_COMPILE_CACHE_DIR/CUDA_HOME and then applies patches), and every one of the ~60 component modules imports this module at module scope — so a single early import can freeze cache locations before configuration is applied and can turn an incompatible toolchain into an import-time failure of the whole package. Since the fix cannot stay lazy without losing its purpose, it should be pinned to the paths that actually compile Triton programs (session construction/declare, plus the component's own compile entry point) rather than to module import.

Everything else I checked (scratch-free plans, native_plan use, stride/alignment rejection, captured-graph replay test, the declared numerical contract) looked consistent with the existing component patterns; the CLI CI failure on the head commit was not investigated further. I did not finish verifying the ordering risk with a test, which is stated in the note.

#4 [medium] Review coverage and cleared items for PR 231 (architecture and scope lens)

Lens: architecture and scope. Rules read: charter (read_charter), AGENTS.md (esp. lines 9-13 scope, 155-207 rejection criteria, 470-482 kernel authorship), docs/design-review.md principles 3, 4, 11, 12, 15, docs/model-development.md (3-8, 260-309), docs/preparation-development.md (11-27, 66-93).

Changed files (6, +373/-16): ignition/components/bf16_bmm.py (new, 184 lines), ignition/components/linear.py (+8/-9), ignition/preparation/tuning.py (+9/-5), tests/components/test_bf16_bmm.py (new 44), tests/components/test_bf16_bmm_cuda.py (new 122), tests/preparation/test_toolchain.py (+6/-2).

Findings confirmed and recorded as entries 1 and 2:

  1. Blocking — bf16_bmm.py + linear.py wiring + 2 component tests belong in hyperflare_recipes/components per design-review principle 3 (lines 33-37) and AGENTS.md:9-13; corroborated by the PR's own 2026-11-24 triage comment and by ignition/components/linear.py no longer existing on main (its 2026-11-13 comment reports that merge conflict).
  2. Should fix — tuning.py:66 module-level _prepare_compiler_toolchain() call inverts the environment-before-patches ordering documented in ignition/cli/environment.py:5-11, freezes Triton/Inductor cache dirs before Configuration.apply, and turns a torch/triton version mismatch into an import-time PreparationError for every one of the ~60 modules that import ignition.preparation.tuning at module scope.

Things I checked and found consistent with existing patterns (no finding):

Explicitly not covered here (other lenses / not verified): whether the Triton tile selection is the best kernel (charter: GPU kernel code — concrete defects only, and I found none); whether the combined-branch 2945 vs 2620-2631 tok/s prefill claim is attributable (the PR already disclaims attribution, consistent with AGENTS.md required-PR-description rule 3); the CI failure on head commit 0ba78eb (not investigated — the branch is also 18 days stale and conflicted with main).