Architecture scratchpad · NVIDIA/hyperflare-inference #540

Raw Markdown for agents: https://autobot.eidonix.com/p/0b59c3ba-e157-430c-a29d-16d9b83c8969.md

#1 [high] Project rules (charter, AGENTS.md, design-review) key clauses

Sources: read_charter, AGENTS.md (main), docs/design-review.md (main).

Charter: "Solve the right problem in the right place... smallest footprint in shared code"; "Stay focused... not interested in piling on extra model aliases, random switches"; "Bring real evidence. Performance PRs need benchmarks showing an actual speedup over main on a served workload"; "Keep the runtime small and model-agnostic. Helios handles scheduling, caches, requests, and shouldn't accumulate per-model branches"; "Be explicit and pin everything. No magic defaults... Benchmarks, tests, or feature flags don't override architectural rules." Charter code review: "Supported matrix & compatibility: ... Check state and CUDA-graph transitions, and verify that existing data, artifacts, and exported cores still load." "No per-model special cases or flags."

AGENTS.md:

design-review.md principles: 1 "Keep Helios as simple as possible ... Introducing a captured-graph operation family requires prior explicit approval"; 3 "Preserve canonical model semantics and shared mechanisms ... Admission, page reservation and growth, eviction, preemption, readmission, and offload must not branch on model or recipe identity or capability flags"; 7 "Preserve complete committed state"; 8 "Budget physical memory across the lifecycle. Bound loading, tuning, compilation, capture, and serving storage"; 12 "Validate the real path and report evidence honestly ... keep raw measurements and disclose unrun checks"; 13 "Preserve model core compatibility"; 15 "Reject scope expansion and weakened constraints"; 16 "Write without hidden context".

#2 [high] Should fix: PR bundles four unrelated outcomes (~4k lines, 25 files)

Severity: should fix (scope).

Files: whole PR (25 files, +3965/−119) — helios/src/scheduler/{cost,refresh,policy,rounds,sam}.rs, runtime_core/selection.rs, model/catalog.rs, heliopause/src/python.rs, ignition/preparation/execution.py, docs/scheduling-runtime-design.md.

The description itself lists four independent commits (a85be397 cost-refresh recovery; 83ff9ed6 SAM copy drafts; 35ab143a wide copy-verify graph scheduling; 7ca5430c padding dominance + DEFAULT_MIN_MATCH_LEN 3→6). Each has its own motivation, risk surface and evidence, and each touches a different subsystem (refresh ledger; new 1600-line SAM module; graph catalog/selection/manifest metadata; batch padding policy).

Rule: AGENTS.md L196-199 "Keep each PR focused on one coherent outcome and describe its problem, resulting behavior, validation, and material limitations." design-review.md principle 15 (reject scope expansion / weakened constraints) and charter "Solve the right problem in the right place ... smallest footprint in shared code".

Why it matters: (a) the padding-dominance change and the match-length change alter behaviour for all existing speculation users (policy.rs dominates_padding_with / prune_padding, sam DEFAULT_MIN_MATCH_LEN), while the SAM and wide-copy work only affects cores that carry copy inputs; mixing them makes it impossible to attribute the measured improvement or to bisect a regression. The headline figure ("3.078 -> 3.650 emitted tokens/round") is a combined-stack number for three of the four commits. (b) Nothing in the description isolates the padding-dominance change's live effect from the wide-copy graph change, so the "max_b == C" table cannot be attributed.

Fix: split into (1) the funded-refresh recovery fix (a self-contained defect fix with CPU tests), (2) the padding-dominance + min-match-len change (shared policy, live evidence), (3) the SAM/wide copy-verify feature stack (new capability, new metadata).

#3 [high] Should fix: second proposal-source dimension in manifest + load-time special cases

Severity: should fix (architecture).

Where the duplication appears:

Why it matters: a graph's proposal source is already an expression of the core's speculative_proposal_source config (selection.rs:161-165, model.rs), and the scheduler already has proposal_source. This change adds a second source of truth (GraphDescriptor::draft_source, defaulted from kind == Speculative in heliopause/src/python.rs:231-232) and then needs a dozen conditionals to keep the two consistent. Rules: design-review.md principle 1 ("Keep Helios as simple as possible ... Express differences through cache schemes and prepared layout metadata reusable across models") and principle 3 ("Do not add ... capability flags"); AGENTS.md L188-193 "Reject unsupported abstractions and churn. Do not add frameworks, extension points, speculative compatibility, fallback layers, or configuration switches without a concrete requirement"; L176-181 "Flags, enums, callbacks, optional paths, and temporary implementations cannot be used to bypass them."

Also note has_mtp/copy_wide make behaviour depend on which other graphs a core contains — a non-local dependency that is hard to test and easy to break.

Fix: derive per-shape source from the key alone (e.g. keep one CostKey-level notion driven by a single declared catalog field), and keep one place that answers "may a copy-only shape be scheduled" instead of four. If wide copy-only graphs are wanted, the smallest footprint is a scheduler-level check on the captured shape list, not new manifest metadata threaded through selection, catalog, cost, rounds and runtime.

#4 [high] Nit/medium: docs stale after SAM change; unpinned constants; evidence gaps; no-op idle()

Severity: nit / should-fix (documentation accuracy).

  1. docs/mtp-design.md (unchanged by this PR) still states that history drafting works from a "host-memory ring" of "exact eight-token and four-token indexes" and "return[s] up to seven observed continuation tokens" (lines 31-34), and that it "requires speculative graphs that declare copy-token inputs, which only the qwen3.8-flash MTP graphs do" (lines 25-27). After this PR the primary source is a per-request prompt+output suffix automaton (helios/src/scheduler/sam.rs, RequestScheduler::request_history_proposal at helios/src/scheduler.rs:1102), with the shared ring only as fallback when it has a strictly longer match (scheduler.rs:1128-1147). The PR only updates docs/scheduling-runtime-design.md. AGENTS.md requires design docs to describe implemented mechanism and present qualification. Fix: update mtp-design.md's history-drafting section (mechanism, min match length 6, 131,072-token caps, 512-token boundary overlap).

  2. helios/src/scheduler/sam.rs:22 DEFAULT_MIN_MATCH_LEN: usize = 6 and the wide-copy constants WIDE_COPY_PRIOR_RATE = 0.88 / WIDE_COPY_MIN_MATCH_LEN = 6 (helios/src/scheduler/speculation.rs:15,18) plus base_mtp_drafts + 3 (rounds.rs copy branch) are unpinned magic numbers in shared policy. Charter: "Be explicit and pin everything. No magic defaults". The PR calls them calibrated but the evidence offered is one repetitive 512-token prompt; no derivation of 0.88 or of "+3" is given. Fix: state the derivation in the design doc or make them explicit policy fields.

  3. Evidence gap: live results are DeepSeek-V4.1 Flash TP4 on SM120 only with --history-drafts; copy-only wide graphs (W=16/24) were never exported or replayed on a GPU (the PR's own Limitations say so). So the wide-copy scheduling path (rounds.rs copy branch at ~745, catalog.rs:93-131, selection.rs:275-299,382-396) has CPU-test-only coverage — AGENTS.md L194-199 "Do not present scaffolding or partially wired features as supported". The compatibility claim ("existing W=8-only cores load") rests on the unit test helios/src/model/tests.rs::wide_copy_verify_catalog_packs_23_sam_tokens_and_preserves_legacy_w8_cores, not a load-and-serve of a previously exported core (design-review.md principle 13).

  4. helios/src/scheduler/refresh.rs:99 pub fn idle(&mut self) {} — an empty method that silently no longer does anything; call site helios/src/scheduler.rs:1281. Suggest deleting the method and the call so "idle does nothing" is visible. Nit.

  5. Positive note to record (no finding): the refresh change itself (refresh.rs:71-105, cost.rs:31-38) is a clean, well-scoped defect fix — compute duration excludes measured readiness wait, idle preserves earned credit and debt, abort still discards positive credit, and the aggregate bound in docs/scheduling-runtime-design.md (P <= 0.002/0.998 * O + D) still holds because idle adds neither credit nor ordinary duration. refresh_order (cost.rs:284-293) now returns a tiered key instead of a timestamp, which fixes the "probe older/smaller shapes first" defect.