Pre test report report · NVIDIA/hyperflare-inference #533

Raw Markdown for agents: https://autobot.eidonix.com/p/e0549603-c570-468c-9a17-c159ec76694e.md

Hardware Test Plan — PR #533 "Cap the per-request context target" (head 503a438)

Verdict: refer to hardware testing, narrowly — ~2–4 GPU-hours on ONE GPU of cn5. Skip cn7. Skip multi-host.

PR #533 adds --request-context N, an export-time cap on the prepared per-request context. It is a memory-sizing and admission-ceiling change with no speed claim, so this plan deliberately contains no throughput A/B. Two things are worth GPU time and nothing else is: (1) does the cap actually reach the exported core (max_sequence_tokens, advertised max_model_len, admission enforcement), and (2) does it buy VRAM that the default --kv-cache-limit memory mode does not already give. Item 2 may honestly measure ~0 — report that, don't hide it.


1. What the code guarantees (verified at 503a438, so you can predict the result)

Fact Citation
Plan.prepared_context = declared_context when unset, else min(declared, N) ignition/planning.py:373-375
declared_context = adjust_context(recipe.base_context(checkpoint), …) (checkpoint/#212-aware) planning.py:363-365, :432-441
The single seam into every recipe/core: "context": plan.prepared_context ignition/preparation/bootstrap.py:132 (BasePreparationConfig.context, default 262144 at :33)
It becomes the served ceiling and is advertised helios/src/server/config.rs:131,148 → max_sequence_tokens; /v1/models max_model_len at helios/src/server/models.rs:99
Served ceiling is then clamped to physical pages helios/src/model.rs:263-275 (fit_context)
Over-cap request → HTTP 400, before any prefill work, message names the ceiling helios/src/server/request.rs:577-587; code context_length_exceeded at helios/src/server.rs:743 (not opened)
Cap also lowers the default output limit (max_new_tokens defaults to max_sequence_tokens) helios/src/server/config.rs:210-213
Misaligned in-range N rejected at planning; above-max N silently clamps planning.py:198-200, :373-375
Prefill chunk must be ≤ served context (export-time rejection) planning.py:626-629
Cap recorded in plan JSON / manifest / repro args / serve hint planning.py:407-409, ignition/parameters.py:1529-1530, ignition/cli/serve.py:69-74
Page sizes: Qwen 64, GLM 256, DeepSeek 128 tokens docs/core-design.md:1480
Default runtime mode ignores the cap for pool sizing (page_ceiling → None for KvCacheLimit::Memory) helios/src/runtime_core/memory.rs:314-316; default memory per docs/cli-design.md:733

Two known head-of-branch defects that can corrupt your reading if you trust the wrong surface (both non-blocking, already reported in the final review):


2. Hardware targeting

Model: nvidia/GLM-5.3-Flash-NVFP4 (cached on cn5; GLM-5.3 Flash is the model the repo's own examples qualify, docs/model-preparation.md:318, docs/multi-host.md:340). Page size 256 → N must be a multiple of 256.

Preflight before booking the GPU (5 min, no GPU):

df -h ~ /tmp; du -sh ~/.cache/flare/cores ~/.cache/huggingface/hub

A cn5 job gets only 16 GiB scratch. A checkpoint + core for a GLM-class model can exceed that; point paths.core_cache, paths.export_staging, and paths.hub_cache in ~/.config/flare/config.toml (not opened) at a larger writable volume, or the run dies mid-export and burns the booking.


3. Phase 0 — GPU-free, must be green first (zero GPU time)

The head has no CI. Its own new test is tests/cli/test_planning.py:298-329 (stubs source_identity, asserts the bootstrap seam, both rejections, manifest uint_value, repro args). Run:

.venv/bin/python -m pytest tests/cli/test_planning.py tests/cli/test_parameters.py (not opened) tests/cli/test_commands.py (not opened) -q

Then confirm, all GPU-free because planning precedes download (ignition/cli/serve.py:264-290) and derive() (ignition/cli/preparation.py:62-81):

.venv/bin/ignition export glm-5.3-flash-nvfp4 --gpus 0 --request-context 100000 --verbose   # expect UsageError "--request-context 100,000 … is not a multiple of the 256-token page size" (planning.py:198-200)
.venv/bin/ignition export glm-5.3-flash-nvfp4 --gpus 0 --request-context 2048 --verbose      # expect UsageError "--prefill-chunk-size 4,096 exceeds the 2,048-token context" (planning.py:626-629)
.venv/bin/ignition export glm-5.3-flash-nvfp4 --help | grep -A2 request-context              # flag present; note the "Context: X tokens max (page size: 256)" line (help.py:46)
flare-cli/target/release/flare run --help | grep request-context || echo "absent on flare run (correct)"

Record the declared maximum X from that --help line. Set N = largest multiple of 256 ≤ X/2 (e.g. X=262144 → N=131072). Do not hardcode N anywhere below.

Gate: if any of these fail, stop — a GPU run would test code that cannot plan.


4. Phase 1 — does the cap reach the core? (the only genuinely new capability; ~2 exports)

Two exports from the same command, differing only in the flag. A = capped, B = stock.

# A
.venv/bin/ignition export glm-5.3-flash-nvfp4 --gpus 0 --max-concurrency 4 --request-context $N 2> a-plan.json (not opened) | tee a-export.txt
# B  (skip only if `flare models list` already holds a stock core for this alias+TP: then reuse it)
.venv/bin/ignition export glm-5.3-flash-nvfp4 --gpus 0 --max-concurrency 4                 2> b-plan.json (not opened) | tee b-export.txt

A1 — the artifact (no serving needed). From a-plan.json (not opened) / b-plan.json (not opened):

python - <<'PY'
import json
for f in ("a-plan.json (not opened)","b-plan.json (not opened)"):
    p=json.load(open(f))["plan"]
    print(f, {k:p[k] for k in ("context","checkpoint_context","prepared_context","tokens","page_tokens","guaranteed_tokens","demand_pages")})
PY

PASS: A prepared_context == $N; B prepared_context == checkpoint_context (the declared max); demand_pages == 4 × prepared_context/page_tokens in each (planning.py:331 — this is the KV-demand number the PR exists to lower).

A2 — the exported core. flare inspect <A entry>:

flare-cli/target/release/flare inspect CACHE_ENTRY_A --json | grep -m1 max_sequence_tokens

PASS: max_sequence_tokens == $N on A, declared max on B; and A's printed reproduction command contains --request-context $N (ignition/parameters.py:1529-1530 → flare-cli/src/inspect.rs:454). This is the reproducibility claim from the closed #454.

A3 — the reachability gate (stop condition). Serve A and B and compare the advertised ceiling:

flare-cli/target/release/flare run CACHE_ENTRY_A --gpus 0 --max-concurrency 4 --kv-cache-limit concurrency &
curl -s localhost:8000/v1/models | python -c 'import json,sys; d=json.load(sys.stdin)["data"][0]; print(d["max_model_len"], d["model_info"]["flare"]["context_length"])'

PASS: A reports exactly $N. B: expect ≥ N and ≤ declared max — not necessarily the recipe max, because Helios narrows the served ceiling to pages × page_tokens at load (helios/src/model.rs:263-275). The pass condition is A == N and B > N, not "B == recipe max". FAIL here = "the external hyperflare_recipes recipe does not forward BasePreparationConfig.context" — the seam is outside this repo (AGENTS.md:379-396 (not opened)). Stop and report that; do not keep spending GPU time.


5. Phase 2 — admission ceiling, cheap (no long generation)

The 400 is produced from prompt + max_tokens > max_sequence_tokens before any prefill work (request.rs:577-587), so this costs seconds, not minutes. Calibrate the prompt with the CPU-side counter (docs/api.md:13):

curl -s localhost:8000/v1/messages/count_tokens -d '{"model":"…","messages":[{"role":"user","content":"<~1k token text>"}]}'

Then, against A and B:

# accepted on both (a few tokens of generation, then cancel)
curl -s localhost:8000/v1/chat/completions -d '{"model":"…","messages":[{"role":"user","content":"<~1k>"}],"max_tokens":4000}' | head -c 200
# rejected on A only
curl -s -w '\n%{http_code}\n' localhost:8000/v1/chat/completions -d '{"model":"…","messages":[{"role":"user","content":"<~1k>"}],"max_tokens":200000}'

PASS on A: HTTP 400, code: context_length_exceeded, message prompt of P tokens plus an output limit of O tokens exceeds this server's context of $N tokens, and the body carries the context is limited by … the --request-context cap hint (ignition/cli/serve.py:73-74 → helios/src/server/http.rs:57-68). Same request on B (stock) must be accepted — that comparison is the assertion no runtime flag can reproduce, since --kv-cache-limit/--memory-limit cannot lower max_sequence_tokens.

Also record "default output limit" from flare inspect on A vs B: it should drop with the cap (config.rs:210-213) — a real user-visible side effect worth one line in the report.


6. Phase 3 — the isolating VRAM comparison (A/B × kv-limit mode; ~4 serve starts)

At --max-concurrency 4, for A and B, under both pool modes:

for core in A B; do for mode in memory concurrency; do
  flare-cli/target/release/flare run $core --gpus 0 --max-concurrency 4 --kv-cache-limit $mode &
  sleep 45   # after load settles
  nvidia-smi --query-gpu=memory.used --format=csv,noheader -i 0
  curl -s 'localhost:8000/metrics?format=json' | python -c 'import json,sys; m=json.load(sys.stdin); print({k:m.get(k) for k in ("total_kv_pages","free_kv_pages","cached_kv_pages")})'
  kill %1
done; done

Read total_kv_pages as the primary number (helios/src/server/metrics.rs:1388), with nvidia-smi memory.used as corroboration.

Expected, and this is the honest framing:


7. Phase 4 — regression (same job, ~10 min)

  1. No-op path: from b-plan.json (not opened), prepared_context == checkpoint_context and the core loads and serves identically to a main-built core of the same alias/TP. If a pre-PR core is already cached, just flare run it — it must still load (helios/src/model/catalog.rs:42-69).
  2. Bench record: ignition bench … --request-context $N writes configuration.preparation including the cap (ignition/cli/bench.py:263-266); one run, no tuning sweep, just confirm two different caps produce different records.
  3. --direct parity (optional, 1 run): ignition debug-serve … --direct --request-context $N, then curl /v1/models — served ceiling should be $N (the cap reaches direct execution via config["max_sequence_tokens"], ignition/direct/scheduler.py:202). Cheap confirmation, and it is the one path not covered by the added test.

8. Budget, skip list, stop conditions

Item Cost
Preflight + Phase 0 (GPU-free) ~20 min CPU
Phase 1 (one export ≈ 30–60 min on one Blackwell; skip export B if a stock core is cached) 1–2 GPU-h
Phase 2 (admission probes) ~10 min
Phase 3 (4 serve starts) ~45 min
Phase 4 (regression) ~20 min
Total ≈2–4 GPU-hours, 1 GPU of cn5, 1 model, 1 host

Skip: cn7 (no ARM64 question), multi-host --ranks>1 (no second host — Phase 0 pins it), any throughput or latency sweep (the PR makes no speed claim), any full-context decoding test (Phase 2 replaces it), autotune-effort sweeps.

Stop and report instead of continuing if: Phase 0 fails; the preflight shows <~25 GiB writable scratch for export; Phase 1 A3 shows max_model_len does not move (external-recipe gap); or Phase 1 A2 shows --request-context missing from the reproduction command.


9. What to bring back

  1. prepared_context / demand_pages for A vs B (plan JSON).
  2. flare inspect context + reproduction command for A.
  3. /v1/models max_model_len for A and B, with the < N / > N comparison.
  4. The exact 400 body + code + context_hint for A, and B accepting the same request.
  5. total_kv_pages and nvidia-smi memory.used for the 2×2 grid (core A/B × memory/concurrency), including the honest memory-mode delta.
  6. Any mismatch between the Select GPUs status line and prepared_context (expected: the known display bug at ignition/parameters.py:1606-1607) — worth reporting as confirmation, not a new blocker.
  7. Whether the external recipe actually forwarded the cap (item 3) — the single fact that decides whether this feature ships working.