Final review report · NVIDIA/hyperflare-inference #723

Raw Markdown for agents: https://autobot.eidonix.com/p/be7d9ac8-6b2a-4724-81ea-27ca5eea58c3.md

Recommendation: Changes Requested

The core of this PR — a fleet-wide 2-way (codec, compute) Green Context split for non-worker cores, gated on options.prefix_cache.compression == KvCompression::Gpu (helios/src/runtime_core/model.rs:718-733) rather than on model identity — is at the right layer, is model-agnostic, and is a defensible residual of priority:P1 #701. The manifest field additions are additive and plumbed end to end, and the load-time SM/cluster validation is genuinely fail-closed. But one verified code defect defeats the PR's own headline invariant: compute_coscheduled_alignment is laundered through .max(...) (persistent_worker.rs:455-457), which makes half of the guard at :490-496 unsatisfiable and feeds a fabricated alignment into the per-node cluster check at mod.rs:1087-1094, so a driver-downgraded partition is accepted with a 16-CTA cluster validation it cannot honour. Four smaller verified issues (a fabricated min_compute_sms >= 1 that voids the documented 0 = unspecified sentinel, a silent ImportError → 0 fallback on the external API the whole SM-floor gate depends on, an inverted min() floor aggregation, and a stale normative design doc) round out the request.

Merge Risk

Level: High

Walkthrough

Pre-merge Checks

Blockers

  1. compute_coscheduled_alignment is fabricated, which makes half of the create-time guard unsatisfiable and lets a downgraded partition pass the per-node cluster check. helios/src/runtime_core/persistent_worker.rs:454-457:

    partition.compute_coscheduled_alignment = actual_compute_sm
        .sm_coscheduled_alignment
        .max(group_params[compute_index].coscheduled_sm_count);
    

    group_params[compute_index].coscheduled_sm_count is set to required_compute_coscheduled (:189) or to PREFERRED_COMPUTE_COSCHEDULED_SMS = 16, and the latter branch is only entered when required_compute_coscheduled < 16 (:195-200). Therefore group_params[compute].coscheduled_sm_count >= required_compute_coscheduled always, so the second disjunct at :490-496 (partition.compute_coscheduled_alignment < required_compute_coscheduled) can never be true. The first disjunct (actual_compute_sm.sm_coscheduled_alignment < baseline_coscheduled) is live, but only catches a drop below the baseline alignment, never a drop below the required alignment derived from max_cluster_size — exactly the case the guard's message ("compute green context partition lost required co-scheduled SM alignment") exists for.

    The fabrication propagates: prepare_graphs reads Some(partition.compute_coscheduled_alignment) (helios/src/runtime_core/mod.rs:958) and compares it per attribute at :1087-1094. With min_sm_partition_size = 8, sm_coscheduled_alignment = 8 and one graph declaring max_cluster_size = 16, required_compute_coscheduled = 16; if the driver downgrades the request to an 8-SM-aligned compute resource, :490 (8 < 8) and :491 (max(8,16)=16 < 16) both evaluate false, the partition is accepted, and a 16-CTA cluster node then satisfies cluster_size > alignment = 16 > 16 = false. The PR's stated invariant ("no fallback below max_cluster_size") is silently defeated, and the diagnostic printed by the new tests (:3037-3040, :3592-3595) cannot distinguish requested from actual alignment. main recorded the driver's real value (persistent_worker.rs:265 at main: partition.compute_coscheduled_alignment = actual_compute_sm.sm_coscheduled_alignment;), so this is a regression introduced here.

    Fix: stop laundering the value and compare once against the real output:

    partition.compute_coscheduled_alignment = actual_compute_sm.sm_coscheduled_alignment;
    if actual_compute_sm.sm_coscheduled_alignment < required_compute_coscheduled {
        return Err(invalid(format!(
            "compute green context partition returned co-scheduled alignment {}, below required {}",
            actual_compute_sm.sm_coscheduled_alignment, required_compute_coscheduled
        )));
    }
    

    baseline_coscheduled <= required_compute_coscheduled holds by construction at :108-114, so one comparison covers both.

Should Fix

  1. heliopause reports min_compute_sms >= 1 and max_cluster_size >= 1 for every exported graph, voiding the documented 0 = unspecified sentinel. heliopause/src/export/capture.rs:465-472 returns Ok(1) when attribute 4 is absent, and :491-499 sets min_compute_sms = declared.min(max_cluster_size). A plain decode graph with no clustered kernels and no b12x floor therefore serialises (1, 1), so a reader can never distinguish "no floor declared" from a real 1-SM floor, nor a genuine 1-SM floor from a 16-CTA cluster's implicit 16-SM floor — contradicting the proto comment the description cites for backward compatibility (helios/proto/core.proto:251-254). The .max() fold additionally double-counts cluster size into the SM floor, and persistent_worker.rs:108-114 consumes max_cluster_size independently anyway, so the fold buys nothing. The new unit test locks the wrong behaviour in (capture.rs:5671: assert_eq!(graph_sm_requirements(&nodes[..1], 0)?, (1, 1));). Fix: return 0 when the attribute is absent, drop the fold (let min_compute_sms = declared_min_compute_sms;), and update the test to (0, 0) / (128, 0).
  2. The load-time SM-floor gate silently becomes a no-op if the pinned b12x lacks the new API. ignition/preparation/capture.py:78-83 returns nullcontext({"min_compute_sms": 0}) on ImportError, and this PR changes no pin (pyproject.toml:47 still pins flashinfer-python to rev 1441ce862ffbc9d8550fdda7ad90e97ca04f4b8e; pyproject.toml is not in pr_files). On a rev without track_capture_min_compute_sms, every graph exports floor 0 and the advertised rejection at mod.rs:964-980 / persistent_worker.rs:137-170 never fires — a silent substitution of execution behaviour, which AGENTS.md:182-193 prohibits. The companion test also imports record_min_compute_sms at module top (tests/preparation/test_capture_graph_metadata.py:599), so it errors rather than skips on an older pin. Fix: bump/verify the pin to a rev containing the API, and make the missing tracker a hard failure (or an explicit, named skip) instead of 0.
  3. register_cooperative_plan aggregates the reservation floor with min(), so a re-registration can silently weaken it. ignition/preparation/scratch.py:163-164: self._cooperative_plans[key] = reserve_sms if prev is None else min(prev, reserve_sms). The guard at :158 computes required = max(self._min_reserve_sms, self._parallel_reserve_sms.get(key, 0)) and never includes prev, so a lowering re-registration always passes. Concretely: register_cooperative_plan(p, reserve_sms=8) records 8; register_cooperative_plan(p, reserve_sms=4) passes the guard (required == 0) and replaces 8 with min(8, 4) = 4; a correctly annotated register_parallel(p, q, reserve_sms=6) then raises. A floor must be monotone; every other aggregate in the class uses max (:135, :186-187). Not exercised by tests/preparation/test_scratch.py:548-584. Fix: self._cooperative_plans[key] = max(prev or 0, reserve_sms).
  4. docs/runtime-core-design.md:654-696 now contradicts the shipped behaviour. The section — which #709 itself rewrote — is scoped to "When a single-rank core declares an entry in Execution.persistent_workers" and lists only "two groups … or three groups … when prefix-cache offload is enabled with --lossless-kv-compression gpu". The PR makes a 2-way (codec, compute) split with no worker entry the shipped default for every non-worker core (model.rs:718-733, mod.rs:386-396), a topology that document says does not exist. docs/prefix-cache-offload.md:59-66 and helios/manifest.md:111-135 were updated; this file was not, and AGENTS.md:228 names it as the required doc for Protobuf/core-loading changes. Also stale: the Graph row at docs/core-format-design.md:222, which enumerates the record's fields and now omits the two fields Helios reads at load. Fix: update both.
  5. The public single-rank loader hardcodes reserve_codec_partition = false, so codec isolation and both new bounds are skipped on that path. mod.rs:335 (prepare_kernels(..., None, false) — the explicit false is added by this PR) and mod.rs:342-344 (initialize → initialize_with_options(.., false)), reached from NativeResources::load (:208), load_any (:232), load_selected (:269) and PayloadAuthorizedCore::load (protection.rs:2836). For a codec-enabled non-worker core loaded there, primary_context is false (:386), green_partition stays None (:793), every graph instantiates on self.context (:962), offload_context() falls back to the base context (:1511-1516), and neither min_compute_sms (:964-980) nor the cluster check (:1067-1096) is applied — silently. The main serving path is correct (model.rs:729-733, :859-867), and no production caller of the load_prepared path was found (only event_tests.rs:19, helios/tests/tools/test_{fixed_,}runtime_core.rs, and in-module tests), which is why this is not a blocker. Fix: thread the flag (or a LoadOptions/KvCompression argument) through load_prepared/initialize/PayloadAuthorizedCore::load, or fail closed when a core needs codec SMs and the flag is absent.

Subtract / Simplify

  1. resolve_reserve_sms(..., plan=...) is provably a no-op — delete the kwarg and _parallel_reserve_sms. ignition/preparation/scratch.py:137-146: floor = self.reserve_sms_floor is max(self._min_reserve_sms, self._max_parallel_reserve_sms), and every _parallel_reserve_sms[key] is assigned max(..., reserve_sms) in lockstep with _max_parallel_reserve_sms = max(..., reserve_sms) (:186-187), so per_plan <= _max_parallel_reserve_sms <= floor always and max(floor, per_plan) == floor. The body reduces to return max(requested, self.reserve_sms_floor). The test that appears to cover it (tests/preparation/test_scratch.py:559) cannot distinguish the branch because register_parallel(plan_a, plan_b, reserve_sms=4) at :556 already raised the arena-wide max to 4.
  2. Split out or drop the whole ScratchArena surface until it has a consumer. register_cooperative_plan, require_reserve_sms, resolve_reserve_sms, reserve_sms_floor, and min_reserve_sms appear only in ignition/preparation/scratch.py:59-188 and tests/preparation/test_scratch.py:548-607; no recipe, component, or preparation path calls them, and docs/core-design.md:821 / docs/preparation-development.md:256 still describe register_parallel as byte sizing only. AGENTS.md:167-169 ("Hypothetical future consumers … do not establish a need") and :188-193 ("Do not present scaffolding or partially wired features as supported") apply directly, and 139 lines of it ride with a CUDA fix.
  3. The cluster-dimension decode is written twice, with a magic 4 on only one side. Export uses a named constant and helper (capture.rs:462-489); load re-implements the identical parse with a bare literal at helios/src/runtime_core/mod.rs:1067-1078 — same attribute id, same three-u32 layout, same max(1) product, same overflow message. Move one decode next to the wire::Attribute type and call it from both.
  4. Duplicated Green Context API guard. mod.rs:387-396 rejects the missing-driver case before persistent_worker::create can run, so the ok_or_else at persistent_worker.rs:255-261 with the same message is unreachable from the load path. Keep one.
  5. Two identical passes over core.graphs. mod.rs:795-808 walks the graph list twice, once per field; one fold((0, 0), ..) or a Core::graph_sm_requirements() returning (u32, u32) (mirroring the identically shaped export-side helper) collapses them.
  6. (Option<u32>, bool) encodes an unrepresentable-but-checked state. persistent_worker.rs:85-91 and :247-254 both take five positionals, forcing the reject check at :96-100, the Some(0) check at :101-105, and the unreachable!() arm at :157. A PartitionRequest enum (Worker(u32) | Codec | WorkerAndCodec(u32)) makes all three illegal states unrepresentable and collapses two arguments into one along the initialize_with_options → prepare_kernels → create path.

Nits

Dropped on verification