FlagGems
AGENTS.md1.2k starsChanged 4 months agoApache-2.0View on GitHub
FlagGems is a high-performance, generic Triton operator library that accelerates LLM training and inference across diverse AI hardware by registering into PyTorch's ATen backend.
Adopted by
Steady: 0 new projects took it in the last 4 weeks, none the 4 weeks before.thin data
Who's talking about flagos-ai/FlagGems
- linkedin/Liger-Kernel“[RFC] Code Organization for New Backend Support”GitHub · Dec 4, 2025 · 4 reactions
- gpu-mode/resource-stream“Docs: Can we add FlagGems under the session of "Triton Kernels / Examples"”GitHub · Dec 22, 2025 · 1 reactions
- flagos-ai/Torch-FL“[AI] MetaX SDPA cannot compile FlagGems 5.4.0 attention kernel”GitHub · Nov 10, 2026
- flagos-ai/Torch-FL“[Hygon] FP32 addmm: four CPU-reference discrepancies across DAS boxing and FlagGems”GitHub · Nov 10, 2026
- flagos-ai/Torch-FL“[AI][DCU] Track FlagGems public global aminmax empty-input error”GitHub · Nov 9, 2026
The biggest 5 of 46 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 46
Talked about on GitHub (46 times).
On GitHub · 46
- Dec 4, 2025[RFC] Code Organization for New Backend Support — linkedin/Liger-Kernel4 reactions · 3 comments
- Dec 22, 2025Docs: Can we add FlagGems under the session of "Triton Kernels / Examples" — gpu-mode/resource-stream1 reaction
- Nov 10, 2026[AI] MetaX SDPA cannot compile FlagGems 5.4.0 attention kernel — flagos-ai/Torch-FL0 reactions
- Nov 10, 2026[Hygon] FP32 addmm: four CPU-reference discrepancies across DAS boxing and FlagGems — flagos-ai/Torch-FL0 reactions
- Nov 9, 2026[AI][DCU] Track FlagGems public global aminmax empty-input error — flagos-ai/Torch-FL0 reactions
41 more on GitHub
- Nov 9, 2026[AI][DCU] Track FlagGems public global aminmax NaN propagation — flagos-ai/Torch-FL0 reactions
- Nov 9, 2026[AI][DCU] Track FlagGems _to_copy fractional-to-bool conversion — flagos-ai/Torch-FL0 reactions
- Nov 9, 2026[BUG][DCU] Advanced indexing rejects valid non-contiguous row and column index views — flagos-ai/Torch-FL0 reactions
- Nov 4, 2026Add linear-5379: reshape non-contiguous linear input instead of view — FLAG-OP/flag-fixes0 reactions · 4 comments
- Nov 2, 2026[KMCompiler] Rewrite the operator using loop vectorization — flagos-ai/FlagGems-vllm0 reactions
- Oct 29, 2026Collect original group_mm H800 records with native per-group CUDA composite — zhaojs12345/ops-baseline0 reactions
- Oct 27, 2026Add clean H800 baseline for mkldnn_rnn_layer — zhaojs12345/ops-baseline0 reactions
- Oct 27, 2026[QC][MThreads] Optimize W8A16 FP8 RMSNorm for real shapes — July-h5kf3/FlagGems0 reactions
- Oct 26, 2026[AI][BUG][DCU] Track FlagGems round rejecting strided tensors — flagos-ai/Torch-FL0 reactions
- Oct 26, 2026[AI][BUG][DCU] Track FlagGems remainder errors for infinite divisors — flagos-ai/Torch-FL0 reactions
- Oct 26, 2026[AI][BUG][DCU] Track FlagGems clamp/clamp_min losing NaN propagation — flagos-ai/Torch-FL0 reactions
- Oct 26, 2026[AI][BUG][DCU] Track FlagGems rand/rand_like returning 1.0 in BF16/FP16 — flagos-ai/Torch-FL0 reactions · 2 comments
- Oct 26, 2026[Bug Fix] Guard attn_res on TLE load capability — flagos-ai/FlagGems-vllm0 reactions
- Oct 22, 2026[NVIDIA] Add guarded MiniMax TP8 W8A8 MoE profiles and mixed-policy fusion — flagos-ai/FlagGems-vllm0 reactions
- Oct 20, 2026[KMCompiler][Ascend] perf-opt for fused_experts_impl — flagos-ai/FlagGems-vllm0 reactions
- Oct 20, 2026Collect and replay explicit native CPU and host baselines — zhaojs12345/ops-baseline0 reactions
- Oct 19, 2026[AI][DCU] Track native_layer_norm CPU-parity regression and boxing control for FlagGems #7247 — flagos-ai/Torch-FL0 reactions
- Oct 18, 2026[AI][Performance][DCU] R5 same-device DAS/FlagOS/boxing survey: 29 cases and classified follow-ups — flagos-ai/Torch-FL0 reactions
- Oct 18, 2026[AI][Performance][DCU] Track FlagGems repeat_interleave output_size readback and R5 integration — flagos-ai/Torch-FL0 reactions
- Oct 18, 2026[AI][Performance][DCU] Track FlagGems Hygon int64 sort multistage latency on R5 — flagos-ai/Torch-FL0 reactions
- Oct 15, 2026Explicit complex dtype becomes float32 in zeros on the default DCU backend — flagos-ai/Torch-FL0 reactions · 1 comment
- Oct 14, 2026Route Ascend GDN decode through the FlagGems operator — iteratorlee/sglang-plugin-FL0 reactions
- Oct 12, 2026docs(wheel-info): give each package a source-tarball download URL — flagos-ai/build-infra0 reactions
- Oct 10, 2026[AI][DCU] Track batched cdist failure in the FlagGems _euclidean_dist route — flagos-ai/Torch-FL0 reactions
- Oct 10, 2026[AI][DCU] Track FlagGems exp float64 precision loss on the default route — flagos-ai/Torch-FL0 reactions
- Oct 10, 2026[AI][DCU] Track FlagGems amin dtype rejection on the default route — flagos-ai/Torch-FL0 reactions
- Sep 27, 2026[OP] Route Hygon FP32 scaled_dot_product_attention to a supported fused backend — flagos-ai/Torch-FL0 reactions · 1 comment
- Sep 27, 2026[MThreads][TLE] Add persistent GEMM pipeline and SPMC synchronization support — flagos-ai/FlagTree0 reactions · 10 comments
- Sep 24, 2026Fix FlagOS attention layouts and packed sequence boundaries — flagos-ai/TransformerEngine-FL0 reactions
- Sep 21, 2026[KMCompiler][Ascend][test] perf-opt for pack_seq_triton/unpack_seq_triton on ascend — flagos-ai/FlagGems-vllm0 reactions
- Sep 18, 2026Fix amin_ accuracy test to exercise the inplace Gems operator — flagos-ai/FlagGems-Experimental0 reactions
- Sep 18, 2026Fix add_relu benchmark to measure the fused Gems operator — flagos-ai/FlagGems-Experimentalsays it tested it0 reactions
- Sep 16, 2026fix(benchmark): sync backend functional batch norm target from FlagGems #6352 — flagos-ai/FlagGems-Experimentalsays it tested it0 reactions · 2 comments
- Sep 16, 2026fix(benchmark): sync explicit batch norm targets from FlagGems #6338 — flagos-ai/FlagGems-Experimentalsays it tested it0 reactions
- Sep 2, 2026Arm: integrate Qwen packed W4A8 and GDN on CPU — flagos-ai/vllm-plugin-FL0 reactions · 3 comments
- Aug 26, 2026[XPU] tl.store 在向量计算之后写入标量时,实际写入的是过期的寄存器值 — flagos-ai/FlagTree0 reactions
- Aug 18, 2026[Ascend] flagos 融合算子精度污染: prefer=flagos 输出乱码(prefer=vendor 正常) — flagos-ai/sglang-plugin-FL0 reactions
- Aug 7, 2026[KMCompiler] perf-opt grouped_topk for DeepSeek-v3.2 — flagos-ai/FlagGems-vllm0 reactions · 1 comment
- Jul 7, 2026fix: add in-place input comparison in test_unsqueeze_ — XDYuanzhuLee/FlagGems0 reactions
- Jun 24, 2026This project is not maintained anymore 😢 — github/command0 reactions · 1 comment
- Mar 10, 2026算子开发流程 — siliconflow/FlagGems0 reactions
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 31,542 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repositoryOne other file it gives its agents.
- CLAUDE.mdCLAUDE.md
The file
We split this AGENTS.md into the rules it gives an agent
5 rules. About 0 are common, 2 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 10
Dual Validation: Every operator change requires numerical accuracy verification (vs.
- Very specific: line 24
Place in src/flag_gems/{ops,fused,experimental_ops}/<op_name>.py (snake_case, lowercase, no leading _ or .).
- Very specific: line 25
Generic Baseline ("公版算子"): Must run on the official upstream Triton compiler on NVIDIA Ampere (e.g., A100).
- Very specific: line 43
Run: pytest tests/test_<op_id>.py (add --ref cpu for CPU baseline, --quick for smoke tests).
- Distinctive: line 63
Device Isolation: Always isolate devices on shared nodes before testing:
≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Project: FlagGems
FlagGems is a high-performance, generic Triton operator library that accelerates LLM training and inference across diverse AI hardware by registering into PyTorch's ATen backend.
1. Core Principles
- Triton-First & Multi-Backend: Implement core kernels in Triton for portability across NVIDIA, Ascend, Hygon, Moore Threads, MetaX, Iluvatar, Kunlunxin, Cambricon, etc.
- Seamless Integration: Register operators into PyTorch's ATen dispatcher for zero-code-change acceleration.
- Host Function Isolation: Host functions MUST NOT invoke PyTorch compute ops (only allocation/init like
empty_like,zeros,randn, or other FlagGems ops are allowed) and must launch device kernels. - Dual Validation: Every operator change requires numerical accuracy verification (vs. CPU/native ATen) and performance benchmarking.
2. Directory Structure
src/flag_gems/: Main package —ops/(standard kernels),fused/(fused kernels),experimental_ops/(incubating ops),modules/(nn.Moduleblocks like RMSNorm/RoPE),runtime/(multi-backend dispatchers &backend/_<vendor>/),utils/(@pointwise_dynamic,LibTuner, caching),testing/(test helpers).cpp/: C++ extensions (include/,lib/forLibTritonJIT,ctest/).conf/:operators.yaml(operator metadata source of truth),backends.yaml(toolchains),ci_test_aliases.yaml(test markers).tests/&benchmark/: Pytest accuracy suite andtriton.testing.do_benchperformance suite.examples/&tools/ci_checks/: Model examples, pre-tuning scripts, and CI/pre-commit rule checks.setup.sh&pyproject.toml: Per-backend environment setup and build config.
3. Operator Development Checklist
- Implement Kernel:
- Place in
src/flag_gems/{ops,fused,experimental_ops}/<op_name>.py(snake_case, lowercase, no leading_or.). - Generic Baseline ("公版算子"): Must run on the official upstream Triton compiler on NVIDIA Ampere (e.g., A100). Place vendor-specific customizations under
src/flag_gems/runtime/backend/_<vendor>/. - vLLM Notice: vLLM-specific fused operators have migrated to FlagGems-vllm; submit vLLM kernels there instead of
src/flag_gems/fused/.
- Place in
- Register & Export:
- Export in
src/flag_gems/__init__.py(orfused/__init__.py) and map ATen ops in_FULL_CONFIG. - Sort
__all__alphabetically viapython tools/ci_checks/sort_exports.py.
- Export in
- Register Metadata (
conf/operators.yaml):- id: <op_id> # Matches function name description: <Description> for: [<aten_op_name>] # e.g., aten::add.Tensor labels: [aten] # e.g., aten, Reduction, pointwise kind: [Math] # e.g., Math, NeuralNetwork, LinearAlg stages: [{beta: '5.4'}] # alpha, beta, or stable with version name: [<abstract_op_name>] # OpInfo style name source: [aten] - Accuracy Tests (
tests/test_<op_id>.py):- Decorate tests with
@pytest.mark.<op_id>. - Run:
pytest tests/test_<op_id>.py(add--ref cpufor CPU baseline,--quickfor smoke tests).
- Decorate tests with
- Benchmarks (
benchmark/test_<op_id>_perf.py):- Implement using
Benchmarkand run:pytest benchmark/test_<op_id>_perf.py -s.
- Implement using
- Validate Static CI Checks:
python tools/ci_checks/check_operators_yaml.py --operators '["<op_id>"]' python tools/ci_checks/check_init_exports.py python tools/ci_checks/check_operator_markers.py --operators '["<op_id>"]' python tools/ci_checks/check_aten_operators.py --operators '["<op_id>"]'
4. Coding Standards & Environment
- Formatting & Linting: Python uses
black,isort(blackprofile), andflake8(max line length 120); C++ usesclang-format. Always runpre-commit run --all-files. - Environment & Build:
# Install backend deps (e.g., nvidia-cuda128, ascend-cann900, metax-maca3810) [COMPILER=flagtree|triton] [ENABLE_CPP=1] ./setup.sh <backend> export USE_C_EXTENSION=1 # Enable C++ runtime dispatcher if built with ENABLE_CPP=1 - Device Isolation: Always isolate devices on shared nodes before testing:
- NVIDIA:
CUDA_VISIBLE_DEVICES=<id> - Ascend:
ASCEND_RT_VISIBLE_DEVICES=<id> - Enflame:
TOPS_VISIBLE_DEVICES=<id>
- NVIDIA:
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

