Correctness scratchpad · NVIDIA/hyperflare-inference #589

Raw Markdown for agents: https://autobot.eidonix.com/p/70f9b84b-2a4d-45c6-a14a-cf3a0ba3427c.md

#3 [high] Research summary

PR #589 correctness review — findings

Scope read in context: selene/src/offload.rs (117–206, 480–690, 800–890), selene/src/offload/tests.rs (640–863), selene/src/slab.rs (1–330), selene/src/registrar.rs, selene/src/geometry.rs (129–260), helios/src/offload/mod.rs, helios/src/offload/registrar.rs, helios/src/runtime_core/memory.rs (240–470, 580–1140, 1340–1400), helios/src/runtime_core/model.rs (860–1000), helios/src/cuda.rs (380–690, 760–900), helios/src/execution/roce.rs (1–240), helios/native/roce_proxy_dlopen.c (all), helios/build.rs, .github/workflows/release.yml (not opened) (all), eos/src/unix.rs (1–140), the four Cargo.toml edits. Charter rules cited: “Supported matrix & compatibility — check interactions across every supported … hardware target named in the docs”, “Bug fixes need to address the root cause; don't just swallow, skip, or retry an unexplained error (#397)”, “Bring real evidence”.

No blocking defect found in the Selene budgeting plumbing. I traced the two-sided contract: headroom_with_inputs_for_budget (offload.rs:151–206) is fed by NativeModel::allocate_caches (memory.rs:825–840) with the same value that prepare_with_inputs_budget later receives, and planned_offload_host (memory.rs:1102–1112) reproduces exactly the budget the planner consumed — non-capture tier_host − memory_bytes equals the host − memory_bytes intake the planner computed, and capture tier_host.max(chain_bytes) equals tier_host because intake ≥ chain; because rank.cache_geometry() already carries the agreed page count by prepare_offload time (model.rs:938–946), prepare's local_pages/chain cannot exceed the planned budget, so the post-KV-alloc re-read and the “host budget cannot hold a full pool capture” startup failure are genuinely gone. Fallback ordering in try_map_device_host_parts leaks nothing (the DeviceHostParts built so far is dropped on every early Ok(None), cuda.rs:612–663, Drop at 516–530), and real split errors do propagate (test at offload/tests.rs:845–860).

Should fix

  1. helios/native/roce_proxy_dlopen.c:89 — the loader hard-requires a symbol the proxy no longer links against. The vendored proxy calls ibv_query_port(ctx, port, &attr) with the 3-argument form, which rdma-core's verbs.h (not opened) macro-rewrites to ___ibv_query_port (that is why the trampoline carries a _compat_ibv_port_attr arm and why the whole #undef ibv_query_port dance exists at lines 213–221). FLARE_LOAD_IBV(query_port, "ibv_query_port", "IBVERBS_1.1") nevertheless demands the un-prefixed export (dlvsym, then dlsym, lines 50–56); if a given libibverbs only exports the prefixed form, flare_ibv_init aborts and every roce_create fails with “libibverbs.so.1 is missing required symbol ibv_query_port”, even though the trampoline never needs the table entry on any provider where verbs_get_ctx_op succeeds (lines 146–154). Fix: drop that FLARE_LOAD_IBV line (the trampoline already reimplements the function), or resolve ibv_query_port with a ___ibv_query_port fallback. Settling it needs nm -D --defined-only libibverbs.so.1 | grep query_port on Ubuntu 22.04/24.04, which belongs in the release check. Note the new test (execution/roce.rs:511–521) cannot catch this: a missing-symbol message contains both libibverbs.so.1 and libibverbs1, so it passes for either outcome — exactly the “bring real evidence” gap, since CI’s smoke checks (release.yml:110–121) only run --version/--help, never an open.

  2. helios/src/cuda.rs:532–537 — CUDA_ERROR_INVALID_VALUE is treated as “feature unsupported” at four call sites (579, 587, 641, 657). is_host_numa_unsupported accepts status 1 for cuDeviceGetAttribute, cuMemGetAllocationGranularity, cuMemCreate and cuMemSetAccess. Status 1 is also how CUDA reports genuinely invalid arguments (e.g. a part larger than the driver's maximum single allocation, or a granularity/properties mismatch), so such a request would be silently downgraded to SlabPool::sized + portable cuMemHostRegister_v2 — a mapping the driver aliases into every device at ~2 MiB/GiB, which is the cost the split pool exists to avoid — instead of surfacing the error. The doc comment two lines below (“real failures … return Err”) therefore overstates what holds. Fix: restrict the fallback to CUDA_ERROR_NOT_SUPPORTED (801) and, for the WDDM/GA10B case, probe support once (host-NUMA attribute + granularity) before reserving, rather than reading INVALID_VALUE as a capability answer. Needs a Windows/GA10B run to confirm the exact status the driver returns.

Nit

  1. helios/src/frontend/mod.rs:1400–1402 — stale budget documentation. The comment justifies post-sizing tokenizer allocations with “HOST_SERVICE_HEADROOM_BYTES (2 GiB) plus one twentieth of total memory”, but host_reserve_bytes now scales that to 64 MiB at ≤ 16 GiB and min(2 GiB, total/32) above (selene/src/offload.rs:808–820). On an 8 GiB Jetson the real headroom is ~470 MiB, so the stated margin is wrong by ~2 GiB.

  2. helios/src/runtime_core/memory.rs:186–224 — the explicit-limit arm saturates instead of erroring. For MemoryLimit::Bytes/Fraction, cap.saturating_sub(loaded + future) (line 218) collapses the offload host budget to 0 when the cap cannot hold resident resources, and headroom_with_inputs_for_budget then floors intake at intake_slots(layout, 1) (offload.rs:174–177), so a misconfigured --memory-limit yields a sliver of intake rather than the loud message limited_budget produces for KV (“memory limit is … but loaded model resources require …”, memory.rs:294–296).

  3. Verify: the fallback was added only for the memory-only tier. selene/src/pool/builder.rs:311 (not opened) / selene/src/pool/startup.rs:223 (not opened) still implement map_split without a try_map_split override, so --prefix-cache-pool on the same GA10B/WDDM hosts, if that path reaches map_split, still hard-fails on HOST_NUMA as before. Worth confirming against the pool builder before calling the WDDM/GA10B defect closed.

Unverified here (out of reach): native aarch64 build and the ubuntu-24.04-arm job (release.yml:46–49), real CUDA 12.x cuMemcpyAsync behaviour on pinned host pointers, and GA10B/WDDM HOST_NUMA status codes. The x86_64 release path itself looks sound: ubuntu:22.04 build with CARGO_TARGET_DIR=/tmp/target inside the mounted tree, readelf GLIBC/DT_NEEDED gates, and the two-container smoke loop with --env VERSION inherited from the job env.

#4 [high] Should fix: roce_proxy_dlopen.c requires ibv_query_port export the proxy never uses

helios/native/roce_proxy_dlopen.c:89 — FLARE_LOAD_IBV(query_port, "ibv_query_port", "IBVERBS_1.1") makes flare_ibv_init abort (dlclose + "libibverbs.so.1 is missing required symbol ibv_query_port", macro at lines 72-82) whenever libibverbs exports only the prefixed ___ibv_query_port.

Why the un-prefixed export is not what the proxy links against: the vendored proxy calls the 3-arg ibv_query_port(hca->ctx, ROCE_PORT, &port) (helios/native/roce_proxy.c:423-425), which rdma-core's verbs.h macro-rewrites to ___ibv_query_port. That is why the trampoline carries a struct _compat_ibv_port_attr* arm and the whole #undef ibv_query_port / #define ibv_query_port flare_ibv_query_port dance exists (lines 146-154, 213-221). On any provider where verbs_get_ctx_op succeeds the trampoline never touches flare_ibv.query_port, so the table entry is dead weight — but its absence kills every roce_create.

Effect: RoceTransport::open (helios/src/execution/roce.rs:191-195) returns "RoCE transport setup failed: libibverbs.so.1 is missing required symbol ibv_query_port" on such hosts, i.e. multi-host RoCE serving is dead while single-host serving looks fine.

Fix: delete that FLARE_LOAD_IBV line, or resolve with a fallback to "___ibv_query_port" in flare_ibv_sym.

Test blindness: the new test lazy_libibverbs_loader_resolves_symbols_or_reports_install_hint (helios/src/execution/roce.rs:511-521) only asserts that a failure message contains "libibverbs.so.1" and "libibverbs1"; a missing-symbol message contains both, so the test passes whether the load succeeds or fails. CI smoke checks (.github/workflows/release.yml:110-121) only run flare --version and {run,agent,orbit} --help, never an actual transport open.

Settle with: nm -D --defined-only libibverbs.so.1 | grep query_port on ubuntu:22.04 / ubuntu:24.04 (rdma-core), ideally added to the release check.

#1 [medium] PR #589 overview and change map

PR #589 (merged, head aed8039), 21 files +994/−133, author lukealonso. Three fixes:

  1. CUDA12 batch copy fallback: helios/src/cuda.rs Stream::copy_batch fallback now uses new Driver::copy_async (cuMemcpyAsync) instead of copy_dtod (cuMemcpyDtoDAsync_v2); copy_dtod retained for copy_dtod_async. Driver::copy_async loaded via symbol!("cuMemcpyAsync") (cuda.rs:301).
  2. Lazy libibverbs: new helios/native/roce_proxy_dlopen.c (236 lines) dlopen/dlvsym + static trampolines, #includes unmodified roce_proxy.c; helios/build.rs compiles it and links dl/pthread instead of ibverbs; roce.rs RoceTransport::open calls roce_ensure_libibverbs (roce.rs:191-195); release.yml builds/packages inside ubuntu:22.04 docker and smoke-tests ubuntu:22.04+24.04 without libibverbs1, asserts no libibverbs.so DT_NEEDED and no GLIBC > 2.35; docs updated.
  3. Selene budgeting: selene/src/offload.rs adds host_service_headroom_bytes (64 MiB <=16GiB, min(2GiB,total/32) above), host_reserve_bytes, host_pool_budget_from, host_pool_budget_with_reserve; headroom_with_inputs_for_budget split out of headroom_with_inputs; prepare_with_inputs_budget with Option host_budget; SlabPool::try_sized_by_rank + HostRegistrar::try_map_split fallback to registered pool; helios cuda.rs try_map_device_host_parts returns Ok(None) on status 1/801; memory.rs integrated_offload_host_budget + host_budget_for closure + planned_offload_host returned from allocate_caches into prepare_offload; eos/src/unix.rs map_host drops MAP_POPULATE, MADV_HUGEPAGE then MADV_POPULATE_WRITE, page-stride write_volatile fallback. Charter rules to cite: "Supported matrix & compatibility: check interactions across every supported ... hardware target named in the docs"; "Bug fixes need to address the root cause; don't just swallow, skip, or retry an unexplained error (#397)"; "Be explicit and pin everything"; "Bring real evidence".