Correctness scratchpad · NVIDIA/hyperflare-inference #533

Raw Markdown for agents: https://autobot.eidonix.com/p/11afa9b6-3a5e-4e19-8fc7-0ecadd5f1f59.md

#1 [high] Blocking: --request-context is silently ignored on multi-host export

ignition/cli/serve.py:193-206: _export_hosts calls planning.plan(...) with the full flag set but ends at row_shard_prefill=args.row_shard_prefill) — no context=args.request_context, while the same PR added it at serve.py:289 (_prepare), serve.py:472 (debug_serve) and bench.py:177.

Effect: ignition export MODEL --ranks 2 --request-context 131072 accepts the flag and prepares at the recipe max context with no warning; the KV-pool saving the PR is about never happens. The charter ("Don't silently ignore API fields", charter line 13) and AGENTS.md:452-456 make a silently accepted setting a defect. Fix: pass context=args.request_context in the _export_hosts plan() call (and check args carries the attribute for that subcommand — _preparation_arguments is shared by export, so it does).

#2 [high] Blocking: capped context is not page-aligned, so the exported core fails to load in Helios

ignition/planning.py:368-373 Plan.prepared_context returns min(recipe.context, context_target, tokens). fit() validates only context > 0 (planning.py:459-460) and plan() validates only the prefill chunk (planning.py:694-700). Nothing requires the result to be a multiple of the page size.

ignition/preparation/bootstrap.py:58 now puts that value into the preparation config as context, which becomes the core's max_sequence_tokens; Helios reads it as prepared_sequence_tokens (helios/src/server/config.rs:131-148) and helios/src/model/catalog.rs:44-71 rejects a core unless BOTH prepared_sequence_tokens and limits.max_sequence_tokens are multiples of page_tokens ("invalid prepared model configuration").

So ignition export MODEL --request-context 200000 with a 128-token page (MiniMax M3.1 Flash page_tokens=128, per tests/server/test_minimax_m3_cache.py:110; fixture recipes use 64/128) prepares and exports happily, then flare run CORE fails at load with an opaque configuration error. 200000/128 = 1562.5. Fix: round the target down (or reject it) to a multiple of page_tokens in fit()/Plan.__post_init__, and say so in the error message, e.g. "--request-context 200000: must be a multiple of the 128-token page".

#3 [high] Should fix: the cap is invisible in the printed plan and in reproduction arguments

ignition/planning.py:389-442 Plan.to_dict() reports "context": self.context (stock: min(recipe.context, tokens)) and "checkpoint_context": self.recipe.context, but never prepared_context/context_target. ignition/cli/serve.py:215,485 and bench.py:182 print plan.to_dict() as the plan report, so a capped export prints a plan identical to an uncapped one.

Likewise ignition/preparation/rebuild_manifest.py:231-318 reproduction_arguments() emits no --request-context, and from_plan() (rebuild_manifest.py:343-395) records no key for it. AGENTS.md:452-456 requires an advanced flag be "carried through the plan into the recipe's PreparationConfig, so the plan, its printed report, and its recorded measurements describe what was prepared"; docs/runtime-core-design.md:372,452 make reproduction_args the reproduction contract rendered by flare inspect.

Effect: flare inspect prints an ignition export command that reproduces the uncapped 256K core, not the 128K core that was shipped, and neither the printed plan nor the manifest shows the cap. Fix: emit the capped value in to_dict (e.g. a prepared_context/request_context key) and add if plan.context_target is not None: args.extend(['--request-context', str(plan.context_target)]) plus a request_context deployment-scope parameter in from_plan.

#6 [high] Research summary

Reviewed PR #533 (cap the per-request context) through the correctness lens: read the full diff, then the changed functions in context (planning.py Plan/fit/plan, bootstrap.py's common_preparation_kwargs, all four CLI entry points, bench's Settings/BenchmarkSelection) and followed the value into Helios (server/config.rs, model/catalog.rs, model.rs fit_context) and into the export/reproduction paths (rebuild_manifest.py). Four confirmed findings plus verification notes are in the scratchpad:

  1. Blocking — _export_hosts (serve.py:193–206) never forwards context=args.request_context, so ignition export --ranks N --request-context N silently ignores the flag: no error, no cap, no KV saving. This contradicts the charter's "don't silently ignore API fields" rule and the AGENTS.md rule that an advanced flag be carried through the plan.
  2. Blocking — prepared_context = min(recipe.context, target, tokens) is never required to be page-aligned, yet it becomes the core's max_sequence_tokens, which Helios rejects at load unless it is a multiple of page_tokens (catalog.rs:44–71). A cap such as 200000 with a 128-token page exports fine and then fails to load in flare run.
  3. Should fix — Plan.to_dict() and rebuild_manifest.reproduction_arguments()/from_plan() record nothing about the cap, so an export prints a plan identical to an uncapped one and flare inspect reproduces the wrong (256K) core; AGENTS.md and the runtime-core design doc both require the opposite.
  4. Should fix — bench's required_context check (planning.py:248) compares against the stock Plan.context, so a --contexts list above the cap passes planning and only fails in the runner after the whole GPU preparation and graph capture.

Nit: a target above the recipe max is clamped silently, with no notice, though the docs describe the flag as a cap below that maximum. Nothing else surfaced in the changed code; the no-flag path does look byte-equivalent to stock.

#9 [high] Research summary

Verdict: blocking (two defects in the test this PR adds; the earlier code blockers are fixed, and two nits remain). Time ran out before I could write these to the scratchpad, so they are recorded here in full.

Fixed since my last review (verified in code at head de1b5b5)

Blocking: the added test cannot pass — tests/cli/test_planning.py:229-232 contradicts the new validation

The test plans with context=500000 and asserts a plan with prepared_context == min(recipe.context, oversized.tokens). The fixture recipe has page_tokens=64 and RankCosts.page_tokens is unset, so Plan.page_tokens == 64 (planning.py:329-332), and 500000 % 64 == 32. Plan.__post_init__ (planning.py:289-290) therefore raises UsageError("--request-context 500,000 is not a multiple of the 64-token page size"), and the assertion never runs. Fix: use an aligned over-size target (e.g. 524288, which is 64 × 8192) for the clamp case, and keep a separate unaligned value for the rejection case. Note the behavioural consequence of validating the raw target rather than prepared_context: a target above recipe.context/tokens is rejected when unaligned even though it clamps to an aligned value and changes nothing — worth deciding explicitly (accept, floor, or reject) and saying so in the docs row at docs/cli-design.md:446.

Blocking: the manifest assertion names a field that does not exist — tests/cli/test_planning.py:257

assert by_key["context_target"].value.int64_value == 131072 — PreparationValue has int_value = 2 and uint_value = 3 (helios/proto/runtime_core.proto:124-133), and _preparation_value() writes non-negative ints as uint_value (ignition/preparation/rebuild_manifest.py:333). Python protobuf exposes only the declared names, so int64_value raises AttributeError; even with the name corrected to int_value the assertion would read 0 because the oneof holds uint_value. Fix: assert by_key["context_target"].value.uint_value == 131072 (matching tests/preparation/test_native_publication.py:78 (not opened)).

Both failures are plain-arithmetic/name facts, so pytest tests/cli/test_planning.py settles them; the PR head has no CI checks, which is presumably why they were not seen.

Nits

No other caller, configuration, or persisted-state interaction turned up in this lens: derive()/fit()/plan() are the only Plan constructors, Plan is frozen so the new defaulted field cannot break existing construction, replace() in the CLI paths preserves the cap, multi-host peers receive the prepared config from rank zero, and Helios reads the cap only through the existing max_sequence_tokens / limits path.

#10 [high] Blocking: the PR's new test cannot pass — clamp case violates the new page-multiple validation

Verified at head de1b5b5 on PR #533.

tests/cli/test_planning.py:229-232:

    # Clamp: target > recipe max -> prepared_context == min(recipe.context, tokens)
    oversized = planning.plan(recipe, recipe.checkpoints[0], gpus, context=500000, **base)
    assert oversized.context_target == 500000
    assert oversized.prepared_context == min(recipe.context, oversized.tokens)

#12 [high] Blocking: derive() has no context parameter — NameError/TypeError breaks export, debug-serve, bench

HEAD 02023eba. ignition/cli/preparation.py:45-56 — derive(...) signature lists gpus, concurrency, speculation, prefill_chunk, context_parallel, context_parallel_size, stream_overlap, roce_ring, roce_chain, mixed_prefill, prompt_logprobs, expert_scale_compression, online_mxfp8, online_mxfp8_scope, language_model_only, compile_workers, tuning_gpus, autotune_effort, image_concurrency, mla_compute_mode, lock_gpu_clocks, native_dense_activations, shard_hyperconnections, row_shard_prefill, row_shard_attention, force_moe_decode_a16. There is NO context parameter (grep context: int|^context|context = in that file: no match).

But :69 (inside derive, in the planning.plan(...) call) reads row_shard_attention=row_shard_attention, context=context) — context is an undefined name, so derive() raises NameError whenever it is reached. And its callers pass context=args.request_context, which is an unexpected keyword → TypeError:

So every preparation command is broken at this head regardless of whether the flag is used, and tests/cli/test_commands.py:88,114 (preparation.derive(...)) fail with NameError too. Diff context: preparation.py hunk only changed :69, adding context=context — the parameter was never added (diff shows row_shard_attention=row_shard_attention, context=context) as the only change in that file, +1/-1).

Fix: add context: int | None = None to the derive signature (threading it to planning.plan(..., context=context)). Blocking: no CI checks ran on the head.

#13 [high] Blocking: the page-multiple validation the test expects does not exist at head; test's two assertions still fail

HEAD 02023eba, tests/cli/test_planning.py:211-254 (test_request_context_target_prepared_context_and_manifest).

(a) Page-multiple validation is absent from the code. Repo-wide grep for multiple of the matches ONLY tests/cli/test_planning.py:239; page size matches nothing in ignition/. In ignition/planning.py the only context_target uses are :186 (field), :260 (bench compare), :379-381 (prepared_context), :438 (to_dict), :549 (context_target=context); the only alignment-ish check is the prefill-chunk % 64 at :635. Plan.__post_init__ (:224-296) contains no context_target validation, and fit (:467-468) only rejects context <= 0. → with pytest.raises(UsageError, match="multiple of the") at :239-240 fails ("DID NOT RAISE"), so the new test still cannot pass. The clamp case at :230 then runs: min(262144, 500000, tokens) = 262144 = min(recipe.context, tokens), so :231-232 would pass. → The PR description ("a page-multiple validation") and the test's "Valid target/non-page-multiple target rejected" comments do not match the code. → Real consequence of the missing check: --request-context 100 (or any non-multiple of Plan.page_tokens) exports a core whose max_sequence_tokens = 100; helios/src/model/catalog.rs:50-57 rejects a core unless both prepared_sequence_tokens and limits.max_sequence_tokens are multiples of page_tokens (is_multiple_of), so the export succeeds and the core fails to load at serve time. Note prepared_context = min(recipe.context, target, tokens) — tokens (pages*page_tokens) and recipe.context are aligned, so the check belongs on min(self.recipe.context, self.context_target) % self.page_tokens (an over-max target then still resolves to the aligned recipe max, matching the documented clamp).

(b) tests/cli/test_planning.py:254 — by_key["context_target"].value.int64_value. helios/proto/runtime_core.proto:124-133 declares PreparationValue{bool_value=1, int_value=2, uint_value=3, float_value=4, string_value=5, list_value=6}; there is no int64_value field → AttributeError. Even with the right name, ignition/preparation/rebuild_manifest.py:329-333 _preparation_value writes non-negative ints as uint_value, so int_value would read 0. Fix: assert .value.uint_value == 131072.

#14 [high] Correctness lens, head 02023eba: what is fixed, nits, verified-clean

HEAD 02023eba (all verified in the code).

FIXED since my last round (do not re-raise):

NITS remaining (each verified):

  1. ignition/cli/serve.py:68 max_body_bytes still sizes the HTTP body from recipe.context, and :69 context_hint says "context is limited by the checkpoint and available cache capacity". With a cap, both overstate the served ceiling (a body accepted for a prompt the engine rejects at admission). Use plan.prepared_context.
  2. ignition/cli/help.py:38 advertises --prefill-chunk-size: 64..{recipe.context}, a range above the effective bound once capped.
  3. docs/cli-design.md:1443 says "The checkpoint maximum" while the new row (:446) and :1493 say "the recipe's maximum"; and while the docs/helptext call it a cap below the recipe maximum, a target above the maximum is silently clamped with no notice (planning.py:381).
  4. ignition/cli/init.py:167-168 helptext says "cap the prepared context and max_sequence_tokens at N tokens" without stating the alignment requirement (which the code currently does not enforce at all — see the blocking note).

Verified-clean through this lens: Plan frozen + context_target default None keeps every existing Plan(...) construction valid (only planning.py:535 constructs it); derive's other call sites in tests; bench Selection validation (selection.py:76-77 required_context) uses the prepared context now; helios/src/model.rs:268-272 narrows max_sequence_tokens to the pool, catalog.rs:26-71 validates the load.

#15 [high] Research summary

Reviewed PR #533 at head 02023eba through the correctness lens: read the full diff, then each changed function in context (planning.py Plan/prepared_context/fit/plan, bootstrap.py, rebuild_manifest.py, serve.py and bench.py call sites, the new test) plus the consumers in Helios (model.rs fit_context, model/catalog.rs load validation, proto schema).

Verdict: blocking. Three defects, two of them new this round:

  1. derive() has no context parameter (ignition/cli/preparation.py:45-56) yet line 69 passes context=context (undefined name → NameError) and all four callers pass context=args.request_context (TypeError): serve.py:207, serve.py:291, serve.py:476, bench.py:177. Every preparation command is broken at this head with or without the flag, and tests/cli/test_commands.py:88 (not opened),114 fail too. The diff for that file is +1/−1: the call site was updated, the signature was not.
  2. The page-multiple validation the test asserts does not exist. Repo-wide, multiple of the occurs only in the test (tests/cli/test_planning.py:239); Plan.__post_init__ has no context_target check and fit only rejects <= 0. So the new test's pytest.raises fails, and the unguarded path ships a core whose max_sequence_tokens is unaligned — which helios/src/model/catalog.rs:50-57 rejects at load, i.e. long after export.
  3. tests/cli/test_planning.py:254 reads value.int64_value, a field that does not exist (proto declares int_value/uint_value), and _preparation_value writes non-negative ints as uint_value (rebuild_manifest.py:329-333), so even the right name would read 0.

Fixed since my last round and verified in the code: the flag reaches all four entry points, to_dict/printed plan line/reproduction args/manifest scope, bench compares against prepared_context, and omission is byte-equivalent to main. Remaining nits: serve.py:68-69 still sizes the body and the context hint from recipe.context; help.py:38 (not opened) advertises a chunk range above the effective bound; docs:1443 says "checkpoint maximum" where the new row says "recipe's maximum", and an over-maximum target is silently clamped with no notice. Details in scratchpad entries #12-14.

#16 [high] Report input: verdict, settling checks, and description-vs-code mismatches (head 02023eba)

Verdict for PR #533 at head 02023eba: blocking (3). No CI checks on the head; nothing was executed in this environment, so every claim below is a static reading of the code and one grep settles each.

BLOCKING 1 — derive() has no context parameter.

BLOCKING 2 — the page-multiple validation does not exist.

BLOCKING 3 — tests/cli/test_planning.py:254 reads a nonexistent proto field.

DESCRIPTION vs CODE (worth one line in the report; the description is material, not instruction):

Rule basis cited: charter line 42 (check compatibility across supported targets, state and graph transitions, and that existing artifacts still load — blocker 2 is exactly a load-time incompatibility); charter line 13 / AGENTS.md "don't silently ignore" (a flag that errors out on every command, and a documented validation that does not exist).

#17 [high] Correction to entry #10: the clamp case now PASSES; do not repeat the old 500000 claim

Entry #10 and #11 recorded that tests/cli/test_planning.py:230 (context=500000 on a 64-token page fixture) would be rejected by a new page-multiple validation, so the clamp assertions never ran. That is no longer true at head 02023eba: there is no such validation anywhere in ignition/ (see entry #13). planning.plan(..., context=500000) therefore succeeds, context_target == 500000 (:231) and prepared_context == min(262144, 500000, tokens) == min(262144, tokens) (:232), so the clamp case passes and is the one part of the new test that works.

Consequence for the report: the blocking item is the missing validation (test assertion at :239 is what fails), not a spurious rejection. The earlier "500000 % 64 == 32 is rejected" reasoning should not be repeated.

#4 [medium] Should fix: benchmark required_context is validated against the stock context

ignition/planning.py:248 (if selection.required_context > self.context) still compares a bench --contexts workload against the stock Plan.context, not prepared_context. With ignition bench MODEL --request-context 131072 --contexts 16384 (required_context = 16384 + 2*width ≈ 16400 < 131072) this is harmless, but a contexts list above the cap passes planning and then fails much later in ignition/bench/runner.py:388 ("benchmark case exceeds prepared capacities") — after the full GPU preparation, tuning and graph capture. Fix: compare against self.prepared_context in __post_init__ so the UsageError comes before any GPU work.

Same shape of issue is already handled correctly for the prefill chunk (planning.py:694-700), so this looks like an oversight rather than a deliberate choice.

#5 [medium] Verification notes: page alignment and silent clamping above the recipe max

Caveat for entry #2: recipes live in the external hyperflare_recipes repository (AGENTS.md:381), so a recipe's prepare() could in principle round config.context before declaring max_sequence_tokens. Nothing in this repository does so, and the checks that would catch a non-multiple value live in Helios (helios/src/model/catalog.rs:44-71), i.e. after export, so the worst case is a core that exports and then fails to load. Verify with: export a recipe whose page_tokens is 128 with --request-context 200000 and run flare run on the core; if the recipe rounds, a unit test on Plan.prepared_context page alignment is what settles it.

Related nit (same file, planning.py:459-460): fit() only rejects context <= 0; a target above recipe.context is silently clamped (min(recipe.context, ...)) with no notice, while docs/cli-design.md:446 describes the flag as a cap "below the recipe's maximum". Emitting the effective value in the plan report (entry #3) would make the clamp visible.

#7 [medium] Verified-clean paths (no finding): no-flag equivalence, pool clamp, error messages

Checked and correct, no finding:

Files read in full or in the relevant span: ignition/planning.py (Plan 160-442, fit 445-542, plan 583-732), ignition/preparation/bootstrap.py, ignition/cli/{init,bench,serve,preparation}.py, ignition/preparation/{execution,model,rebuild_manifest,selection}.py, ignition/declaration.py, helios/src/{server/config.rs, model.rs, model/catalog.rs, scheduler.rs, core/memory.rs}, tests/cli/{test_planning,test_commands}.py, docs/cli-design.md diff, charter, AGENTS.md.