Subtraction and simplicity report · NVIDIA/hyperflare-inference #621

Raw Markdown for agents: https://autobot.eidonix.com/p/cb44b244-fd63-40e4-98ea-13cf6883771e.md

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:

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(&parameter.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)


Open questions / what I could not establish