# FlagTree
**Repository Path**: zt7398/FlagTree
## Basic Information
- **Project Name**: FlagTree
- **Description**: No description available
- **Primary Language**: Unknown
- **License**: MIT
- **Default Branch**: main
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2026-08-12
- **Last Updated**: 2026-08-12
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
[
](https://flagos.io/)
[中文版|[English](./README.md)]
FlagTree 是 [FlagOS](https://flagos.io/) 的一部分。
FlagOS 是一个面向多元AI芯片的开源、统一系统软件栈,旨在打通模型、系统与芯片层,培育开放协作的生态系统。
它支持 “一次开发,多芯运行” 的工作流,兼容多样化的 AI 加速芯片。
它释放硬件性能潜力,消除各类 AI 芯片专用软件栈之间的碎片化问题,并大幅降低大模型在多种 AI 硬件移植与维护的成本。
FlagTree 是面向多种 AI 芯片的开源、统一编译器。
FlagTree 致力于打造多元 AI 芯片编译器及相关工具平台,发展和壮大 Triton 上下游生态。
项目当前处于初期,目标是兼容现有适配方案,统一代码仓库,快速实现单仓库多后端支持。
对于上游模型用户,提供多后端的统一编译能力;
对于下游芯片厂商,提供 Triton 生态接入范例。
## 多后端支持
各后端基于不同版本的 Triton 适配,因此位于不同的主干分支。
各主干分支均为保护分支且地位相等,表格中所有后端均搭建了 CI/CD Runner。
有些后端适配了多个 Triton 版本,表格中仅展示最新版本。
|主干分支|厂商 |后端 |Triton 版本 |安装 |
|:-------|:-----|:------|:----------------|:-----------|
|[main](https://github.com/flagos-ai/flagtree/tree/main)|NVIDIA
TLE 的主要优势包括:
* 从可移植到硬件导向调优的渐进式抽象(`Lite` / `Struct` / `Raw`)。
* 更好覆盖多设备、架构特化与后端 lowering 场景。
* 在保留优化空间的同时,降低现有 Triton kernel 的迁移改造成本。
详细设计、API 与示例请参考 [TLE Wiki](https://github.com/flagos-ai/FlagTree/wiki/TLE) 和 [TLE-Raw Wiki](https://github.com/flagos-ai/FlagTree/wiki/TLE-Raw)。
## 性能改进
无需修改任何 Triton 算子代码,FlagTree 可在实际模型中的某些形状上获得性能增益。
下面以 Qwen 模型中调用的一些形状下的 mm 算子为例,展示 FlagTree 在不同芯片上的性能增益。
## 新特性
* 2026/08/04 新增接入 [ppu](/third_party/ppu/) 后端(对应 Triton 3.6),加入 CI/CD。
* 2026/07/07 新增接入 NVIDIA [tileir](/third_party/tileir/) 后端(对应 Triton 3.6),加入 CI/CD。
* 2026/07/03 [iluvatar](/third_party/iluvatar/) 后端升级到 Triton 3.6,加入 CI/CD。
* 2026/07/02 [xpu](/third_party/xpu/) 后端升级到 Triton 3.6,加入 CI/CD。
* 2026/06/30 [sunrise](/third_party/sunrise/) 后端升级到 Triton 3.6,加入 CI/CD。
* 2026/06/26 [metax](/third_party/metax/) 后端升级到 Triton 3.6,加入 CI/CD。
* 2026/06/10 新增接入 [rpu](/third_party/rpu/) 后端(对应 Triton 3.6),加入 CI/CD。
* 2026/06/08 [ascend](https://github.com/flagos-ai/FlagTree/tree/triton_v3.5.x/third_party/ascend/) 后端升级到 Triton 3.5,加入 CI/CD。
* 2026/06/03 新增接入 ARM64 [cpu](https://github.com/flagos-ai/FlagTree/tree/triton_v3.3.x/third_party/cpu/) 后端(对应 Triton 3.3)。
* 2026/06/01 新增接入 [damoacademy](/third_party/thrive/) 后端(对应 Triton 3.6),加入 CI/CD。
* 2026/05/12 [mthreads](/third_party/mthreads/) 后端升级到 Triton 3.6,加入 CI/CD。
* 2026/05/07 [hcu](/third_party/hcu/) 后端升级到 Triton 3.6,加入 CI/CD。
* 2026/04/24 [mthreads](https://github.com/flagos-ai/FlagTree/tree/triton_v3.2.x/third_party/mthreads/) 后端升级到 Triton 3.2,加入 CI/CD。
* 2026/04/17 [enflame](/third_party/enflame/) 后端升级到 Triton 3.6,加入 CI/CD。
* 2026/03/13 [enflame](https://github.com/flagos-ai/FlagTree/tree/triton_v3.5.x/third_party/enflame/) 后端升级到 Triton 3.5,加入 CI/CD。
* 2026/01/23 新增接入 [sunrise](https://github.com/flagos-ai/FlagTree/tree/triton_v3.4.x/third_party/sunrise/) 后端(对应 Triton 3.4),加入 CI/CD。
* 2026/01/08 添加 [HINTS](https://github.com/flagos-ai/FlagTree/wiki/HINTS)、[TLE](https://github.com/flagos-ai/FlagTree/wiki/TLE)、[TLE-Raw](https://github.com/flagos-ai/FlagTree/wiki/TLE-Raw) 等新功能 WIKI。
* 2025/12/08 新增接入 [enflame](https://github.com/flagos-ai/FlagTree/tree/triton_v3.3.x/third_party/enflame/) 后端(对应 Triton 3.3),加入 CI/CD。
* 2025/11/26 添加 FlagTree 后端特化统一设计文档 [FlagTree-Backend-Specialization](https://github.com/flagos-ai/FlagTree/wiki/FlagTree-Backend-Specialization)。
* 2025/10/28 提供离线构建支持(预下载依赖包),改善网络环境受限时的构建体验,使用方法见后文。
* 2025/09/30 在 GPGPU 上支持编译指导 shared memory。
* 2025/09/29 SDK 存储迁移至金山云,大幅提升下载稳定性。
* 2025/09/25 支持编译指导 ascend 的后端编译能力。
* 2025/09/16 新增接入 [hcu](https://github.com/flagos-ai/flagtree/tree/triton_v3.1.x/third_party/hcu/) 后端(对应 Triton 3.0),加入 CI/CD。
* 2025/09/09 Fork 并修改 [llvm-project](https://github.com/FlagTree/llvm-project),承接 [FLIR](https://github.com/flagos-ai/flir) 的功能。
* 2025/09/01 新增适配 Paddle 框架,加入 CI/CD。
* 2025/08/16 新增适配北京超级云计算中心 AI 智算云。
* 2025/08/04 新增接入 T*** 后端(对应 Triton 3.1)。
* 2025/08/01 [FLIR](https://github.com/flagos-ai/flir) 支持编译指导 shared memory loading。
* 2025/07/30 更新 [cambricon](https://github.com/flagos-ai/FlagTree/tree/triton_v3.2.x/third_party/cambricon/) 后端(对应 Triton 3.2)。
* 2025/07/25 浪潮团队新增适配 OpenAnolis 龙蜥操作系统。
* 2025/07/09 [FLIR](https://github.com/flagos-ai/flir) 支持编译指导 Async DMA。
* 2025/07/08 新增多后端编译统一管理模块。
* 2025/07/02 新增接入 S*** 后端(对应 Triton 3.3)。
* 2025/06/20 [FLIR](https://github.com/flagos-ai/flir) 开始承接 MLIR 扩展功能。
* 2025/06/06 新增接入 [tsingmicro](https://github.com/flagos-ai/FlagTree/tree/triton_v3.3.x/third_party/tsingmicro/) 后端(对应 Triton 3.3),加入 CI/CD。
* 2025/06/04 新增接入 [ascend](https://github.com/flagos-ai/FlagTree/blob/triton_v3.2.x/third_party/ascend) 后端(对应 Triton 3.2),加入 CI/CD。
* 2025/06/03 新增接入 [metax](https://github.com/flagos-ai/flagtree/tree/triton_v3.1.x/third_party/metax/) 后端(对应 Triton 3.1),加入 CI/CD。
* 2025/05/21 [FLIR](https://github.com/flagos-ai/flir) 开始承接到中间层的转换功能。
* 2025/04/09 新增接入 [aipu](https://github.com/flagos-ai/FlagTree/tree/triton_v3.3.x/third_party/aipu/) 后端(对应 Triton 3.3),提供 torch 标准扩展[范例](https://github.com/flagos-ai/flagtree/blob/triton_v3.3.x/third_party/aipu/backend/aipu_torch_dev.cpp),加入 CI/CD。
* 2025/03/26 接入安全合规扫描。
* 2025/03/19 新增接入 [xpu](https://github.com/flagos-ai/flagtree/tree/triton_v3.1.x/third_party/xpu/) 后端(对应 Triton 3.0),加入 CI/CD。
* 2025/03/19 新增接入 [mthreads](https://github.com/flagos-ai/flagtree/tree/triton_v3.1.x/third_party/mthreads/) 后端(对应 Triton 3.1),加入 CI/CD。
* 2025/03/12 新增接入 [iluvatar](https://github.com/flagos-ai/flagtree/tree/triton_v3.1.x/third_party/iluvatar/) 后端(对应 Triton 3.1),加入 CI/CD。
## 环境准备
避免环境匹配问题的最佳实践是使用 [用户手册](https://github.com/flagos-ai/FlagTree/wiki/User-Manual) 中推荐的镜像。
## 从源码安装
安装依赖(注意使用正确的 python3.x 执行):
```shell
apt update; apt install zlib1g zlib1g-dev libxml2 libxml2-dev nlohmann-json3-dev
python3 -m pip install -r python/requirements.txt
```
通用的构建安装方式(网络畅通环境下推荐使用):
```shell
# Set FLAGTREE_BACKEND using the backend name from the table above
export FLAGTREE_BACKEND=${backend_name} # Do not set it on nvidia/amd/triton-shared
# For Triton 3.1/3.2/3.3 (branch: triton_v3.1.x, triton_v3.2.x, triton_v3.3.x)
cd python; python3 -m pip install . --no-build-isolation -v # Install flagtree and uninstall triton
# For Triton 3.4/3.5/3.6 (branch: triton_v3.4.x, triton_v3.5.x, main)
python3 -m pip install . --no-build-isolation -v # Install flagtree and uninstall triton
```
安装 `flagtree` 后,可通过下列命令查看:
```shell
python3 -m pip show flagtree
cd ${ANY_DIR_OTHER_THAN_FLAGTREE_PYTHON}; python3 -c 'import triton; print(triton.__path__)'
```
## 免源码安装
参见 [用户手册](https://github.com/flagos-ai/FlagTree/wiki/User-Manual)。
## 关于贡献
欢迎参与 FlagTree 的开发并贡献代码,详情参见 [CONTRIBUTING.md](/CONTRIBUTING_cn.md)。
## 许可证
FlagTree 使用 [MIT license](/LICENSE)。