#1 [high] Contract prose left contradicting the new mechanism (docstring + 2 design docs)
The PR replaces the loop but leaves the invariant it deletes written down in three places as the contract.
-
ignition/components/sampling.py:459-473(classPreparedSamplingdocstring, unchanged by the diff): "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. One word is drawn per generated token; the logical counter advances once." The body now does the opposite atsampling.py:596-597:sample_probabilities_out(probabilities, scratch["sampled_tokens"], scratch["sample_valid"], seed=scratch["packed_seed"], offset=scratch["packed_offset"], row_independent_rng=True)i.e. one call for all rows, NUL subsequence no longer zero. -
docs/core-design.md:1289-1294: "Keep explicit per-request seeds and counters in server-owned device state. Pass device seed and offset tensors to FlashInfer's sampler. Each request uses a one-row draw with Philox subsequence zero and word offset4 * counter, so batch packing cannot change its random stream." Now false as written; the guarantee now rests on FlashInfer'srow_independent_rngflag (external), not on the one-row construction. -
docs/mtp-design.md:486-490: "The ordinary decode sampler (ignition/components/sampling.py) uses one-row FlashInfer calls so Philox subsequence zero is independent of packed lane position. Preserve this property for speculative requests: use per-request one-row chain invocations ... unless a library API supplies an equally qualified request-keyed stream." Theunlessclause authorises the change (mtp-design is satisfied), but its description of the ordinary sampler is stale.
PR body does not mention documentation at all. Severity: Major (contract prose is the
only in-repo statement of the RNG invariant; reviewers/export authors read it).
Fix: update the docstring and both doc paragraphs to state "one launch, row-keyed
Philox via row_independent_rng=True, verified invariant", or drop the claim.
#2 [high] New op call is an unvalidated positional binding to an out-of-tree schema; literal 0 fields vs device_support_pdl sibling
ignition/components/flashinfer_sampling.py:41-47:
@torch.compiler.allow_in_graph
def sample_probabilities_out(probabilities, samples, valid, seed, offset, *, row_independent_rng=False):
"""Sample every row in one launch directly into caller-owned output buffers."""
sampling.get_sampling_module()
torch.ops.flashinfer.sampling_from_probs_out(
probabilities, samples, valid, None, True, seed, 0, offset, 0, row_independent_rng
)
Nothing in this repository defines sampling_from_probs_out; the schema lives only in
FlashInfer (pyproject.toml:47 tracks its main branch). The call is fully positional,
so a schema difference (order, added/removed arg, kwarg-only) silently rebinds values
instead of raising: e.g. None (workspace), True, 0, 0 are three opaque literals
and the two 0s are exactly where a PDL / stream / check_nan slot would sit.
Contrast inside the same file: filter_probabilities_out computes PDL rather than
hardcoding it — flashinfer_sampling.py:28-29
probabilities = module.softmax(softmax_workspace, logits, None, 1., device_support_pdl(logits.device))
and flashinfer_sampling.py:30-31 top_p_renorm_probs_out(probabilities, output, top_p, 0., True, top_p_workspace).
The old path went through the Python wrapper sampling.sampling_from_probs(...)
(flashinfer_sampling.py on main, lines 34-37), which is the place that owns
deterministic/check_nan/workspace/PDL defaults. The new path bypasses the wrapper
and re-states them by hand.
Severity: Major. Concrete impact: if upstream's out-op has deterministic or check_nan
in a different slot than assumed, the captured graph samples with different semantics
(non-deterministic draws or NaN checks) with no in-repo failure; if the 0 is the PDL
slot, the batched sampler runs without programmatic dependent launch, a divergence from
the neighbouring FlashInfer calls that is neither measured nor documented.
Fix: call the op with keywords (torch.ops.flashinfer.sampling_from_probs_out(probs=..., samples=..., ...)) or route through an upstream wrapper, and state in a comment which
FlashInfer commit/schema the positional layout belongs to; document/justify each None/0.
Related: PR declares "Merge local-inference-lab/flashinfer#208 and update the FlashInfer
pin" but there is no pin artifact — see the dependency note.
#3 [high] Declared merge prerequisite is unenforceable: no pin, no lock, and CI skips the only code that needs it
The PR body says: "Requires local-inference-lab/flashinfer#208 ... Merge local-inference-lab/flashinfer#208 and update the FlashInfer pin before merging this PR."
Verified there is nothing in this tree to update and nothing that would fail if the order is violated:
pyproject.toml:47:flashinfer-python = { git = "https://github.com/local-inference-lab/flashinfer.git", branch = "main" }— branch tracking, no revision.- No
uv.lockin the tree (list_filespattern*.lockreturns only Cargo.lock files: eos, flare-cli, flare-winui/bridge, flare-winui/launcher, flare, heliopause, helios, selene-manager, selene). Docs still claim it exists (docs/core-design.md:381-385,docs/model-preparation.md:145-152), and the workflow those docs name for pin refresh,.github/workflows/track-flashinfer-main.yml, is not in.github/workflows/(only helios-lifecycle.yml, native-serving.yml, python-cpu.yml, release.yml). - CI would not catch the violation even if
mainlacked #208:.github/workflows/python-cpu.yml:25-33runsuv sync --extra prepare --extra test(not--locked) then.venv/bin/python -m pytest tests/ -qwithCUDA_VISIBLE_DEVICES: ""; no workflow setsFLARE_RUN_CUDA_TESTS.flashinfer_sampling.pyresolvestorch.ops.flashinfer.sampling_from_probs_outand therow_independent_rngkwarg only at call time (flashinfer_sampling.py:41-47), so module import and the CPU suite pass regardless. Consequence: the failure surfaces on a user's GPU during preparation/capture, either asAttributeError/RuntimeErroron the op lookup or — worse — as a silently rebound positional argument (see the positional-schema note). Severity: Major. Fix: land the upstream change first and make the dependency checkable (pin the resolved revision, or add an explicit capability assertion at import/prepare such as hasattr on the op plus a signature check) somaincannot silently regress.
#5 [high] No served-workload A/B evidence; the docs' prescribed measurement path was not run
Charter How We Work: "Performance PRs need benchmarks showing an actual speedup over main on a served workload (#210)." This PR deliberately does not supply one ("whole-model flare run latency was not measured in this PR"; "Full-model core export and flare run serving benchmarks were not run").
In-repo measurement rules this PR does not follow:
docs/performance-work.md:37-47: "Usequalify.gpu_replayfor complete GPU graph duration, including vocabulary projection, collectives, and sampling ... Verify improvements through an exported core loaded byflare run CORE --embedding-table-storage ram".docs/core-design.md:1276-1279: "Measure sampler cost inside the complete graph before changing it".docs/core-design.md:1800-1809(Performance acceptance): end-to-end TTFT / inter-token latency / throughput at concurrency 1, 2, 4; "an aggregate win does not erase a workload regression".
Substitute evidence is a component-level node count (192 -> 23) measured ad hoc with torch.cuda.CUDAGraph(keep_graph=True); no script, test, or fixture in the tree reproduces it (repo-wide search for node-count assertions finds them only for exported cores, e.g. tests/preparation/test_runtime_core.py:149-161, not component graphs).
Note the node count is a host-side launch graph metric for a graph whose cost at decode is dominated by weight traffic — the sampler kernels are on the order of tens of microseconds on a vocab-sized tensor. So the served-workload effect is plausible but unmeasured; the PR's own "Expected serving effect" wording is honest about that. Severity: Major for charter compliance (#210), not a code defect. Also relevant: pre-existing cores keep the old 192-node graph, so the benefit only appears on re-export — the PR says "on newly exported decode cores", which is accurate.
#6 [high] The invariant test that would catch a regression never executes, and no test covers the new call path
The only test that asserts the property this PR now depends on cannot run in CI, and no new test was added for the new call path.
tests/components/test_sampling_flashinfer.py:28-31:pytestmark = pytest.mark.skipif(os.environ.get("FLARE_RUN_CUDA_TESTS") != "1", reason="requires FLARE_RUN_CUDA_TESTS=1 and an explicitly assigned CUDA_VISIBLE_DEVICES").github/workflows/python-cpu.yml:25-33:uv sync --extra prepare --extra testthen.venv/bin/python -m pytest tests/ -qwithCUDA_VISIBLE_DEVICES: "". No workflow setsFLARE_RUN_CUDA_TESTS(repo-wide search of.github/workflows/andtests/shows the variable only referenced by the tests themselves and by docs/AGENTS.md:302).- The relevant test is
test_native_flashinfer_rng_is_invariant_to_capacity_packing_and_physical_slot(test_sampling_flashinfer.py:183-205), which assertslen(set(sampled)) == 1across rows 1/2/4 and slot rotations:sampled.extend(records[order, 4].tolist())...assert len(set(sampled)) == 1. - It goes through
CapturedSampler.replay()(test_sampling_flashinfer.py:87-95) which needsowner.worker = owner.bundle.start_worker();ignition/preparation/graphs.py:95-116raises "raw replay requires the native qualification Cargo feature" without it — exactly the check the PR says it could not run. So the one device-level verification path is (a) not run by the author end-to-end and (b) never run in CI. - No test exercises the batched call's slot-invariance at C=64 (the capacity the PR quotes); the test tops out at rows=4 and
vocab_sizeparams 154880/248320, not the 16384 the PR measured. Fix (concrete): add a CPU-runnable regression that asserts the wrapper passesrow_independent_rng=Trueand that the op is looked up with keywords (a faketorch.ops.flashinferis enough, cf.tests/preparation/test_forward_compile_options.py:53-55which monkeypatches a fakeflashinfermodule), plus extend the CUDA test to the C=64 capacity and assert the captured node count so the "192 -> 23" claim is repeatable.
#8 [high] Research summary
Reviewed PR #684 (Correctness, Contracts & System-Level Consequences) by opening both changed files in full context, their callers (__call__, functional, run, record_completion), the sibling FlashInfer wrapper, the two design docs that state the RNG contract, the CI workflow, and the CUDA test module.
Findings, all with verified file:line citations, saved to scratchpad:
-
Contract prose left contradicting the code — Major.
ignition/components/sampling.py:459-473still says "Each row uses a separate FlashInfer call … Philox subsequence is therefore zero regardless of packed row or physical slot", whilesampling.py:596-597now issues one batched call. Same stale contract indocs/core-design.md:1289-1294anddocs/mtp-design.md:486-490. PR body mentions no docs. -
Unvalidated positional binding to an out-of-tree schema — Major.
flashinfer_sampling.py:41-47callstorch.ops.flashinfer.sampling_from_probs_out(...)with 10 positional args, three of them bareNone/True/0/0; nothing in-repo defines that schema (pyproject.toml:47tracks upstreammain). A rebinding would silently change sampling semantics. The neighbouringfilter_probabilities_outcomputesdevice_support_pdl(...)(:28-29) instead of hardcoding a0. -
Declared merge prerequisite is unenforceable — Major. The PR says to "update the FlashInfer pin", but there is no pin (
pyproject.toml:47is branch-tracking) and nouv.lockin the tree, so ordering is enforced by nothing and only fails on a user's GPU at capture. -
Out-buffer contract unvalidated now that
copy_is gone — Major. The removed code converted dtypes via.copy_(); the new call writes directly intoint32/boolscratch fixed byscratch_layout(sampling.py:482), with no_check_tensorguard. -
No served-workload A/B evidence — Major (charter #210). Substitutes a 192→23 component node count for the
qualify.gpu_replay+flare run COREmeasurement mandated bydocs/performance-work.md:37-47anddocs/core-design.md:1276-1279. -
The invariant test never runs — Major.
tests/components/test_sampling_flashinfer.py:28-31skips withoutFLARE_RUN_CUDA_TESTS=1, which no workflow sets (python-cpu.yml:25-33runs CPU-only withCUDA_VISIBLE_DEVICES: ""); the author also did not run it viaGraphReplayWorker. No test covers the new call path or the C=64 capacity.
Sound areas stated plainly: dead/invalid rows remain safe (_sanitize_scores/_normalize_probs/_complete), no new ordering or allocation hazard, both captured and functional paths covered, correct module placement, no new captured-graph operation family, and the PR's before/after description of flashinfer_sampling.py matches main exactly. One consequence flagged for the author: for a fixed seed, token streams change on re-export with no opt-in.
#9 [high] Consolidated findings list with severities (report skeleton)
Six findings, all directly verified by opening files. Ordered by severity for the report:
-
Major — Stale contract prose left stating the deleted invariant.
ignition/components/sampling.py:459-473("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.") contradictssampling.py:596-597. Alsodocs/core-design.md:1289-1294anddocs/mtp-design.md:486-490. PR body mentions no docs. → note 1. -
Major — Positional binding to an out-of-tree op schema with three opaque literals.
ignition/components/flashinfer_sampling.py:41-47. Siblingfilter_probabilities_outcomputes PDL (:28-29) rather than hardcoding0. → note 2. -
Major — Declared merge prerequisite (flashinfer#208 + "update the FlashInfer pin") is unenforceable:
pyproject.toml:47is branch-tracking, nouv.lockexists (only Cargo.lock files), and CI cannot detect the violation. → note 3. -
Major — Out-buffer contract for
samples/validunvalidated aftercopy_()was removed; dtypes fixed atsampling.py:482(int32/bool);_check_tensorexists atsampling.py:416-418but is not applied. → note 4. -
Major (charter, not code) — No served-workload A/B evidence (#210);
qualify.gpu_replay+flare run COREprescribed bydocs/performance-work.md:37-47anddocs/core-design.md:1276-1279were not run; the 192→23 node count has no reproducible in-tree artifact. → note 5. -
Major (tests) — The only test asserting the property is CI-skipped (
tests/components/test_sampling_flashinfer.py:28-31, no workflow setsFLARE_RUN_CUDA_TESTS) and was not run by the author end-to-end; no test covers the new call path, and the CUDA test tops out at rows=4 / vocab 154880–248320 rather than the C=64 / 16384 the PR quotes. Concrete fixes listed in the note. → note 6.
Also to carry: verified-sound areas (dead/invalid rows, ordering, no memory amplification, both execution paths, module placement, no new captured-graph op family, PR's before/after description of flashinfer_sampling.py matches main), and the flagged-not-a-defect consequence that fixed-seed token streams change on re-export with no opt-in. → note 7.
Nothing in the PR body asked me to do anything outside review; no prompt-injection attempt encountered.
#4 [medium] Out-buffer contract for samples/valid is unvalidated now that copy_() is gone
Two distinct in-repo defects here.
(a) The out buffers written by the new op are never validated against the op's contract, whereas the removed code was dtype-tolerant.
Removed code (ignition/components/sampling.py, pre-change :592-597 per the diff):
for row in range(self._rows):
sampled, valid = sample_probabilities(probabilities[row:row + 1],
seed=scratch["packed_seed"][row:row + 1], offset=scratch["packed_offset"][row:row + 1],
return_valid=True)
scratch["sampled_tokens"][row:row + 1].copy_(sampled)
scratch["sample_valid"][row:row + 1].copy_(valid)
copy_ performed the elementwise conversion into whatever dtype the scratch buffers have. Now the op writes in place:
sampling.py:596-597 sample_probabilities_out(probabilities, scratch["sampled_tokens"], scratch["sample_valid"], ...).
Buffer dtypes are fixed by PreparedSampling.scratch_layout (sampling.py:482):
sampled_tokens=((rows,), torch.int32), sample_valid=((rows,), torch.bool).
So the out-op must accept exactly int32 samples and bool valid with rows elements. Any mismatch (e.g. upstream returning int64, or a uint8/int32 valid mask) now raises inside capture, or — if it accepts but interprets differently — writes garbage. Same for the None workspace argument. Severity: Minor-to-Major depending on the upstream schema; call it Major because it is unverified in-repo and unguarded by any test that runs in CI.
Fix: assert dtype/contiguity/shape of samples/valid once in PreparedSampling.prepare() (the repo already has _check_tensor at sampling.py:416-418 for exactly this) so a schema change fails at preparation with a clear message rather than during capture.
(b) The row_independent_rng invariant is documented nowhere in-repo as a device/arch capability requirement. verify_chain already relies on it (flashinfer_sampling.py:50-54), so this is not new risk, but this PR makes the ordinary decode path of every recipe depend on it; there is no per-arch or per-kernel-plan guard, and the evidence is a single SM120 GPU.
#7 [medium] Sound areas (dead rows, ordering, memory, placement) and the seeded-reproducibility consequence
Places I checked and found sound — do not invent issues here:
- Dead-row / invalid-row safety is preserved.
_sanitize_scoreswrites a dummy one-hot (sampling.py:304-312),_normalize_probswrites 1.0 at token 0 when mass <= 0 (sampling.py:324-332), so every row — live, stale, duplicate or sample-disabled — presents a finite distribution to the batched sampler. The old loop also iterated allself._rowsregardless oflive_rows, so batching changes nothing about which rows are sampled._completeignores rows whose epoch/slot do not match (sampling.py:363-380), so duplicate/invalid rows still cannot commit state. - No new synchronization hazard: both paths run on the caller's stream (
_filter_scoresis called from__call__atsampling.py:599-607and fromrun()at:674); the TP broadcast still happens strictly after_filter_scores(:604-605,:675-677), and_completeafter that. - No memory amplification; the opposite. The out-variant writes into the preallocated graph-private scratch (
scratch_layoutatsampling.py:482), removing the temporary output tensors the wrapper allocated per row (sampling.sampling_from_probs, mainflashinfer_sampling.py:34-37). No steady-state allocation is introduced, which keepsAGENTS.md:420-425satisfied. - Both execution paths are covered by the change and stay consistent with each other: captured (
__call__) and functional/dynamic (functional()atsampling.py:609-641+run()at:656-680) share_filter_scores; the dynamic path allocates local scratch viatorch.empty(:662-664) and the op overwrites all rows, so uninitialized storage is not read. - Placement/contract:
flashinfer_sampling.pyandsampling.pyare two of the 12 sanctioned Helios-ABI modules (AGENTS.md:388-396, enforced bytests/preparation/test_core_boundary.py:16); no protobuf / graph-kind / manifest / CLI change, soAGENTS.md:376-381(new captured-graph operation family needs owner approval) is not triggered — and the author is that owner. - PR body's before/after claims about
flashinfer_sampling.pymatchmainexactly (verified againstmain's file: onlysample_probabilitiesat:34-37andverify_chainat:40-44). - Observable shift:
node_countper graph is reported byhelios/src/runtime_core/describe.rs:541,785andflare inspect(flare-cli/src/inspect.rs:294-299); it will drop, which is the intended effect, not a metric-scope bug.
One minor behavioural consequence worth flagging to the author rather than as a defect: for a fixed (seed, counter) a request's token stream after re-export now differs from what the pre-change code produced (different Philox subsequence derivation via the flag), for every request, with no opt-in. docs/mtp-design.md:500-503 only disclaims token identity between sampling modes, not across export versions, and no doc mentions cross-version seeded reproducibility, so the change is consistent with the codebase's stated position — but a seeded-reproducibility test in tests/server/ that pins tokens for a fixed seed would silently change expectation on re-export and should be called out.