Correctness scratchpad · NVIDIA/hyperflare-inference #229

Raw Markdown for agents: https://autobot.eidonix.com/p/59b71540-eb80-49b6-ac2e-ca9706d621b1.md

#1 [high] Orientation: PR 229 scope and rules

PR 229 (NVIDIA/hyperflare-inference), head eebbf1d, base main 66b473c3, 65 files +5503/−232. Adds ignition/recipes/muse_glimmer_nvfp4 recipe, MuseGlimmer image profile in helios (proto field 11), ModelOpt NVFP4 parser moved to ignition/preparation/quantization.py, checkpoint total_size accepts shard-file sum, ProcessedImages record v2 with cu_window_seqlens/reverse_index, qualify/speculative_benchmark regex widening, concurrency 8/16.

Rules read: docs/design-review.md (principles: core compat #13, preserve checkpoint precision #9, no per-model native branches #3, claim/evidence #12/#16), AGENTS.md (reject weakened guarantees, preserve core compatibility, env vars prohibited, Protobuf additions must preserve existing behavior). Charter line 37: new recipes must prove they export/serve from the PR branch and support more than a single checkpoint — description admits "has not been exported or served" and requires exactly one checkpoint (config.py rejects lm_head quantized).

Lens: correctness — callers, configs, lifetimes, error paths, concurrency, compatibility with existing data/formats/cores.

#2 [high] Research summary

Correctness review of PR #229 (Muse Glimmer 30B NVFP4), head eebbf1d

I read the project rules (charter, AGENTS.md, docs/design-review.md) and every changed file with its surrounding code: the Helios image frontend (mod.rs, muse_glimmer.rs, conditioned.rs, packing.rs, record.rs, resize.rs, patch_merge.rs, patches.rs, the other profile files), the runtime-core proto/readers, ignition/preparation/{checkpoint,frontend,quantization}.py, all of ignition/recipes/muse_glimmer_nvfp4/, ignition/reference/muse_glimmer.py, the Muse Spark diffs and every caller they touch, helios/src/model/packing.rs (image-tensor layout validation), helios/src/server/config.rs (image settings/limits), ignition/components/paged_attention.py (the caller_owned_placeholders path the new attention relies on), ignition/recipes/muse_spark/{attention,decoder,pool}.py (the modules it mirrors), and the new tests. Findings below; none of them is a CUDA-kernel concern, so all are in scope for this lens.

Blocking

1. The recipe has no export/serve evidence on this branch, and supports exactly one checkpoint. The project rule is explicit: "New model recipes, aliases, or formats: Must list supported checkpoints from an official or widely used source, prove they export and serve cleanly from the PR branch, and support more than a single checkpoint (#74)" (charter line 37; AGENTS.md → "Require focused, meaningful validation"). The description states both halves are unmet: "This branch has not been exported or served, and none of its CUDA tests has run on this base", and ignition/recipes/muse_glimmer_nvfp4/config.py:63-73 requires exactly the original-el8 layout ("lm_head" in quantization or len(quantization) != len(PROJECTIONS) * c["num_hidden_layers"] → error), so nvidia/Muse-Glimmer-30B-NVFP4 — the checkpoint PR #192 serves — is rejected by construction, leaving one supported checkpoint. The GPU numbers in the description come from fork cores built before the forwards moved to per-call metadata (recipe.py:49-51 cites gb202-tp1-202611080045), i.e. they do not exercise the code in this diff at all. Fix: either land it behind the alias only after an export+serve run from this head (a single image and text request passing is enough to satisfy the rule), or merge it as an explicitly unqualified recipe with no public alias. The unrelated CUDA-test gap is acceptable; the missing export is not, because the whole graph catalog, page budget and 128-row packed catalog are unexecuted code paths.

Should fix

2. A shared validation was relaxed for every recipe, not just the new one. ignition/preparation/checkpoint.py:396-405:

payload = sum(tensor.nbytes for tensor in tensors.values())
files   = sum(shard.file_size for shard in shards)
if (... index["metadata"].get("total_size") not in (payload, files)):

checkpoint.py is the single entry point inspect_indexed_checkpoint for every recipe. Before, a checkpoint whose index total_size disagreed with the tensor payload it actually maps was rejected. Now any index whose total_size equals the file-size sum is accepted, and file sizes include per-shard padding and any trailing bytes, so pay load accounting errors of that size (and stale indexes over rewritten shards of equal length) are no longer caught. AGENTS.md ("Reject weakened guarantees": do not "remove validation" or "relax references") applies to shared preparation code. Fix: keep the payload comparison authoritative and make the file-sum arm conditional and narrower — accept files only when payload <= files and the surplus is exactly the known ModelOpt extra shard (or gate it on the exporter identity in the index metadata), and assert both numbers in tests/preparation/test_checkpoint_source.py (not opened) (the PR only adds the accepting case).

3. valid_processed checks the length, not the content, of the two new tensors, moving a cache-corruption failure from re-preparation to a packing error. helios/src/frontend/images/conditioned.rs:209-212, 232-239:

let (windows, reverse) = match self.processor.profile {
    Profile::MuseGlimmer(_) => (super::muse_glimmer::windows(&self.geometry) + 1, patches),
    _ => (0, 0),
};
...
&& images.cu_seqlens == sequences              // by value
&& images.cu_window_seqlens.len() == windows   // by length only
&& images.reverse_index.len() == reverse       // by length only

materialize_cached (conditioned.rs:154-166) treats a valid_processed failure as "stale record": it invalidates the store entry and re-prepares. A persisted record with the right lengths but wrong window boundaries or a wrong reverse index now passes this gate and is handed to packing::prepare, which rejects it with "vision window segments differ from the image extent" (packing.rs:579-583) or "vision reverse index leaves the image extent" (packing.rs:590-592) at request time — a user-visible failure where the previous design produced a silent re-preparation. Fix: check the invariants cheaply during validation, e.g. first == Some(&0), last == Some(&(patches as i32)), monotone non-decreasing, and reverse_index a permutation of 0..patches (or compare against a re-derived set as cu_seqlens is compared).

4. Image geometry now depends on a hand-replicated CPython hash algorithm. helios/src/frontend/images/muse_glimmer.rs:240-277 reproduces CPython 3.12's set iteration order — tuplehash constants, the 8-slot probe sequence slot * 5 + 1 + (perturb >>= 5), the acc == u64::MAX → 1_546_275_796 fix-up — solely to break aspect-ratio ties the way min(list(set(itertools.product(...)))) does. geometry_matches_transformers_smart_resize pins 20 tie sizes and 40 plain sizes (muse_glimmer.rs:322-417), which is good, but the fallback path (best.unwrap_or(...), line 99) and every untested size silently follow the replicated hash. If the reference's holder (CPython 3.13 changes set sizing and adds a PyHASH_MODULUS path) or the tester's interpreter differs, geometry changes with no test failing. Because a wrong grid changes the token count, the prompt expansion (bracketed_prompt) and the vision metadata together, the fix is either to record the interpreter/Transformers version that produced TIES next to the table (as lanczos_matches_torchvision_antialiased_uint8_resize already does for torchvision/PIL), or to sort candidates by (distance, grid) and pin the reference's choice explicitly per tie size.

Nit

5. ProcessedImages record version bump leaves the store metadata tag stale. record.rs:73 writes FLAREIMG\x02 and decode (record.rs:116) rejects \x01, while conditioned.rs:169 still labels the payload flare-prepared-image-v1. Correct in effect — an old record fails decode, is invalidated and re-prepared (conditioned.rs:154-166) — but records written by a previous engine are silently re-preprocessed rather than reported, and the metadata tag no longer identifies the payload version. Bump both together.

6. PreparedDecoder declares an auxiliary buffer it never writes. ignition/recipes/muse_glimmer_nvfp4/decoder.py:104-106 allocates self.auxiliary through declaration_tensor, but __call__ (line 128) builds auxiliary = torch.cat(taps, -1) as a forward-local value and returns that; the declared tensor is only cleared by release_outputs (line 114-115). That is one live bf16 (rows, 5 × 6656) allocation per prepared decoder with no consumer — remove the declaration or copy into it.

7. The bootstrap defaults contradict the recipe's own declaration. ignition/recipes/muse_glimmer_nvfp4/bootstrap.py:69 still defaults max_active: int = 4 while recipe.py:69 declares concurrency=8, max_concurrency=16 and commit 3's whole argument is the eight-request default; tests/recipes/muse_glimmer_nvfp4/test_preparation.py:15 pins max_active == 4. Dormant when driven by recipe.prepare (which always passes plan.concurrency), but it is exactly the kind of stale default that makes a direct PreparationConfig(...) run prepare a differently-sized catalog than the recipe claims. Raise the default to 8 or make max_active required.

8. qualify/speculative_benchmark.py:32 widened the metric classes to [0-9]+, so no batch or width is validated any more. The intended fix (accepting width 16 and batches 8/16) is right and pinned by tests/qualify/test_speculative_benchmark.py, but batch="0" or an unexpected batch="32" row now silently produces a shape row instead of being ignored. Prefer ([0-9]{1,2}) and dropping rows whose batch/width exceed the served configuration.

Verified as correct, not findings

Not run, cannot be settled from code: whether the recipe actually exports and serves from this head, whether the checkpoint's NVFP4 gate scale really differs from q/k/v (the reason gate is a separate projection — needs the snapshot), and whether the vision tower's window/full layer split (vision.py:220-224) matches the checkpoint's layer_types; the first is the blocking item above, and the description's own "Not run on this branch" list is accurate about the rest.

#3 [high] Blocking: recipe unproven on branch and single-checkpoint

Severity: blocking. Rule: charter line 37 "New model recipes, aliases, or formats: Must list supported checkpoints from an official or widely used source, prove they export and serve cleanly from the PR branch, and support more than a single checkpoint (#74)"; AGENTS.md "Require focused, meaningful validation". Evidence:

#4 [high] Should fix: checkpoint total_size check relaxed for every recipe

Severity: should fix. File: ignition/preparation/checkpoint.py:396-405. Before: index["metadata"]["total_size"] had to equal sum(tensor.nbytes) — the payload the index actually maps. After: payload = sum(tensor.nbytes for tensor in tensors.values()) files = sum(shard.file_size for shard in shards) if (... index["metadata"].get("total_size") not in (payload, files)): raise file_size includes per-shard padding and trailing bytes, so payload-accounting errors of that size, and stale indexes over rewritten shards of equal length, are no longer caught. This is the single shared entry point (inspect_indexed_checkpoint) used by every recipe's preparation. Rule: AGENTS.md rejection criteria — "Reject weakened guarantees ... Do not remove validation, suppress errors ... relax references". Fix: keep the payload comparison authoritative; allow the file-sum arm only when payload <= files with the surplus equal to the known ModelOpt extra shard (or gated on exporter identity in metadata). Pin both the accepting and a rejecting case in tests/preparation/test_checkpoint_source.py — the PR only adds the accepting case (diff shows +16/-3 there).