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

Raw Markdown for agents: https://autobot.eidonix.com/p/485b2130-2d8b-4d6f-b5b7-91d4d05fc9a6.md

Key findings

  1. helios/src/execution/threaded.rs:1292-1294 — delete. The new if !b.persistent_workers.is_empty() { return false; } in same_layout is a second validator for a rule ThreadedExecutor::new already enforces at :632-636, before same_layout is ever consulted, with a precise error instead of "rank graph I/O schemas differ".
  2. helios/src/runtime_core/selection.rs:285-289 — delete. LoadOptions::select is pub(super) with one production caller (model.rs:441), which runs validate_persistent_worker_topology at model.rs:386; that function rejects exactly any peer-rank worker, so the rank > 0 branch is unreachable outside the synthetic test.
  3. helios/src/runtime_core/model.rs:118-127 — collapse. The same five-line closure body is written twice (has_rank0_worker, has_peer_worker).
  4. helios/manifest.md:92-95 — stale spec the PR forgot. It still says "multi-rank cores … fail validation before execution". Only docs/runtime-core-design.md:642-644 was reworded.
  5. Otherwise the diff is lean: no new flags, config keys, LoadOptions fields, wrappers or fallback branches; the test changes are proportionate; nothing speculative was added.

Subtraction, Simplicity & Conventions review — PR #640

Verdict: mostly lean; three added code fragments should not exist, plus one stale spec. Net +68 / −34 across 4 files. Every change is a predicate swap, a test update or a doc reword; no new abstraction was introduced. The problems are all added checks that duplicate a check the same call path already made, and one spec the PR did not update. All four fixes are deletions or one-line rewords — none needs a new helper.

1. same_layout's worker clause duplicates ThreadedExecutor::new (high)

helios/src/execution/threaded.rs:1292-1294, end of same_layout:

    if !b.persistent_workers.is_empty() {
        return false;
    }

It replaces the previous field-wise comparison of worker_sm_count / graph / metrics_count.

Redundant. ThreadedExecutor::new (threaded.rs:632-636) already rejects every peer manifest carrying a worker, and does so before the same_layout loop:

        if ranks.iter().any(|rank| !rank.persistent_workers.is_empty()) {
            return Err(invalid(
                "persistent workers are only supported on rank 0 of a local core",
            ));
        }
        for rank in &ranks {
            rank.validate()?;
            if !same_layout(&manifest, rank) {
                return Err(invalid("rank graph I/O schemas differ"));
            }
        }

So by the time same_layout runs, b.persistent_workers is guaranteed empty. The clause can only ever fire when same_layout is called directly from tests, and when it does fire it turns a precise topology error into a misleading schema error.

Concretely: delete threaded.rs:1292-1294 (and the now-empty preceding match arms adjacent to it are unaffected — only the standalone if block goes). Then rank_layout_permits_persistent_worker_only_on_rank_zero (threaded.rs:1631-1651) reduces to a single meaningful assertion, assert!(same_layout(&root, &peer)), and the other two assertions assert the behaviour the PR exists to remove. The rejection direction is already covered by helios/src/execution/tests.rs:1371-1373 (ThreadedExecutor::new(value, vec![value]) and (manifest(), vec![value]) must error). Delete the test with the clause, or retarget it at the untested direction — a successful ThreadedExecutor::new(worker_manifest, vec![plain_peer]).

One caveat for honesty: threaded.rs:1620 already asserts !same_layout(&ranks[0], &ranks[0]) for a repeated engram delivery group, so same_layout is already non-reflexive in one pre-existing case, and the new test's assert!(!same_layout(&root, &root)) at :1650 follows that precedent rather than inventing it. The asymmetry argument is therefore weaker than the redundancy argument; the redundancy argument stands on its own.

2. LoadOptions::select's new rank > 0 guard is unreachable in production (high)

helios/src/runtime_core/selection.rs:282-289:

            if execution.persistent_workers.len() > 1 {
                return Err(invalid("at most one persistent worker is supported per rank"));
            }
            if !execution.persistent_workers.is_empty() && rank > 0 {
                return Err(invalid(
                    "persistent workers are only supported on rank 0",
                ));
            }

select is pub(super) (selection.rs:76). Its only non-test caller is model.rs:441:

        let active = options.select(&mut cores, &mut server_config)?;

which is reached only after model.rs:386:

        validate_persistent_worker_topology(&cores, cluster.as_ref())?;

whose new body (model.rs:118-132) rejects cores.iter().skip(1) holding any worker. Therefore rank > 0 && !persistent_workers.is_empty() cannot be observed by select in production. The branch's only exercise is the synthetic test at selection.rs:710-720, which drives select directly and bypasses the topology validator.

Delete selection.rs:285-289 and keep the rule in one place (model.rs:128). This also removes the third error-string variant introduced by the PR — the repo then has "persistent workers are only supported on rank 0 of a local core" (model.rs:130, threaded.rs:634) and the untouched "…only supported on single-rank cores" (parallel.rs:124, :556) instead of three wordings for two different rules. The test at selection.rs:694-720 then keeps only the rank-0-retention assertions, which are the real value.

If a reviewer prefers the opposite direction (keep select standalone-safe, drop the model-level check), that is a legitimate call — but keeping both, with divergent messages, is the churn. This is the exact shape AGENTS.md names under "Reject unsupported abstractions and churn" / "Require focused, meaningful validation" (≈ lines 188-199; line numbers taken from research, worth re-confirming).

3. validate_persistent_worker_topology writes the same closure twice (medium)

helios/src/runtime_core/model.rs:118-127:

    let has_rank0_worker = cores.first().is_some_and(|core| {
        core.execution
            .as_ref()
            .is_some_and(|execution| !execution.persistent_workers.is_empty())
    });
    let has_peer_worker = cores.iter().skip(1).any(|core| {
        core.execution
            .as_ref()
            .is_some_and(|execution| !execution.persistent_workers.is_empty())
    });

Five identical lines, twice. Collapse:

    let has_worker = |core: &Core| {
        core.execution
            .as_ref()
            .is_some_and(|execution| !execution.persistent_workers.is_empty())
    };
    let has_rank0_worker = cores.first().is_some_and(has_worker);
    let has_peer_worker = cores.iter().skip(1).any(has_worker);

Minor and mechanical; it is the only place in the diff that got longer than it needs to be. Note the same test exists in a third form at helios/src/runtime_core/mod.rs:369-372 (core.execution.as_ref().and_then(|e| e.persistent_workers.first())) — a shared accessor would serve both, but that is out of scope for this PR and should not be bundled in.

4. helios/manifest.md now contradicts the code (high, convention)

helios/manifest.md:92-95, unchanged by this PR:

Context. Helios currently supports at most one persistent worker entry on
single-rank cores; cores declaring more than one entry, multi-rank cores, and
multi-host cluster cores declaring a persistent worker fail validation before
execution. Each `PersistentWorker` carries:

"multi-rank cores … fail validation before execution" is false for local multi-rank cores after this change. Only docs/runtime-core-design.md:642-644 was reworded, and the PR body's "What changed" list does not mention manifest.md. AGENTS.md's required-prose-review section (≈ lines 52-60) asks every document to state the architecture the code implements; two specs now disagree.

Reword manifest.md:92-95 to the same statement as the design doc: at most one entry per rank, permitted only on rank 0 of a local core, with peer ranks and multi-host cluster cores rejected before execution.

What is already lean (checked, not worth flagging)

Open questions / not verified