How flagos-ai/flagtree works
FlagTree is a unified Triton-based compiler for AI accelerators, with language extensions and backend-specific support. The primary workflow is kernel authoring, compilation through Triton and GPU-oriented IR, hardware-specific lowering, then backend execution. Its internal compiler layers include layout analysis and loop pipelining; TLE adds portable-to-hardware-specific programming layers. The README documents multi-backend support and TLE capabilities, while sampled sources focus on compiler IR and pipelining, so several workflow links are shown as unverified rather than inferred as certain.
Main entry points: Ops.cpp TritonGPU IR · SoftwarePipeliner.cpp Software pipeliner · core.py Triton language · compiler.py Compiler API
Components 18
Kernel authoring
- Triton language
python/triton/language/core.py - Gluon language
python/triton/experimental/gluon/language/_core.py
Triton compiler
- Compiler API
python/triton/compiler/compiler.py - Triton IR
lib/Dialect/Triton/IR/Ops.cpp
GPU optimization
- TritonGPU IR
lib/Dialect/TritonGPU/IR/Ops.cpp - Layout analysis
lib/Analysis/Utility.cpp - Linear layouts
lib/Tools/LinearLayout.cpp - GPU transforms
lib/Dialect/TritonGPU/Transforms/Utility.cpp - Software pipeliner
lib/Dialect/TritonGPU/Transforms/Pipeliner/SoftwarePipeliner.cpp - Pipeline expander
lib/Dialect/TritonGPU/Transforms/Pipeliner/PipelineExpander.cpp
Backend integration
- NVIDIA GPU IR
lib/Dialect/TritonNvidiaGPU/IR/Ops.cpp - NVIDIA transforms
lib/Dialect/TritonNvidiaGPU/Transforms/MMALowering.cpp - LLVM lowering
lib/Conversion/TritonGPUToLLVM/Utility.cpp - Backend runtime
python/triton/backends/driver.py
TLE extensions
- TLE Lite / Struct
python/triton/experimental/tle/language/core.py - TLE Raw
python/triton/experimental/tle/raw/typing.py
Other components
- Kernel developer
- AI accelerator
Connections 20
- Kernel developer → Triton language: writes kernels
- Kernel developer → Gluon language: writes kernels
- Triton language → Compiler API: compiles through
- Gluon language → Compiler API: compiles through
- Compiler API → Triton IR: produces IR
- Triton IR → TritonGPU IR: converts to
- TritonGPU IR → Layout analysis: analyzes layouts
- Layout analysis → Linear layouts: uses layouts
lib/Analysis/Utility.cpp - TritonGPU IR → GPU transforms: transforms
- GPU transforms → Software pipeliner: includes pipelining
- Software pipeliner → Pipeline expander: expands schedule
lib/Dialect/TritonGPU/Transforms/Pipeliner/SoftwarePipeliner.cpp - Software pipeliner → NVIDIA GPU IR: handles MMA
lib/Dialect/TritonGPU/Transforms/Pipeliner/SoftwarePipeliner.cpp - TritonGPU IR → NVIDIA GPU IR: specializes for NVIDIA
- NVIDIA GPU IR → NVIDIA transforms: lowers operations
- TritonGPU IR → LLVM lowering: lowers to LLVM
- LLVM lowering → Backend runtime: emits code for
- Backend runtime → AI accelerator: launches kernels
- Kernel developer → TLE Lite / Struct: uses extensions
- TLE Lite / Struct → TLE Raw: can use lower-level
- TLE Raw → Triton language: extends Triton