feat(txda): support cudagraph capture and replay (#649)
PR Category
Vendor
PR Type
New Features
Description
Enable cudagraph (FULL_DECODE_ONLY mode) capture and replay on TXDA (tsingmicro) devices. Previously the tsingmicro triton launcher rejected kernel launches inside the capture scope (txLaunchKernel err=0x47000003) and the device-guard stream diversion corrupted captures, so graph mode was effectively unusable on TXDA.
Related Issues
(none)
Changes
vllm_fl/compilation/graph.py: use TXDAGraph on txda; txda-only warmup before capture; applycapture_guard_context()andcapture_error_mode="relaxed"at the capture point (non-txda paths byte-identical to upstream)
vllm_fl/dispatch/backends/vendor/txda/patch.py(new): stream/current_stream patches, device-guard neutralization, publiccapture_guard_context()
vllm_fl/dispatch/backends/vendor/txda/impl/fused_moe.py,impl/normalization.py(new),register_ops.py,__init__.py
vllm_fl/platform.py: enable static graph mode for tsingmicrovllm_fl/worker/worker.py: register graph-capture hook for txdaTesting
e2e verified on TXDA (tsingmicro): MiniCPM5-1B, TP=1,
--compilation-config '{"cudagraph_mode": "FULL_DECODE_ONLY"}', TORCH_COMPILE_DISABLE=1cudagraph capture 1/1 succeeds (
Capturing CUDA graphs (decode, FULL): 100%)graph replay output is byte-identical to enforce-eager baseline (same request, temperature=0)
runs verified 3/3 in a clean container; non-txda platforms unaffected (nullcontext + empty kwargs path unchanged)
Checklist
- I have run the existing tests and they pass
- I have added tests for my changes (if applicable)
- I have updated the documentation (if applicable)
A vLLM plugin built on the FlagOS unified multi-chip backend.
版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9
京公网安备 11010802047560号
vllm-plugin-FL
vllm-plugin-FL is a plugin for the vLLM inference/serving framework, built on FlagOS’s unified multi-chip backend — including the unified operator library FlagGems and the unified communication library FlagCX. It extends vLLM’s capabilities and performance across diverse hardware environments. Without changing vLLM’s original interfaces or usage patterns, the same command can run model inference/serving on different chips.
Adaptation Gate
The adaptation gate validates text, image, and mixed text-image requests across the required models in both eager and graph modes. See the adaptation gate cases for the test matrix, scenarios, and usage.
Version Compatibility
release/0.2mainSupported Models and Chips
In theory, vllm-plugin-FL can support all models available in vLLM, as long as no unsupported operators are involved. The tables below summarize the current support status of end-to-end verified models and chips, including both fully supported and in-progress (“Merging”) entries.
Supported Models
Supported Chips
Quick Start
Setup
Install vLLM
For NVIDIA GPUs, install vLLM from the official v0.24.0 release (optional if the correct version is already installed):
For non-NVIDIA chips, install vLLM from source with the
emptydevice target:Install vllm-plugin-FL
2.1 Clone the repository:
2.2 Install
For CUDA-like devices, including CUDA and HIP/ROCm environments that use PyTorch’s CUDA dispatch key, build the plugin native extension by setting
VLLM_VENDOR=cudaduring installation:This builds and installs
vllm_fl._C, which provides native C++ support required by some graph/custom-op paths, especially when vLLM is installed withVLLM_TARGET_DEVICE=empty.If
VLLM_VENDORis not set, vllm-plugin-FL is installed as a Python-only plugin and the native extension is skipped.Install FlagGems
3.1 Install Build Dependencies
3.2 Install FlagGems
Runtime compatibility hooks
The plugin installs runtime compatibility hooks through vLLM’s plugin entry points without modifying the installed vLLM package. Model-specific config and model registrations are loaded only for their corresponding architectures.
Operator adapters use the plugin dispatch manager, so backend selection, fallback, per-op policy, operator-list recording, and I/O diagnostics continue to follow the common FlagOS controls.
On Iluvatar with vLLM 0.24, the FlagOS GPU runner binds all attention caches within each decoder layer, including separate main and index caches. Binding preserves layer order, cache order within a layer, tensor identity and shared aliases. This cache initialization fix does not enable graph capture or establish model or operator support; validate those separately in the target environment.
Operator profiling
See the operator profiling tools for a reproducible native-vLLM and plugin comparison workflow.
(Optional) Install FlagCX
4.1 Clone the repository:
4.2 Build the library with different flags targeting to different platforms:
4.3 Set environment
4.4 Installation FlagCX
Note: [xxx] should be selected according to the current platform, e.g., nvidia, ascend, etc.
If there are multiple plugins in the current environment, you can specify use vllm-plugin-fl via VLLM_PLUGINS=’fl’.
Additional Steps for Ascend
Install FlagTree
For other chips, please refer to FlagTree for the corresponding version (e.g.,
flagtree==0.6.1+iluvatar3.6,flagtree==0.6.1+metax3.6, etc.).Set required environment variable
Select eager or full-decode graph execution
For eager execution, add
enforce_eager=Trueto theLLMconstructor or pass--enforce-eageron the command line. ForFULL_DECODE_ONLY, use:This path uses the eager FX backend with NPU graph capture/replay. The standard Python-only FL installation above is sufficient. Use a compatible FlagGems/FlagTree installation when setting
USE_FLAGGEMS=1.HY4 on NVIDIA
HY4 is paired with this branch’s vLLM 0.24.0 environment and the shared FlagGems-vllm integration. Its MLA query concatenation and graph-safe paged MQA logits APIs are now merged into upstream FlagGems-vllm. The shared CI dependency now includes both APIs. Install the same pinned upstream source using the integration instructions above; no separate HY4 upgrade is needed.
HY4 uses the public
flaggems_vllmsparse indexer, cache and attention APIs; query quantization uses general FlagGems. No model-specific dependency extra or fork revision is required. The shared fused-operator rollout switch and its default behavior are described in the integration documentation. Runtime selection checks callable APIs, device kernels and the shared dispatch policy before allocating model weights. A selected operator’s execution error propagates without retrying another implementation.Use
hy4_safetensorsto load the preview checkpoint with expert slicing. The portable path requires BF16 KV (autowith a BF16 model, orbfloat16); FP8 KV requires the complete native sparse/cache/prefill path. Shared indexers require pipeline parallel size 1. The manual checkpoint smoke configuration requires 16 NVIDIA GPUs; the single-GPU dummy smoke checks model integration. HY4-Preview currently targets NVIDIA H100, vLLM 0.24.0, the MXFP8 preview checkpoint, BF16 activations and BF16 portable KV. Other chips, multimodal serving and portable FP8 KV are not validated. Sparse indexer providers use explicit entry points while preserving the real CUDA platform identity. The portable sparse indexer checks the selected paged MQA logits provider’s graph capability before loading weights. Upstream FlagGems-vllm exposesfp8_fp4_paged_mqa_logits_graphfor static-grid CUDA Graph capture, reading lengths and page mappings on the GPU on every replay. The shared dispatch selects that public entry point when available; older operator builds without the capability require--enforce-eager.With the graph-safe operator build, use
FULL_DECODE_ONLYwith compilation modeNONE, for example:The shared CachedOp prewarming from vllm-plugin-FL #552 is used after model loading. Whole-model Dynamo compilation remains limited by the current FlagGems
libentryimplementation; CUDA Graph modeNONEand eager execution remain available.Run a Task
Offline Batched Inference
With vLLM and vLLM-fl installed, you can start generating texts for list of input prompts (i.e. offline batch inferencing). See the example script: offline_inference. Or use blow python script directly.
Advanced use
For dispatch environment variable usage, see environment variables usage.
Using Cuda Communication library
If you want to use the original Cuda Communication, you can unset the following environment variables.
Using native CUDA operators
If you want to use the original CUDA operators, you can set the following environment variables.