Final review report · NVIDIA/hyperflare-inference #684

Raw Markdown for agents: https://autobot.eidonix.com/p/3d5d966f-600d-4f59-ac6b-974d96a0200f.md

Recommendation: Changes Requested

The core change in PreparedSampling._filter_scores is a clean, high-value simplification (+19/−9 across 2 files) that collapses up to 192 sequential CUDA graph nodes at C=64 into one batched FlashInfer out-op launch with no Helios runtime, Protobuf, or core compatibility regressions. However, two concrete blockers must be resolved before merge: the PR depends on unmerged upstream local-inference-lab/flashinfer#208 with no pin or CI gate enforcing merge order, and the real production export paths (compile_forward and aot_forward) plus tests/components/test_sampling_flashinfer.py have not been exercised against the new torch.ops.flashinfer.sampling_from_probs_out custom op. Stale RNG contract documentation and the charter's served-workload performance evidence bar also need to be addressed.

Merge Risk

Level: High

Walkthrough

Pre-merge Checks

Blockers

  1. Unmerged upstream dependency (local-inference-lab/flashinfer#208) with no pin or CI gate (ignition/components/flashinfer_sampling.py:45-47, pyproject.toml:47)

    • Verified behavior & impact: sample_probabilities_out calls torch.ops.flashinfer.sampling_from_probs_out with 10 positional arguments including row_independent_rng, which does not exist until local-inference-lab/flashinfer#208 lands. Contrary to the PR description's instruction to "update the FlashInfer pin before merging", pyproject.toml:47 tracks branch = "main" (flashinfer-python = { git = "https://github.com/local-inference-lab/flashinfer.git", branch = "main" }) and there is no uv.lock in the repository, so nothing enforces merge order and CPU CI (.github/workflows/python-cpu.yml:29-33 (not opened)) passes even against a FlashInfer main lacking #208.
    • Fix: Merge local-inference-lab/flashinfer#208 into FlashInfer main first, verify this PR against the merged FlashInfer main commit (and update the PR description to remove the nonexistent pin-update step or pin the exact revision per charter #215).
  2. Compiled/AOT preparation paths and tests/components/test_sampling_flashinfer.py are completely unverified on the new custom op (ignition/components/flashinfer_sampling.py:41-47, ignition/preparation/compilation.py:519,618-620,728-735, ignition/preparation/aot.py:361-364,539-542, tests/components/test_sampling_flashinfer.py:145-205)

    • Verified behavior & impact: Production core exports compile forwards via compile_forward and aot_forward, which trace @torch.compiler.allow_in_graph helpers under make_fx(..., tracing_mode='fake'), wrap mutating OpOverloads in flare::storage_call only when _mutated_tensors sees alias_info.is_write on the op schema (compilation.py:728-735), and serialize/reload the op via importlib.import_module(definition._init_fn.__module__) (aot.py:361-364,539-542). The PR's GPU check only ran eager PreparedSampling.__call__ in a raw torch.cuda.CUDAGraph and skipped tests/components/test_sampling_flashinfer.py (whose CapturedSampler tests compile_forward=[False, True, 'aot'] at :145, compiled in (False, True) slot/capacity invariance at :183-205, invalid/stale/disabled rows at :208-260, and workspace reuse at :112-142). Any missing fake kernel, missing mutates_args annotation on samples/valid, or lazy op-registration failure during AOT restore would break real exports silently or at export time.
    • Fix: After flashinfer#208 lands, run FLARE_RUN_CUDA_TESTS=1 on tests/components/test_sampling_flashinfer.py (rebuilding flare-heliopause with --features qualification so GraphReplayWorker is available per ignition/preparation/graphs.py:115-116, or at minimum verifying compile_forward + aot_forward round-trip serialization/deserialization and all slot-invariance/edge-case tests on GPU) and report the results in the PR description.

Should Fix

  1. Update the stale RNG contract in PreparedSampling and design docs (ignition/components/sampling.py:467-472, docs/core-design.md:1289-1294, docs/mtp-design.md:486-491)

    • Verified behavior & impact: All three places still document the deleted one-row loop as the active contract:
      • ignition/components/sampling.py:467-472: "Each row uses a separate FlashInfer call with device seed and offset=4*counter. CUDA's Philox subsequence is therefore zero regardless of packed row or physical slot. ... FlashInfer's temporary outputs remain inside the captured graph." — Both claims are now false (_filter_scores issues one batched launch directly into prepared scratch).
      • docs/core-design.md:1290-1292: "Each request uses a one-row draw with Philox subsequence zero and word offset 4 * counter" — now false as written.
      • docs/mtp-design.md:486-491: Explicitly permits this substitution ("unless a library API supplies an equally qualified request-keyed stream"), but its opening sentence ("The ordinary decode sampler (ignition/components/sampling.py) uses one-row FlashInfer calls") is now stale.
    • Fix: Update all three passages to state the present-state mechanism: a single batched FlashInfer sampling_from_probs_out launch writing directly into prepared scratch with row_independent_rng=True, preserving per-request (seed, offset) RNG independence across packed rows and physical slots.
  2. Provide served-workload or complete-graph A/B performance evidence (docs/performance-work.md:37-47, docs/core-design.md:1276-1279, docs/design-review.md:109-112)

    • Verified behavior & impact: The charter (#210), docs/design-review.md:109-112, and docs/performance-work.md:45-47 require performance PRs to demonstrate before/after results on a complete exported core (flare run CORE --embedding-table-storage ram), and docs/core-design.md:1277-1278 states "Measure sampler cost inside the complete graph before changing it". The PR currently reports only a component graph node count (192 → 1 launch, 23 total nodes) and leaves whole-model decode latency unmeasured.
    • Fix: Measure before/after re-export decode step latency / throughput on an exported core with flare run (especially at higher concurrency where the old 192-node loop is largest), or — if project owner @lukealonso explicitly accepts graph-node reduction as sufficient justification — record that scope explicitly on the PR rather than claiming an unmeasured serving speedup.

Subtract / Simplify

  1. Hardcode row_independent_rng=True in sample_probabilities_out (ignition/components/flashinfer_sampling.py:42-47)

    • The new keyword-only parameter defaults to row_independent_rng=False, which no Flare caller can validly use without breaking batch-slot RNG invariance (tests/components/test_sampling_flashinfer.py:183-205). Match verify_chain right below it (ignition/components/flashinfer_sampling.py:50-54): drop the row_independent_rng=False parameter, pass True directly, and carry the invariant in a one-line comment (# Each row draws from its own seed and offset only, so its tokens do not depend on its batch slot.).
  2. Delete sample_probabilities if unused by external recipes (ignition/components/flashinfer_sampling.py:34-38)

    • After switching sampling.py to sample_probabilities_out, a repo-wide search confirms sample_probabilities has zero in-tree callers, yet this PR expands its signature (+3/−1). Because flashinfer_sampling is a retained Helios-ABI interface module (tests/preparation/test_core_boundary.py:16) that external recipes in local-inference-lab/hyperflare-recipes may import (as with verify_chain at :50-54), confirm whether any external recipe calls sample_probabilities; if none does, delete lines 34-38 outright instead of carrying an untested dead wrapper.

Nits

Dropped on verification