[English|中文版]
FlagGems-vllm is part of FlagOS. It is a high-performance operator library implemented using the Triton programming language launched by OpenAI, designed for multiple hardware backends. It provides optimized implementations of common vLLM operators and supports high-performance inference and deployment for a variety of widely used models.
- Operators have undergone deep performance tuning
- Triton kernel call optimization
- Flexible multi-backend support mechanism
- Support for common vLLM operators (
moe_align_block_size,grouped_topk, etc.)
The three repositories work together in the FlagOS ecosystem but have different responsibilities:
- FlagGems: The general-purpose FlagGems operator library. It provides common PyTorch/Triton operator replacements and exposes
flag_gems.enable()/flag_gems.use_gems()to register operators into PyTorch dispatch. FlagGems-vllm depends on FlagGems, and currently some FlagGems-vllm operators invoke operators from FlagGems internally. - FlagGems-vllm: This repository. It contains vLLM-scenario operator implementations and tests/benchmarks that are aligned with the corresponding FlagGems implementations where the same operator exists. It exposes operators through the
flaggems_vllmPython package, for exampleflaggems_vllm.grouped_topk,flaggems_vllm.fused_experts_impl, andflaggems_vllm.moe_align_block_size. - vllm-plugin-fl: The vLLM plugin layer. It uses FlagGems as the global operator backend by importing FlagGems and calling
flag_gems.enable(). For vLLM-specific fused kernels that are not enabled through PyTorch dispatch, it explicitly imports and calls operators from FlagGems-vllm.
In a typical vLLM plugin environment, the call flow is:
vLLM
-> vllm-plugin-fl
-> flag_gems.enable() for general FlagGems operator registration
-> flaggems_vllm.<operator>() for vLLM-specific fused operators (some calling flag_gems operators internally)
This means FlagGems-vllm builds on top of FlagGems: FlagGems provides the common operator foundation and internal utility operators, while FlagGems-vllm provides vLLM-oriented kernels and compatibility tests/benchmarks used by vllm-plugin-fl.
python -m pip install -U "setuptools>=64,<82" wheel packaging
python -m pip install --no-deps "flag-gems==5.4.0" \
--extra-index-url https://resource.flagos.net/repository/flagos-pypi-daily/simple/
python -m pip install --no-build-isolation -e .tools/setup.sh reads the backend registry in
src/flaggems_vllm/backends.yaml, creates a uv virtual environment and
installs the matching torch/vLLM/compiler stack:
bash tools/setup.sh --list # show profiles and aliases
bash tools/setup.sh nvidia # or ascend, metax, hygon, ...
source tools/setup.sh nvidia # create and activate in one stepInside a vendor image that already provides torch/triton/vLLM, use
bash tools/setup.sh --no-venv <backend> to add only this repository and its
test dependencies.
For complete installation steps (including manual installation without a virtual environment, test dependencies, and multi-repository setup with FlagGems and vllm-plugin-fl), please refer to the Installation Guide.
Since FlagGems-vllm depends on FlagGems, remember to enable FlagGems before using FlagGems-vllm operators:
import torch
import flag_gems
import flaggems_vllm
# Enable FlagGems general operators
flag_gems.enable()
# Call FlagGems-vllm fused operators
scores = torch.randn((8, 16), device="cuda", dtype=torch.float32)
bias = torch.randn((16,), device="cuda", dtype=torch.float32)
topk_weights, topk_ids = flaggems_vllm.grouped_topk(
scores,
n_group=4,
topk_group=2,
topk=2,
renormalize=True,
routed_scaling_factor=1.0,
bias=bias,
scoring_func=0,
)
print(topk_weights.shape, topk_ids.shape)For more examples (such as moe_align_block_size, flash_attention_forward, and fused_add_rms_norm), see the Basic Usage Guide.
Comprehensive documentation is available in the docs directory:
- 📖 Getting Started: Installation Guide
- 🚀 Usage: Basic Usage | vLLM Plugin Integration
- 🔧 Hardware Backends: Non-NVIDIA Hardware Support
- 🧪 Testing: Unit Testing Guide | Coverage
- ⚡ Benchmarking: Running Benchmarks | Performance Results
- 📋 References: Supported Operators | MiniMax M3 Support
- 🤝 Contributing: Contribution Overview | Development Workflow | Project Structure
This project is licensed under the Apache (version 2.0) License.