Code review summary report · NVIDIA/hyperflare-inference #589

Raw Markdown for agents: https://autobot.eidonix.com/p/04cdbe5b-4f86-4b08-9c90-c00198e2c282.md

PR #589 — candidate brief for adjudication (merged, head aed8039, 21 files, +994/−133)

Assembled from six upstream lenses (Architecture, Conventions, Simplicity, Correctness, Prose, Subtractive). ~30 raw findings → 1 candidate blocker, 8 candidate should-fix, 3 candidate subtract/simplify, 1 grouped nit block. Every claim below was re-opened at head; exact lines quoted so no further fetching is needed.

Key findings


Candidate Blockers

1. CUDA_ERROR_INVALID_VALUE (1) is read as "platform unsupported" → silent substitution of the allocation strategy

Lenses: Architecture #1, Correctness #2 (both rank it their top finding). Where: helios/src/cuda.rs:532-537, :577-590, :641-660; consumer selene/src/offload.rs:631-638.

/// `CUDA_ERROR_INVALID_VALUE` (1) or `CUDA_ERROR_NOT_SUPPORTED` (801), returned by
/// CUDA drivers on platforms without `CU_MEM_LOCATION_TYPE_HOST_NUMA` VMM support
/// (such as Windows WDDM and integrated Tegra/GA10B GPUs).
fn is_host_numa_unsupported(status: c_int) -> bool {
    matches!(status, 1 | 801)
}

Consumed four times inside try_map_device_host_parts, each turning a failure into Ok(None) — cuda.rs:577-590:

            let node_status =
                (driver.device_attribute)(&mut node, ATTRIBUTE_HOST_NUMA_ID, device);
            if is_host_numa_unsupported(node_status) {
                return Ok(None);
            }
            driver.check("cuDeviceGetAttribute", node_status)?;
            // A host without NUMA reports -1 and takes node 0.
            properties.location.id = node.max(0);
            let gran_status =
                (driver.granularity)(&mut granularity, &properties, GRANULARITY_MINIMUM);
            if is_host_numa_unsupported(gran_status) {
                return Ok(None);
            }

and cuda.rs:641-660:

            let create_status = (driver.memory_create)(&mut handle, nbytes, &properties, 0);
            if is_host_numa_unsupported(create_status) {
                return Ok(None);
            }
            driver.check("cuMemCreate", create_status)?;
            ...
            let access_status =
                (driver.memory_access)(start, nbytes, access.as_ptr(), access.len());
            if is_host_numa_unsupported(access_status) {
                return Ok(None);
            }
            driver.check("cuMemSetAccess", access_status)?;

What Ok(None) buys, selene/src/offload.rs:631-638:

                match slab::SlabPool::try_sized_by_rank(&layout, bytes, intake, &contexts, registrar)? {
                    Some(pool) => pool,
                    None => {
                        let mut pool = slab::SlabPool::sized(&layout, bytes, intake)?;
                        pool.register(registrar, context)?;
                        pool
                    }
                }

Why it matters. Status 1 is also how CUDA reports a genuinely invalid argument — a part larger than the driver's maximum single allocation, wrong handle/flags, bad granularity rounding, a resident-context mistake in the newly added cuMemSetAccess path. Those requests now silently downgrade to a registered anonymous mapping whose cost is documented at selene/src/slab.rs:254-260 ("Registering one mapping maps it into every device at about 2 MiB of device memory per GiB") — the exact cost the split pool exists to avoid. Grounds: AGENTS.md:182-186 ("Do not remove validation, suppress errors, silently substitute execution paths") and the charter's "don't just swallow, skip, or retry an unexplained error (#397)".

The change is also internally inconsistent: cuMemMap (cuda.rs:652) and the address-reserve path still hard-error, so a HOST_NUMA-less platform can return Err as well as Ok(None) depending on which call reports first. And the docstring at cuda.rs:546-547 — "Returns Ok(None) when the driver reports HOST_NUMA VMM allocation is unsupported on this platform; real failures (such as out-of-memory) return Err" — overstates what holds: only non-INVALID_VALUE errors propagate. The PR description repeats the same overstatement ("real errors such as OOM propagate unchanged").

Fix options: (a) narrow the predicate to CUDA_ERROR_NOT_SUPPORTED (801) and probe capability explicitly before reserving (host-NUMA attribute presence, or cuMemGetAllocationGranularity for CU_MEM_LOCATION_TYPE_HOST_NUMA); or (b) if status 1 must be accepted for one documented driver/platform pair, constrain it to that single call and cite the driver behaviour in the comment. Settled only by a GA10B/WDDM run showing which status each of the four calls returns — flag as hardware-dependent, not decidable here.


Candidate Should Fix

2. copy_batch's contract states the opposite of the fallback added directly beneath it

Lenses: Architecture #2, Prose #1. Where: helios/src/cuda.rs:781-790 vs :824-833; symbol resolution cuda.rs:239-248, 303.

    /// Issue one batched copy of `destinations[i] <- sources[i]` for `sizes[i]`
    /// bytes each, in stream order on both sides. Every address is a device
    /// address, including the device alias of registered host memory. CPU
    /// addresses of registrations are not necessarily GPU-accessible. The batch
    /// carries at most [`BATCH_BYTES`] and [`BATCH_ENTRIES`]; larger batches and
    /// empty entries are rejected. An empty batch issues nothing.
    ///
    /// # Safety
    /// Every range stays valid and, for host sources, unchanged until the
    /// stream passes the copy.

versus the added fallback, cuda.rs:824-833:

        // Fallback for CUDA < 13.0 drivers (e.g. JetPack 6 / CUDA 12.6 on Jetson Orin
        // and discrete CUDA 12.x GPUs) where cuMemcpyBatchAsync_v2 is absent: issue
        // individual UVA stream-ordered copies via cuMemcpyAsync, which accepts device
        // addresses, registered host aliases, and raw cuMemHostAlloc(..., flags=0) pointers.
        for ((&dst, &src), &size) in destinations.iter().zip(sources.iter()).zip(sizes.iter()) {
            self.driver.check("cuMemcpyAsync", unsafe {
                (self.driver.copy_async)(dst, src, size, self.handle as Handle)
            })?;
        }

The description names helios/src/execution/transport.rs (not opened) (frame.input.address() from host_buffer, i.e. allocate_host(nbytes, 0) at cuda.rs:850-854; mapped_host_buffer is the flags=3 variant) and helios/src/offload/transfer.rs (not opened) as callers that pass exactly the pointers the contract excludes.

Why it matters: a stale # Safety/behaviour contract on a pub(crate) unsafe fn is a correctness hazard for the next caller, and AGENTS.md:52-60 makes docstrings present-state specification. Related, same fix: cuMemcpyAsync is now a hard-required entry point — cuda.rs:303 copy_async: symbol!("cuMemcpyAsync"),, resolved by symbol! at cuda.rs:239-248, which returns Err when absent — so a driver lacking it fails at Driver::load, not at copy time. docs/prefix-cache-offload.md:645-655 lists the bound symbols and the fallback but not that requirement.

Fix: rewrite 781-786 to distinguish the two paths (batch entry point requires device addresses including registered aliases; the CUDA < 13 fallback additionally accepts UVA-reachable pinned host pointers with flags = 0), and add cuMemcpyAsync as required to the symbol list.

3. The integrated host budget is computed twice in one module, and the copies already diverge

Lenses: Correctness #4, Conventions #2, Simplicity #4, Subtractive #1. Where: helios/src/runtime_core/memory.rs:195-221 vs :183-190, 267-298; and :646-681 vs :877-904.

fn integrated_offload_host_budget(
    memory: MemorySnapshot,
    loaded: u64,
    limit: Option<MemoryLimit>,
    future: u64,
) -> u64 {
    match limit {
        None => flare_selene::offload::host_pool_budget_from(
            memory.free,
            memory.total,
            future,
            true,
        ),
        Some(MemoryLimit::Reserve(reserve)) => memory
            .free
            .min(memory.total)
            .saturating_sub(reserve)
            .saturating_sub(future),
        Some(limit) => {
            let physical = memory.free.min(memory.total).saturating_sub(future);
            match limit.occupied_bytes(memory.total) {
                Some(cap) => physical.min(cap.saturating_sub(loaded.saturating_add(future))),
                None => physical,
            }
        }
    }
}

The established implementation, same file, memory.rs:183-190 + :288-298:

fn budget(free: u64, total: u64, headroom: u64, integrated: bool, explicit_limit: bool) -> u64 {
    let host = if integrated && !explicit_limit { host_reserve_bytes(total) } else { 0 };
    free.saturating_sub(headroom.saturating_add(host))
}
...
    let required = loaded
        .checked_add(future)
        .ok_or_else(|| invalid("loaded memory footprint overflows the device budget"))?;
    let remaining = cap.checked_sub(required).ok_or_else(|| invalid(format!(
        "memory limit is {cap} bytes, but loaded model resources require {required} bytes"
    )))?;
    Ok(available.min(remaining))

Why it matters: the new function is limited_budget arm for arm — limited_budget(memory, loaded, limit, 0, /*integrated=*/true, future) already expresses the None arm via budget's integrated && !explicit_limit rule, its Reserve headroom, and its cap logic. Two real divergences: the cap case saturates to 0 instead of emitting the loud "memory limit is … bytes, but loaded model resources require … bytes" diagnostic; and 0 is then floored at intake_slots(layout, 1) (selene/src/offload.rs:174-177), so a misconfigured --memory-limit yields a sliver of intake rather than the error the KV path produces. The new test integrated_offload_host_budget_matches_small_soc_scaling_and_explicit_limits (memory.rs:1492-1525) pins the copy rather than the shared helper.

Second half of the same finding — the per-rank fold is written twice inside one function and the copies disagree about total: memory.rs:648-654 takes m.total.min() over integrated ranks while :879-887 uses total: observations[index].total; :674-681 takes a max observed free drop over integrated ranks while :904 uses initial[index].free.

Fix: express the host pool budget through limited_budget(memory, loaded, limit, 0, true, future) (deleting ~30 lines and the ~33-line test that duplicates occupied_limits_include_loaded_resources_and_use_total_capacity), and compute per-integrated-rank state once into a Vec after observations (memory.rs:640-645), indexing it in both host_budget_for (:684-694) and the loop.

4. Stale reserve formula in the one comment that explains the second encoding

Lenses: Conventions #1, Simplicity #5, Correctness #3, Prose #2. Where: helios/src/frontend/mod.rs:1400-1402 vs selene/src/offload.rs:802-820.

    /// That second encoding allocates host memory after the host cache is sized. The memory draws
    /// on the headroom `host_pool_budget` (selene/src/offload.rs) leaves unallocated:
    /// `HOST_SERVICE_HEADROOM_BYTES` (2 GiB) plus one twentieth of total memory.

The PR replaced exactly that rule:

pub const HOST_SERVICE_HEADROOM_BYTES: u64 = 2 << 30;
pub const HOST_SYSTEM_SHARE: u64 = 20;
...
pub fn host_service_headroom_bytes(total: u64) -> u64 {
    if total <= (16u64 << 30) {
        64 << 20
    } else {
        HOST_SERVICE_HEADROOM_BYTES.min(total / 32)
    }
}
/// Implicit host reserve (service headroom plus the system share) when no explicit
/// memory limit overrides it.
pub fn host_reserve_bytes(total: u64) -> u64 {
    host_service_headroom_bytes(total) + total / HOST_SYSTEM_SHARE
}

Why it matters: on the 8–16 GiB Jetson/SoC hosts this PR is fixing, the real margin is 64 MiB + 5%, not 2 GiB + 5% — overstated by ~1.9 GiB, at the only site in the tree that spells the constraint out, while HOST_SERVICE_HEADROOM_BYTES is still exported at 2 GiB (offload.rs:802) making the stale prose look authoritative. docs/prefix-cache-offload.md:1138-1145 was updated to the new rule, so the comment is the inconsistent pair. Fix: one-line edit to cite host_reserve_bytes / host_service_headroom_bytes, or repeat the new formula.

5. The libibverbs loader hard-requires ibv_query_port, a symbol only the trampoline's compat branch reads (severity gated on one nm -D)

Lens: Correctness #1 (sole raiser). Where: helios/native/roce_proxy_dlopen.c:72-82, 89, 146-154, 213-221.

#define FLARE_LOAD_IBV(field, name, version)                                      \
  do {                                                                            \
    void* sym = flare_ibv_sym(handle, name, version);                             \
    if (sym == NULL) {                                                            \
      snprintf(flare_ibv_err, sizeof(flare_ibv_err),                              \
               "libibverbs.so.1 is missing required symbol %s", name);            \
      dlclose(handle);                                                            \
      return;                                                                     \
    }                                                                             \
    memcpy(&flare_ibv.field, &sym, sizeof(sym));                                  \
  } while (0)
...
  FLARE_LOAD_IBV(query_port, "ibv_query_port", "IBVERBS_1.1");

The entry is read only on the trampoline's fallback branch, :146-154:

static int flare_ibv_query_port(struct ibv_context* context, uint8_t port_num,
                                struct ibv_port_attr* port_attr) {
  struct verbs_context* vctx = verbs_get_ctx_op(context, query_port);
  if (!vctx) {
    memset(port_attr, 0, sizeof(*port_attr));
    return flare_ibv.query_port(context, port_num, (struct _compat_ibv_port_attr*)port_attr);
  }
  return vctx->query_port(context, port_num, port_attr, sizeof(*port_attr));
}

The vendored proxy's own call is the 3-argument form (helios/native/roce_proxy.c:424), which rdma-core's verbs.h (not opened) macro-rewrites to ___ibv_query_port — that rewrite is why the trampoline and the #undef/#define dance exist. When verbs_get_ctx_op succeeds, flare_ibv.query_port is never read, so the table entry is dead weight whose absence kills every roce_create.

Judgment call to hand downstream: flare_ibv_sym (:50-56) tries dlvsym(handle,name,version) then dlsym(handle,name), so a version-node mismatch is already tolerated; the only fatal case is libibverbs not exporting the un-prefixed name at all (rdma-core also exports ___ibv_query_port). If the plain symbol is exported this is a load-time strictness nit; if not, RoceTransport::open fails with "missing required symbol ibv_query_port" (helios/src/execution/roce.rs:192-195) and multi-host RoCE is dead while single-host serving looks fine. Settled by nm -D --defined-only libibverbs.so.1 | grep query_port in ubuntu:22.04 and ubuntu:24.04. Note neither the new test (#6) nor the release smoke checks can distinguish the outcomes — .github/workflows/release.yml:110-121 (not opened) only runs flare --version / {run,agent,orbit} --help, never a transport open. Fix: drop that FLARE_LOAD_IBV line, or make flare_ibv_sym fall back to ___ibv_query_port for this one symbol.

6. Two new tests can pass while asserting nothing

Lens: Simplicity #3. Where: helios/src/execution/roce.rs:511-523; eos/src/unix.rs:207-248 (:214-245).

#[test]
fn lazy_libibverbs_loader_resolves_symbols_or_reports_install_hint() {
    let mut message = [0 as c_char; 512];
    // SAFETY: `message` is a valid writable buffer of length 512.
    let status = unsafe { roce_ensure_libibverbs(message.as_mut_ptr(), message.len() as u64) };
    if status != 0 {
        let text = unsafe { CStr::from_ptr(message.as_ptr()) }.to_string_lossy();
        assert!(
            text.contains("libibverbs.so.1") && text.contains("libibverbs1"),
            "unexpected dlopen error: {text}"
        );
    }
}

When libibverbs.so.1 is present — normal on GPU hosts and on any runner with libibverbs-dev — status == 0 and the body is empty; and the failure branch cannot fail either, because a missing-symbol message contains both substrings. So it establishes neither of the two outcomes its name claims.

eos::map_host_advises_hugepages_and_prefaults_zeroed_pages guards its hg VmFlags assertion behind smaps-readable + address-found + VMA-block-found + VmFlags:-present, recovering the block end by re-counting hex lines (~25 lines of nested find/position/take computing offsets it never uses); any miss and it asserts nothing and passes, on exactly the hosts where smaps parsing is fragile. Mitigation: the zero-fill assertion at :212 does assert, so the test is not useless — but the hg claim in its name can go unchecked.

Fix: hoist the smaps block lookup into a helper returning Option<&str> and .expect(...) on it (collapsing the length re-counting to skip_while/take_while); in the roce case assert the applicable branch (0 => assert!(a symbol resolves), _ => assert!(hint)) or delete it — release.yml:110-121 already proves the no-libibverbs1 path. Rule: AGENTS.md:194-199.

7. map_split is a required trait method that production never reaches; map_device_host_parts and sized_by_rank are dead

Lenses: Simplicity #2, Conventions #3, Subtractive #3. Where: selene/src/registrar.rs:22-37; helios/src/cuda.rs:667-676; selene/src/slab.rs:261-270; helios/src/offload/registrar.rs:27-37.

    fn map_split(&self, requests: &[(usize, i32, usize)]) -> Result<Box<dyn SplitMapping>>;

    /// Like [`HostRegistrar::map_split`], returning `Ok(None)` when the device
    /// or driver does not support per-rank `HOST_NUMA` split mappings so the
    /// caller can fall back to a registered anonymous host mapping. Allocation
    /// failures such as out-of-memory still return `Err`.
    fn try_map_split(
        &self,
        requests: &[(usize, i32, usize)],
    ) -> Result<Option<Box<dyn SplitMapping>>> {
        self.map_split(requests).map(Some)
    }

map_split is required, so ~12 impls carry it — selene/src/registrar.rs:26, helios/src/offload/registrar.rs:27, selene/src/pool/builder.rs:311 (not opened), selene/src/pool/startup.rs:223 (not opened), selene/src/pool/net.rs:976 (not opened), selene/src/pool/engine/tests.rs:155 (not opened), selene/src/pool/engine/net_tests.rs:44 (not opened), selene/src/testing.rs:453 (not opened),490, selene/src/offload/tests.rs:800, selene-manager/tests/client.rs:1100 (not opened),1298,3147 — mostly error-returning placeholders. Production reaches CudaRegistrar::try_map_split instead (helios/src/offload/registrar.rs:31-38, via SlabPool::try_sized_by_rank at selene/src/offload.rs:631), so map_split's default body is its only caller and that caller is unreachable. That in turn leaves map_device_host_parts with exactly one caller that is itself unreachable:

/// Like [`try_map_device_host_parts`], returning an error when `HOST_NUMA` VMM
/// allocation is unsupported on this device or driver.
pub(crate) fn map_device_host_parts(requests: &[(usize, i32, usize)]) -> Result<DeviceHostParts> {
    try_map_device_host_parts(requests)?.ok_or_else(|| {
        Error::execution(
            ExecutionError::State,
            "HOST_NUMA virtual memory allocation is not supported on this device or driver",
        )
    })
}

Same shape: SlabPool::sized_by_rank (selene/src/slab.rs:261-270) now only wraps try_sized_by_rank, with test-only callers (selene/src/slab.rs:631, helios/src/offload/transfer.rs:1723 (not opened)).

Fix: make try_map_split the trait's single required method, delete map_split, map_device_host_parts, sized_by_rank and the UnsupportedSplitRegistrar shim (selene/src/offload/tests.rs:785-813). Caveat for the adjudicator: the crates are publish = false and no non-test workspace caller exists, so only a maintainer can confirm no out-of-tree implementor of HostRegistrar exists.

8. The arm64/JetPack 6 headline claim rests on x86_64-only evidence, and the docs state it as qualification

Lenses: Architecture #3/#4/#5, Prose #4. Where: docs/release.md:30-31; .github/workflows/release.yml:46-49 (not opened), 81-121; docs/TODO.txt.

- The Linux executables are built in Ubuntu 22.04 and require glibc 2.35 or
  later (covering Ubuntu 22.04+, JetPack 6, and Ubuntu 24.04+).

(a) Evidence: the headline is "flare-linux-arm64.tgz can start on stock JetPack 6", supported by an x86_64 build inside ubuntu:22.04 plus readelf/GLIBC_ reads on the amd64 artifact; the body itself lists "Native aarch64 build and ubuntu-24.04-arm CI run" as unrun, and all live-GPU paths (discrete CUDA 12.x, GA10B, WDDM) as untested. The linux job's arm64 leg already exists (os: ubuntu-24.04-arm, arch: arm64, build-packages: libibverbs-dev) and runs the same ELF checks and dual-container smoke, so the check is runnable via workflow_dispatch and was not run. docs/design-review.md (not opened) principle: disclosure does not excuse skipping runnable CPU checks.

(b) Prose state: AGENTS.md:52-60 requires support to be stated as present qualification and unrun checks recorded in docs/TODO.txt; docs/TODO.txt contains no JetPack/Orin/GA10B/WDDM/libibverbs/arm64 entry. Nothing establishes the arm64 archive's glibc ceiling, its absence of a libibverbs.so DT_NEEDED entry, or that it starts on JetPack 6. The parenthetical also reads as if JetPack 6 were a glibc level distinct from Ubuntu 22.04, which it is not.

(c) Scope — a judgment call, no lens found a code defect. Four independent outcomes ride in one PR (AGENTS.md:198-199 "Keep each PR focused on one coherent outcome"): the CUDA 12 copy fallback; the arm64 release portability change (release.yml + the 236-line vendored roce_proxy_dlopen.c + build.rs); the Selene/helios host-budgeting rework; the eos::unix THP reordering. Two of them extend support to Jetson Orin 8–32 GiB / GA10B, which appear nowhere in the charter's Goals (SM103/SM120/SM121, DGX Spark) and fall under Non-Goals "broad hardware support" that "require an explicit maintainer sign-off before starting work" (AGENTS.md:171-175, :201-206). No sign-off is cited. Counterweight the adjudicator must weigh: the author is a charter-designated priority contributor (@lukealonso, "carry extra weight — we never close their PRs out of hand") and the PR is already merged, so this reads as a follow-up, not a rejection.

Fix: run the linux arm64 leg (or a native cargo build --release --features roce with the ELF checks applied) and attach output; or qualify release.md:30-31 to "require glibc 2.35 or later, the level of Ubuntu 22.04 and of JetPack 6's Ubuntu 22.04 root filesystem" and add the unrun check to docs/TODO.txt.

9. Docs still describe the pre-PR linked libibverbs model

Lenses: Prose #3, Conventions #8. Where: THIRD_PARTY_NOTICES.md:76-78; packaging/debian/package.sh:46-48; docs/debian.md:3-6, 61-64; docs/prefix-cache-offload.md:1483-1485; contrast helios/build.rs:67-77.

The NVIDIA CUDA driver is loaded from the user's system. Linux aarch64 builds
also link the system libibverbs and pthread interfaces for RoCE. Platform C/C++
runtime libraries remain system dependencies for the CLI. The CLI release
archive packager copies no shared libraries or CUDA SDK components.

No build links libibverbs any more — helios/build.rs:67-77 emits only dl/pthread:

#[cfg(feature = "roce")]
{
    println!("cargo:rerun-if-changed=native/roce_proxy.c");
    println!("cargo:rerun-if-changed=native/roce_proxy_dlopen.c");
    cc::Build::new().file("native/roce_proxy_dlopen.c").std("gnu11").compile("flare_roce_proxy");
    println!("cargo:rustc-link-lib=dl");
    println!("cargo:rustc-link-lib=pthread");
}

THIRD_PARTY_NOTICES.md is shipped in the archive, so it misstates the redistribution dependency in the document whose whole purpose is to state it — while docs/release.md:32-35 and docs/runtime-core-design.md:9-12 (not opened) were both updated to "loads libibverbs.so.1 lazily at run time". Same class, three more: packaging/debian/package.sh:46-48 hard-adds ibverbs-providers for arm64 (if [[ "$arch" == arm64 ]]; then dependencies+=", ibverbs-providers"; fi) now that dpkg-shlibdeps derives nothing from a binary with no DT_NEEDED entry — it works today because ibverbs-providers pulls libibverbs1, so this is a packaging/doc consistency gap, not a runtime defect; docs/debian.md:3-6,61-64 still says the ARM64 build "includes RoCE support" with a hard verbs dependency and no runtime-optional caveat; docs/prefix-cache-offload.md:1483-1485 says "--all-features enables the roce and rdma features, which link libibverbs" when only rdma (selene's ibverbs-sys) links it. (helios/Cargo.toml:28-29's "rdma … links libibverbs" remains correct as written.)

Fix: "also load the system libibverbs (through dlopen) and link the pthread interface for RoCE"; align docs/debian.md and the --all-features note with docs/release.md's wording; decide deliberately whether the ARM64 Debian dependency stays hard or becomes a recommendation (product decision, not stated in the code).


Candidate Subtract / Simplify

10. Collapse the prepare / headroom ladders; the buggy post-KV re-query survives as the default arm (~50 lines)

Lenses: Simplicity #1, Conventions #3, Subtractive #2 and #4. Where: selene/src/offload.rs:603-619, :484-534, :117-206; helios/src/offload/mod.rs:72-129.

            let (_, host) = match host_budget {
                Some(budget) => options.headroom_with_inputs_for_budget(
                    contexts.len(),
                    &layout,
                    max_active,
                    input_staging != 0,
                    local_pages,
                    budget,
                )?,
                None => options.headroom_with_inputs(
                    contexts.len(),
                    &layout,
                    max_active,
                    input_staging != 0,
                    local_pages,
                )?,
            };

The shape this PR set out to remove — re-evaluating host_pool_budget after KV allocation — is the None arm, and None is the default for every caller but one. Production always passes Some: helios/src/runtime_core/model.rs:933 returns early when the cache is disabled and :967-977 forwards planned_host_budget, which is Some whenever the cache is enabled (memory.rs:1102-1112). Every None caller is a test (selene/src/offload/tests.rs, selene/src/offload/sharded/tests.rs:108 (not opened),247,375,537, helios/src/offload/pool/tests.rs:124).

Around it: a three-deep ladder prepare (:484-495) → prepare_with_inputs (:497-520) → #[allow(clippy::too_many_arguments)] prepare_with_inputs_budget (:522-534), mirrored again in helios/src/offload/mod.rs:72-129 — where prepare at :72-80 has no caller anywhere in the tree; plus a headroom_with_inputs / headroom_with_inputs_for_budget pair (:117-206) that duplicates the enabled()/memory/disk/capture derivation twice (:125-137 and :160-165); plus a second too_many_arguments allow. Subtractive measures ~52 lines here and ~31 in helios/src/offload/mod.rs.

Subtractive option kept (per merge rule): one entry point taking host_budget: u64; delete the Option, the None arm, the prepare_with_inputs shims in both crates and both too_many_arguments allows. This is preferred over Conventions/Simplicity's milder "thread Option<u64> through the existing functions" — merging keeps the subtraction and removes the last compiled path that can size the pool twice.

Also in this seam, kept as subtractive rather than expansion: host_pool_budget_from's four-argument form is fine to keep as the single parameterised helper, but headroom_with_inputs should absorb its own default (one function with host_budget: Option<u64> folded at the top) rather than staying a twin — ~30 lines, and the 15 test call sites gain a trailing None.

11. Delete the apply_reserve switch — one caller, one value, ~11 lines

Lenses: Conventions #4, Simplicity #6, Subtractive #7. Where: selene/src/offload.rs:851-861 → :885; helios/src/runtime_core/memory.rs:202-207.

/// Keep the same scaled server allowance and system share as integrated GPU planning.
pub fn host_pool_budget(future: u64) -> Result<u64> {
    host_pool_budget_with_reserve(future, true)
}

/// Like [`host_pool_budget`], allowing callers with an explicit unified-memory limit
/// to omit the implicit service and system reserves.
pub fn host_pool_budget_with_reserve(future: u64, apply_reserve: bool) -> Result<u64> {

Whole-tree caller set verified: host_pool_budget_with_reserve has exactly one caller, offload.rs:853, with true; host_pool_budget_from(..., apply_reserve) is called only from offload.rs:885 and memory.rs:202-207, both true; false appears only in test assertions (selene/src/offload/tests.rs:722-723) exercising the flag directly. The explicit-limit case the docstring names never reaches this function — it goes through integrated_offload_host_budget (item 3). This is the "configuration switches without a concrete requirement" case in AGENTS.md:188-193, and it departs from its own delegate host_pool_budget_from, which is a pure function genuinely called with both values.

Fix: delete the wrapper, end host_pool_budget with Ok(host_pool_budget_from(available, total, future, true)), and drop the parameter (drop host_pool_budget_from too once item 3 routes through limited_budget).

12. Dead code in the new native shim (~18 lines): the iova2 path and the re-entrant init guard

Lens: Subtractive #6 (lower severity, real dead code). Where: helios/native/roce_proxy_dlopen.c:108-115, 171-179, 184-193 and the struct field at :46; :157-163 (the get_device_list guard).

The vendored proxy calls ibv_reg_mr in exactly two places — helios/native/roce_proxy.c:443-444 and :560-561 — both with only IBV_ACCESS_LOCAL_WRITE | IBV_ACCESS_REMOTE_WRITE, never IBV_ACCESS_OPTIONAL_RANGE, so the #ifdef branch routing to ibv_reg_mr_iova2 (and the optional IBVERBS_1.8 dlvsym plus its table field) is unreachable; the trampoline reduces to return flare_ibv.reg_mr(pd, addr, length, (int)access);. Separately, flare_ibv_get_device_list re-runs roce_ensure_libibverbs(NULL, 0) and sets errno = ENOSYS, but its only Rust route is RoceTransport::open, which has already called roce_ensure_libibverbs and returned the install hint before roce_create (helios/src/execution/roce.rs:191-195). The 17 one-line trampolines themselves must stay — they exist so no ibv_* symbol is exported and roce_proxy.c stays byte-identical.


Candidate Nits (grouped, mechanical)

  1. CUDA status literals where the repo keeps named constants. helios/src/cuda.rs:535-537 matches bare 1 | 801; the convention is named constants (helios/src/runtime_core/driver.rs:94-97 declares CUDA_ERROR_NOT_READY: c_int = 600, CUDA_ERROR_PRIMARY_CONTEXT_ACTIVE: c_int = 708; cuda.rs:143-160 names every other driver constant it uses). Constraint the fix must respect: runtime_core is behind #[cfg(feature = "runtime-core")] (helios/src/lib.rs:22-26) while cuda.rs always compiles, so the constants must be declared beside the cuda.rs:143-160 ones, not imported. Folds into item 1's fix.
  2. Duplicated prefault loop. eos/src/unix.rs:109-117 repeats eos/src/windows.rs:178-183 byte for byte (let step = page_size().max(1); for offset in (0..bytes).step_by(step) { ptr.cast::<u8>().add(offset).write_volatile(0); }). Move prefault_zeroed(address, bytes) next to page_size() in eos/src/lib.rs (not opened) and call from both. Keep the MADV_POPULATE_WRITE probe — a deliberate Linux ≥ 5.14 hedge (Ubuntu 22.04 ships 5.15).
  3. Duplicate type alias. helios/src/cuda.rs:80-81: type CopyAsync = unsafe extern "C" fn(u64, u64, usize, Handle) -> c_int; is character-for-character CopyDtoD — the only duplicate pair in the alias table. Use copy_async: CopyDtoD or rename the shared alias; the fallback itself is correct.
  4. Conditional — redundant HOST_NUMA probes (medium confidence). cuda.rs:577-590's attribute and granularity checks may be redundant with the cuMemCreate check if a HOST_NUMA-less driver fails there with the same status pair; deleting that pair saves ~10 lines plus a 6-line doc block. This touches driver-error assumptions, so it must not be merged into item 1's narrowing without a GA10B/WDDM run — pass as conditional.
  5. Description prose — one merged item (per pre-filter rule). (i) "redirects all 17 ibv_* calls to static trampolines" counts the 17 redirect names, not the calls — roce_proxy.c also calls ibv_post_send (:822, 871, 957, 1128, 1299) and ibv_poll_cq (:753), which are verbs.h (not opened) inline wrappers needing no trampoline. (ii) The "What changed" bullets carry exhaustive parenthetical file inventories, against AGENTS.md:116-121. (iii) "real errors such as OOM propagate unchanged" repeats item 1's overstatement. The description's structure is otherwise compliant (AGENTS.md:74-102 four-question order, observed-vs-expected split, unrun checks listed) — do not raise it.

Dropped as noise (so the adjudicator does not re-open)

Open questions (only these need adjudication or a machine)

  1. Item 1: which status does each of the four HOST_NUMA calls actually return on GA10B and on Windows WDDM? Only a live run distinguishes "platform unsupported" from a genuine INVALID_VALUE, and it decides between narrowing to 801 and constraining status 1 to one call.
  2. Item 5: does stock rdma-core libibverbs.so.1 export un-prefixed ibv_query_port? nm -D --defined-only libibverbs.so.1 | grep query_port inside ubuntu:22.04 / ubuntu:24.04 settles whether this is a nit or a dead multi-host path.
  3. Item 8(a): is the arm64 archive's glibc ceiling and DT_NEEDED set equal to the amd64 artifact's? Only the unrun ubuntu-24.04-arm leg can show it.
  4. Item 3: is integrated_offload_host_budget behaviourally identical to limited_budget(..., headroom 0, integrated true, ...) for Reserve(0) and for a Bytes cap smaller than loaded + future? From the code it is not (saturate-to-0 vs the loud diagnostic), but a test asserting both paths agree would pin it.
  5. Item 7: does any out-of-tree implementor depend on HostRegistrar::map_split? Crates are publish = false and no workspace caller exists; only a maintainer can confirm.
  6. Item 8(c): which of the four bundled outcomes was the maintainer-requested one, and is there sign-off for Jetson Orin GA10B / 8–32 GiB SoC support? Not stated anywhere in the PR — this is the one answer that would move the disposition.

Ranked single-action guidance: act on #3 first (behavioural divergence, ~93 lines including its pinning test), then #10 (~50 lines of twin deletion that also removes the last path able to size the pool twice), then #1 (narrow to status 801 plus an explicit capability probe).