[paddle-adapt] Fix CUDAGraphMoE for Paddle compat: ExternalStream + CUDA graph capture#27
Open
BingooYang wants to merge 1 commit into
Open
[paddle-adapt] Fix CUDAGraphMoE for Paddle compat: ExternalStream + CUDA graph capture#27BingooYang wants to merge 1 commit into
BingooYang wants to merge 1 commit into
Conversation
…§53: torch.cuda.ExternalStream unavailable in Paddle compat.\n Use torch.cuda.Stream() + stream_base.cuda_stream + runtime.cudaStream_t(raw_ptr).\n Skip cudaStreamDestroy for Paddle-managed streams in cleanup().\n- §54: torch.empty() in Paddle compat calls cudaMemAlloc, forbidden during\n CUDA stream capture (error 900 cudaErrorStreamCaptureUnsupported).\n Fix: pre-allocate quantized input buffers before capture via quantize_inputs();\n _run_moe_computation() reuses static buffers (no alloc in capture window);\n launch() re-quantizes outside graph and updates buffers via copy_().\n- Regression: paddle_all_test_cases.sh all PASS (0 failed, skips are hw limits).\n- New test added to paddle_all_test_cases.sh.\n\nRefs: MISMATCH_EXPERIMENT §53, §54
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adapt test_renormalize_routing[BF16_logits-Swiglu-Shuffled_MajorK-Renorm-NvFP4xNvFP4-384-1024-8-RandomHiddenStates] to pass under Paddle compat mode. Two compatibility issues fixed in CUDAGraphMoE:
§53 — torch.cuda.ExternalStream unavailable in Paddle compat
torch.cuda.ExternalStream is not implemented in PaddlePaddle compat. Fix: use torch.cuda.Stream() (Paddle-managed), extract raw CUDA pointer via .stream_base.cuda_stream, wrap with runtime.cudaStream_t(raw_ptr). Paddle-managed streams are not destroyed via cudaStreamDestroy in cleanup().
§54 — torch.empty() triggers cudaMemAlloc during CUDA stream capture (error 900)
In Paddle compat, torch.empty() calls cudaMemAlloc directly — forbidden during stream capture (cudaErrorStreamCaptureUnsupported). Fix: move all tensor allocations outside capture window:
Related Issues
Paddle compat adaptation series for PFCCLab/flashinfer.
Tests
Reviewer Notes
Changes confined to tests/moe/test_trtllm_gen_fused_moe.py (test layer only) and scripts/paddle_all_test_cases.sh. No core API or kernel code modified.
Generated with Claude Code