PR #621 — Subtraction, Simplicity & Conventions review
PR: https://github.com/NVIDIA/hyperflare-inference/pull/621 · "Validate scheduler admission against the core parameter declarations" · jcartu · head 55bab978 (parent c146d7be = current main), 25 files, +148/−117.
Key findings
The diff is already lean and, in several places, genuinely subtractive — this review's dominant verdict. It removes code rather than adding fallbacks:
_wire_fp32(20 lines, plus_FP32_MAX) is deleted fromignition/direct/scheduler.pyin favour of the existingignition/preparation/contract.py:15wire_fp32; the keeper usesstruct.pack/unpackinstead of numpy and keeps alabelargument, so nothing is lost (mathis still used atscheduler.py:327, so its import is not orphaned).Layout._cache_key(request, tokens=None)'s unusedtokensargument is removed (ignition/direct/scheduler.py:878-882); only two call sites existed (:605,:888).- The duplicated
is_text_forward_graphfree function is deleted fromhelios/src/model/contract.rs. - The
core_parameter_defsdeclaration slice is fully deleted, not patched, from four signatures and four call sites inhelios/src/server/runtime.rs(begin_pool_lookup,admit_with_checkpoint_accounting,admit_with_host_storeand their callers —runtime.rs:2721-2778,1272,1408,1452,1476,1493).
Four suggestions follow, in priority order. None is a correctness bug; #1–#3 are code/doc that this PR adds or renames but does not need.
1. (high) One predicate, two names — samples() is now a pure alias of is_text_forward()
helios/src/execution/manifest.rs:89-104:
pub fn samples(self) -> bool {
self.is_text_forward()
}
pub(crate) fn is_text_forward(self) -> bool {
matches!(
self,
Self::Prefill
| Self::TerminalPrefill
| Self::ScoredPrefill
| Self::Resume
| Self::Decode
| Self::Speculative
| Self::Mixed
)
}
Before this PR the seven-kind list existed twice (the deleted is_text_forward_graph in model/contract.rs was byte-identical to samples()). The PR collapses the list correctly but leaves two names for the one surviving predicate, with different visibilities, so a reader must resolve which one to call. The rename is also invisible in the PR's description.
Concretely: make is_text_forward pub, delete samples() (lines 89-91), and rename its five call sites — helios/src/execution/manifest.rs:944, helios/src/execution/transport.rs:1537 (not opened) and :1552, helios/src/model/testing.rs:171 (not opened), helios/src/server/runtime.rs:2906 (confirmed by search: these are the only non-image .samples() uses in the crate; helios/src/frontend/images/mod.rs:593 (not opened),601 are an unrelated color_type::samples()). Net −2 lines and one fewer identifier. The alternative — deleting is_text_forward and keeping samples() — is worse, since is_text_forward is the name the two remaining internal callers already use (model/contract.rs:652, model/packing.rs:129).
2. (high) The wire-level rename is unsupported churn and creates a same-name pair across layers
helios/src/runtime_core/mod.rs:48-50:
pub fn validate_core_parameter_declarations(value: &wire::ModelContract) -> crate::Result<()> {
protobuf::validate_core_parameter_declarations(value)
}
The rename validate_core_parameters → validate_core_parameter_declarations propagates through helios/src/runtime_core/protobuf.rs:54 (definition), :85, :952, :966, :1012 (test call sites) and heliopause/src/export/binding.rs:1051 — five files of churn that support no behaviour the PR needs (the behaviour change is the scheduler taking declarations from the core, which touches none of these signatures).
It also creates a caller hazard: helios/src/model/contract.rs:460 already had
pub fn validate_core_parameter_declarations(parameters: &[CoreParameter]) -> Result<()> {
so the repository now exposes two public functions with the same identifier that validate different layers (&wire::ModelContract vs parsed &[CoreParameter]), while the sibling values check keeps the old verb — PreparedContract::validate_core_parameters(&CoreParameters) at contract.rs:521. A caller reading validate_core_parameter_declarations(...) cannot tell from the name which layer it validates.
This is exactly the churn AGENTS.md:188-193 rules out: "Unsolicited formatting, renaming, comment expansion, annotation sweeps, and file rearrangements are not contributions by themselves. Refactoring must directly support the requested behavior or remove a demonstrated source of defects or cost."
Concretely: revert the rename in helios/src/runtime_core/mod.rs:48, helios/src/runtime_core/protobuf.rs:54,85,952,966,1012 and heliopause/src/export/binding.rs:1051. That drops ~12 diff hunks and leaves validate_core_parameter_declarations meaning one thing in the tree.
3. (medium) Pending-qualification prose duplicated into design docs, against AGENTS.md
docs/api.md:766-770:
parameters, the prefix root hashes only the domain tag and core identity. CPU
tests cover the wire contract, request decoding, prefix-cache identity, and
packing paths, and Kani harnesses cover declaration validation and resolution.
Live GPU export and serving with a core that declares `core_parameters` remain
pending qualification.
docs/direct-execution.md:86-89:
resolves defaults and ranges before prefix lookup. Direct core-parameter
resolution, packing, and checkpoint isolation are verified by CPU tests; live
GPU direct execution with a recipe that declares `core_parameters` remains
pending qualification.
The PR also adds docs/TODO.txt:10-16, whose closure criterion is literally "…and the qualification notes in docs/api.md and docs/direct-execution.md are updated". So the same unrun check is recorded in three places, and the two design-doc copies are what AGENTS.md:57-60 excludes: "Record unresolved defects, unrun checks, and pending measurements in docs/TODO.txt, not in design documents. Do not add defect reports, investigation logs, run journals, or progress notes to the repository."
Concretely: delete the added sentences at docs/api.md:766b-770 and docs/direct-execution.md:86b-89, keep docs/TODO.txt:10-16, and adjust that TODO entry's closing clause (which currently points at prose that would no longer exist). Net −7 doc lines and one source of truth for what remains unqualified.
4. (low — note, not a demand) plan_admission's documented rejection is not visible where it is documented
helios/src/scheduler.rs:1448-1452:
/// Validates the request, builds its prefix history, and looks up the GPU
/// cache without reserving anything. Rejects cores that declare core parameters.
pub fn plan_admission(&mut self, spec: &RequestSpec) -> Result<AdmissionPlan> {
self.plan_admission_with_core_parameters(spec, &Default::default())
}
The "rejects cores that declare core parameters" behaviour is realised only by validate_resolved_core_parameters's length check — helios/src/model/contract.rs:475-482:
if values.len() != parameters.len()
|| parameters.iter().any(|parameter| {
values
.get(¶meter.name)
.is_none_or(|&value| !parameter.validate_value(value))
})
{
return Err("core_parameters does not match the model core's resolved parameters".into());
}
— and that error is folded into the generic invalid-request message at scheduler.rs:1479-1482 ("request requires a nonempty prompt, positive output limit, bounded total tokens, and resolved core parameters"), indistinguishable from an empty prompt or bad boundaries. The same &Default::default() idiom in the doc comment is the only place a reader learns that parameterless admission is declaration-only.
I am not asking for a patch here: the defaulting is correct, &Default::default() is idiomatic, and there are 40+ test call sites. If the lines are touched anyway, an explicit if !self.capabilities.core_parameters.is_empty() { return Err(...) } at the top of plan_admission would make the documented rejection self-evident and give it its own error text. Otherwise leave it.
Checked and deliberately not flagged (so the report is honest about scope)
RequestScheduler::newre-validatingcapabilities.core_parameters(helios/src/scheduler.rs:696) duplicatesPreparedContract::validate(helios/src/model/contract.rs:538). It is a cheap guard at apubconstructor with its own regression test (helios/src/scheduler/tests.rs:2432-2446, which feeds a duplicategaindeclaration) — removing it would weaken a public boundary, not simplify.- Python
Layout.__post_init__range/default checks (ignition/direct/scheduler.py:120-139) overlapcore_parameter()inignition/preparation/contract.py:132-142. Both are pre-existing and outside the diff; consolidating them is not this PR's job. - The five
SchedulerCapabilities { core_parameters: vec![] }literal updates inscheduler/tests.rs,scheduler/phase_tests.rs(not opened),server/runtime.rstests are the unavoidable mechanical cost of moving the declarations into the capability — not removable churn. The..capabilities.clone()/..capabilitiesrestructurings atscheduler/tests.rs:2427-2446are the idiomatic way to add one field to an existing literal. - The direct-execution consolidation (deleting
_wire_fp32, removing_cache_key'stokens) is the model of what the rest of this review asks for, and there is no remaining per-site FP32 narrowing inignition/direct/scheduler.py— every narrowing now goes throughwire_fp32. - New test coverage at
tests/direct/test_scheduler.py:997-1025overlaps four invalid cases with the existingtest_core_parameter_helper_validates_and_reaches_wire_contract:834-845(bool, nan, inf, 1e-100) but adds genuinely new boundary cases (np scalars,nextafter, subnormal, exact bounds). Worth its size.
Open questions / what I could not establish
- Whether the maintainers consider finding 2 render-only; a rename revert is a one-command operation but would need a force-push or follow-up commit, and the PR description's "Rust callers … must update" sentence is partly justified by this rename rather than by the admission change itself.
- No in-repo recipe declares
core_parameters, so nothing in tree pins thatconfig.contract.core_parameters(used for resolution) andcapabilities.core_parameters(used for admission) are the same list — a missing test, not a subtraction item, and the Correctness lens's territory. - No CI evidence exists on
55bab978; all suites in the description remain self-reported, so I could not check whether thesamples()/is_text_forwardsplit (finding 1) is exercised outside the five call sites listed.