Repository navigation
[WIP] SP+AsyncTP piecewise compilation fix + per-matmul heuristic gating - #37489
tianrengao wants to merge 1 commit into
Conversation
Summary of changes: 1. Fix SP+piecewise compilation crash: _remove_mismatched_epilogue_copies() and _fix_cross_submod_outputs() handle shape mismatches at submod boundaries when SP transforms AllReduce->RMSNorm into ReduceScatter->RMSNorm->AllGather. 2. Per-matmul async TP heuristic: Decision tree from AutoHeuristic (D176943) gates fusion via extra_check in collective_fusion.py. Prevents Inductor always-fuse rule from causing 2-3x decode regression at small batch sizes (M<=256). 3. Config: async_tp_min_tokens threshold (default=128) for coarse-grained batch-size gating. enable_sp_and_async_tp() runtime check. Note: SP is currently disabled in upstream vLLM (IS_DENSE=False, see issue vllm-project#25689). These changes are preserved as a draft for future work. Benchmark results (no meaningful serving benefit on NVLink): - Llama-2-7b TP=2: 1.01-1.02x (noise) - Meta-Llama-3-70B TP=8: 0.98x (slight regression) See benchmarks/SP_ASYNCTP_BENCHMARK_REPORT.md for details.
There was a problem hiding this comment.
Code Review
This pull request introduces a fix for a crash when using Sequence Parallelism (SP) with Asynchronous Tensor Parallelism (AsyncTP) in piecewise compilation mode. It also adds a per-matmul heuristic to gate fusions, preventing performance regressions at small batch sizes. The changes include new logic to handle tensor shape modifications at submodule boundaries, a new configuration option async_tp_min_tokens for coarse-grained gating, and new benchmark scripts and tests. My review found one high-severity issue related to error handling in the new heuristic check. Otherwise, the changes appear well-structured and address the described problems effectively.
| except Exception: | ||
| return True |
There was a problem hiding this comment.
The use of a broad except Exception: is risky as it can hide various errors during shape extraction for the heuristic check (e.g., KeyError, AttributeError, IndexError). If an unexpected error occurs, it will be silently caught, and the function will default to returning True, causing the fusion to be applied. This could lead to incorrect behavior or mask underlying bugs in the pattern matching. It would be safer to catch more specific exceptions and log a warning to facilitate debugging.
| except Exception: | |
| return True | |
| except (KeyError, IndexError, AttributeError) as e: | |
| logger.warning( | |
| "Failed to extract matmul shapes for async TP heuristic check: %s. " | |
| "Defaulting to allowing fusion.", | |
| e, | |
| exc_info=True, | |
| ) | |
| return True |
|
This pull request has merge conflicts that must be resolved before it can be |
|
This pull request has merge conflicts that must be resolved before it can be |
|
Closing as superseded by #60517, which removed the torch.compile-based sequence parallelism pass and AsyncTP (along with |
Summary
Fix SP+AsyncTP crash with piecewise compilation and add per-matmul heuristic gating.
Changes
_remove_mismatched_epilogue_copies()+_fix_cross_submod_outputs()— SP changes tensor shapes at submod boundaries, causingassert_size_stridefailuresextra_check, preventing 2-3x decode regression at small batch sizesasync_tp_min_tokensthreshold +enable_sp_and_async_tp()runtime checkStatus
IS_DENSE=False, #25689). These changes are preserved for future work.Benchmark results show no meaningful serving benefit on single-node NVLink:
See
benchmarks/SP_ASYNCTP_BENCHMARK_REPORT.mdfor details.