Correctness report · NVIDIA/hyperflare-inference #533

Raw Markdown for agents: https://autobot.eidonix.com/p/bd181da6-bd91-440a-b0af-2d40a2ba400d.md

Review of PR #533 — Cap the per-request context (correctness lens)

Reviewed at head de1b5b5 (9 files, +98/−18). Base: main at c36a6a02. PR: https://github.com/NVIDIA/hyperflare-inference/pull/533

Key findings

The production change is now sound: four blockers I reported against the earlier head have all been fixed, and I re-verified each of them in the code. What remains blocking is the test the PR itself adds — it cannot pass — plus two nits.

  1. Blocking — tests/cli/test_planning.py:230: the "clamp" case plans with context=500000, which the PR's own page-multiple validation rejects (500000 % 64 == 32), so the test dies with UsageError before the assertion it is testing.
  2. Blocking — tests/cli/test_planning.py:257: asserts a protobuf field int64_value that does not exist, and even corrected to int_value would read 0, because the manifest writes non-negative integers into uint_value.
  3. Nit — ignition/planning.py:375: a target above the recipe maximum is silently clamped, while docs/cli-design.md:446 describes the flag as a cap below that maximum.
  4. Nit — ignition/cli/serve.py:68: max_body_bytes still sizes the image budget from recipe.context, not prepared_context, so a capped core accepts HTTP bodies for prompts the engine will reject at admission.

Previously-reported blockers now fixed (verified): multi-host _export_hosts forwards the flag; Plan.__post_init__ enforces the page multiple; to_dict() and reproduction_arguments()/from_plan() carry the cap; bench validates against prepared_context.

Because the head commit has no CI checks, these two test defects were never exercised. pytest tests/cli/test_planning.py settles both — they are plain arithmetic and protobuf-schema facts, not judgement calls.


Blocking

1. The added test cannot pass: the clamp case violates the new page-multiple validation

File: tests/cli/test_planning.py:229-232 (against ignition/planning.py:289-290)

    # 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)

Fix: use a page-aligned over-size target for the clamp case — 524288 = 64 × 8192, which is above recipe.context (262144) and therefore clamps to min(recipe.context, tokens). Keep 100 for the rejection case.

Related design point to settle while touching this: the validation checks the raw context_target, not the clamped prepared_context (ignition/planning.py:375). A target above recipe.context/tokens that is unaligned is rejected even though it changes nothing and would clamp to an aligned value. Decide explicitly whether that should be accepted, floored to a page, or rejected, and state it in the docs row at docs/cli-design.md:446.

2. The manifest assertion names a protobuf field that does not exist

File: tests/cli/test_planning.py:257 (against helios/proto/runtime_core.proto:124-133, ignition/preparation/rebuild_manifest.py:329-333)

    assert by_key["context_target"].value.int64_value == 131072

Fix: assert by_key["context_target"].value.uint_value == 131072.


Nits

3. A cap above the recipe maximum is clamped silently

File: ignition/planning.py:375 (return min(self.recipe.context, self.context_target, self.tokens)) and ignition/planning.py:459-460 (the only validation, context <= 0)

--request-context 300000 on a 256K recipe prepares 262144 with no notice. That is defensible as a clamp — and the pool clamp is documented ("a cap above the pool resolves to the pool capacity, as stock") — but docs/cli-design.md:446, added by this PR, describes the flag as a cap below the recipe's maximum, so a user who believes they have raised the ceiling gets no signal that they have not. The plan report now carries context_target (ignition/planning.py:432) but not the effective value; adding "prepared_context": self.prepared_context to Plan.to_dict() (or a stderr line when the clamp bites) makes it visible and costs one line.

4. max_body_bytes still sizes the image budget from the recipe maximum

File: ignition/cli/serve.py:68

The served body cap is still computed from recipe.context rather than prepared_context. With a cap below the recipe maximum, the frontend accepts request bodies (image payload budgets included) sized for prompts the engine will reject at admission. Harmless functionally — the request fails with the documented context-ceiling error — but it is the one remaining place in the changed area that still treats the recipe maximum as the served context.


Verified and correct (no finding)

Recorded so the coverage is explicit:

Files read in full or in the relevant spans: 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/{rebuild_manifest,selection,execution,model}.py, ignition/declaration.py, helios/src/{server/config.rs, model.rs, model/catalog.rs, scheduler.rs (not opened), core/memory.rs (not opened)}, helios/proto/runtime_core.proto, tests/cli/{test_planning,test_commands}.py, docs/cli-design.md, AGENTS.md, the charter.

Open questions / what a test must settle

  1. Do the two test defects reproduce? They follow from arithmetic and the declared protobuf schema, but I could not run the suite. pytest tests/cli/test_planning.py confirms both; the head commit has no CI checks, which is presumably why they were not seen.
  2. Should an unaligned target above the recipe maximum be rejected? Today it is (see finding 1's design note), even though it clamps to an aligned value and changes nothing. This needs a decision, not a measurement.
  3. Does any recipe re-round config.context before declaring max_sequence_tokens? Recipes live in the external hyperflare_recipes repository (AGENTS.md:381), outside this diff. Nothing in this repository rounds, and every alignment check lives in Helios (after export), so the ignition-side validation at planning.py:289-290 is the right place regardless.