Skip to content

fix(comm): preserve PCIe IPC tuning under unrelated outer autotune - #1

Closed
ormandj wants to merge 5 commits into
qsang-nv:pcie-ipc-allreducefrom
ormandj:fix/pcie-ipc-outer-autotune-cache
Closed

ormandj wants to merge 5 commits into
qsang-nv:pcie-ipc-allreducefrom
ormandj:fix/pcie-ipc-outer-autotune-cache

Conversation

@ormandj

@ormandj ormandj commented Aug 14, 2026

Copy link
Copy Markdown

📌 Description

This is a focused follow-up to flashinfer-ai#4393.

A caller can wrap model warmup in a FlashInfer autotune context that replaces the singleton tuner's active file cache without installing the distributed process group required to profile the PCIe-IPC collective.

Previously, PcieIpcAllReduceWorkspace treated any active autotune context as permission to call choose_one(). In an unrelated outer context, the workspace could lose its explicitly loaded tuning cache or retain the seed launch configuration.

This change:

  • exposes the runner's collective-safe can_profile() predicate;
  • profiles candidates only when autotune is active and the required distributed tuning group is installed;
  • reloads the workspace's explicit tuning cache when an unrelated outer autotune context replaced the singleton cache; and
  • performs the normal cache lookup using the workspace's own bucket policy.

Serving and autotune validation

The change was exercised in the actual SGLang serving stack, not only through a mocked unit test.

The tested configuration used:

  • two RTX PRO 6000 Blackwell Max-Q GPUs, SM120, TP2 over PCIe Gen4 x16;
  • DeepSeek-V4-Flash-0731 with DSPARK block size 5;
  • SGLang's enclosing FlashInfer model-warmup autotune context;
  • a persisted PCIe-IPC tuning cache;
  • SGLANG_PCIE_IPC_MAX_NUMEL=786432;
  • CUDA graph capture and replay; and
  • clients running inside the serving pod against localhost.

Both TP ranks initialized PCIe-IPC successfully, the tuned serving configuration remained active after the enclosing autotune context, and the server completed the complete release qualification.

Matched backend profiling

The following measurements establish that the parent PCIe-IPC backend was exercised by the serving stack. They are not presented as isolated performance attribution for this cache-preservation follow-up.

The NCCL and PCIe-IPC captures used matched source, image, model arguments, graph sizes, token IDs, cache policy, and profiler settings. Each result retained 127 complete paired target-plus-draft graph steps.

Workload NCCL step PCIe-IPC step Change
C1 15.681 ms 14.965 ms -4.57%
C8 35.399 ms 33.421 ms -5.59%

At C8, all 11,938 captured all-reduce operations used PCIe-IPC. The per-rank timeline reductions were:

Rank Time removed per step Share of NCCL step
0 1.734 ms 4.90%
1 1.781 ms 5.03%

Prefill-sized reductions remained on NCCL.

Integration qualification

The source-equivalent release stack containing the outer-autotune fix produced these five-repetition medians:

Concurrency Forward passes/s
C1 63.864
C2 47.737
C4 34.322
C8 22.968
C16 17.304
C32 12.722

Cold-prefill aggregate results, with five requests per length:

Prompt length Prompt tok/s
8K 7,776.8
32K 8,743.1
64K 8,464.5
128K 7,966.6

Quality and long-output results:

  • GSM8K: 1,261/1,319 correct, zero request errors.
  • Long output: 8/8 HTTP successes with finish_reason=stop.
  • Structural validation: 8/8 passed all configured checks.

These are integration results for the complete serving stack. They are not attributed solely to this follow-up.

🔍 Related Issues

🚀 Pull Request Checklist

✅ Pre-commit Checks

  • I have installed pre-commit by running pip install pre-commit or used an equivalent environment.
  • I have installed the hooks with pre-commit install.
  • I have run the hooks manually with pre-commit run --all-files.

🧪 Tests

  • Tests have been added or updated as needed.
  • The focused tests pass.
  • The change has been exercised under the real SGLang outer-autotune serving path.

Focused tests:

uv run --no-project pytest -q tests/comm/test_pcie_ipc_policy.py tests/comm/test_pcie_ipc_tuning.py

The regression test verifies that an unrelated active autotune context reloads the workspace cache, performs one cache lookup, selects the cached tactic, and does not attempt unsafe collective profiling.

Reviewer Notes

This follow-up does not change PCIe-IPC kernels, topology policy, candidate generation, or the parent PR's tuning algorithm. It only distinguishes a collective-safe tuning context from an unrelated process-global autotune context.

Prepared with AI assistance.

qsang-nv and others added 5 commits August 6, 2026 22:50
Signed-off-by: Qidi Sang <200703406+qsang-nv@users.noreply.github.com>
Signed-off-by: Qidi Sang <200703406+qsang-nv@users.noreply.github.com>
Signed-off-by: Qidi Sang <200703406+qsang-nv@users.noreply.github.com>
Signed-off-by: Qidi Sang <200703406+qsang-nv@users.noreply.github.com>
When an unrelated outer autotune context replaces the singleton tuner's file cache but no distributed tune group is available, reload the workspace's explicit tuning cache and search it instead of retaining the seed tactic. Expose the runner's group-safe profiling predicate and cover the cache-restore path.

Signed-off-by: David Orman <ormandj@corenode.com>
qsang-nv pushed a commit that referenced this pull request Aug 18, 2026
…nfer-ai#4219)

## Issue
flashinfer-ai#4214
Addresses GDN-C1 / GDN-C2 / GDN-C3 / GDN-H1 from the GDN CuTe-DSL cache
audit (PR #1 of the suggested sequence).

## Summary

- Documented FP16 `q/k/v/a/b` on the BF16-state and FP32-state MTP
decode paths were silently reinterpreted as BF16 because the kernels
hard-code `cutlass.BFloat16` fragments. Convert those operands to BF16
at the kernel boundary (and stage non-BF16 caller `output=` on MTP).
- Add polymorphic operand dtypes (`A_log`, `dt_bias`, slot indices) to
the compile-cache identities so mixed-dtype sequences no longer collide.
- Stop returning a cached per-batch default `output` buffer from
BF16-state paths when `output=None`.
- Apply the same FP16 conversion on the WY output-only kernel; convert
slot indices to int32 when needed.
- Follow-up: non-BF16 MTP `output=` staging uses `output.to(bfloat16)`
(not `empty_like`) so negative-index padding rows keep
caller-initialized values.
- Assert documented `dt_bias` (bf16/fp32) and `initial_state_indices`
(int32/int64) dtypes at the public API.

## Test plan

- [x] New regressions in `tests/gdn/test_decode_delta_rule.py` (8
parametrizations): FP16 conversion, dtype / `dt_bias` interleaving,
default-output non-aliasing, non-BF16 `output=`, padding-slot
preservation, WY FP16
- [x] Those regressions fail on unmodified `main` (most on main) and
pass on this branch
- [x] Full `tests/gdn/test_decode_delta_rule.py`: **838 passed** on H100
NVL (`CUDA_VISIBLE_DEVICES=1`, `-x -vv`, ~38 min)
- [ ] GPU CI: `@flashinfer-bot run`

## Review

Independent re-review at `024e7c4f`: **approve-with-nits** (padding
critical fixed). Follow-up commits add comment trim + API dtype asserts.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Bug Fixes**
  * Improved validation for tensor data types, shapes, and index values.
* Fixed mixed-precision decode workflows, including proper BF16
conversion and preservation of requested output types.
* Prevented stale output reuse and preserved padding in partially filled
output buffers.
* Improved compilation behavior when switching between supported input
data types.

* **Tests**
* Added coverage for FP16/BF16 conversion, output handling, cache
isolation, index validation, and mixed-precision correctness.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@qsang-nv
qsang-nv force-pushed the pcie-ipc-allreduce branch from 9936fd5 to 34b6329 Compare August 19, 2026 01:25
@qsang-nv
qsang-nv self-requested a review as a code owner August 19, 2026 01:25
@qsang-nv

Copy link
Copy Markdown
Owner

Close this PR as its content is cherry picked in flashinfer-ai@830f79e. Thanks for the contribution!

@qsang-nv qsang-nv closed this Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants