Add FlagOS backend support for Taichi#8785
Add FlagOS backend support for Taichi#8785GWinfinity wants to merge 2 commits intotaichi-dev:masterfrom
Conversation
This commit adds support for FlagOS (unified AI chip software stack) to Taichi, enabling Taichi programs to run on various AI chips including MLU (Cambricon), Ascend (Huawei), DCU (Hygon), and GCU (Enflame). Major changes: - Add flagos architecture definition and RHI device layer - Implement FlagOS code generator for LLVM IR generation - Add FlagOS program implementation with kernel compiler and launcher - Update build system with TI_WITH_FLAGOS option - Add example programs (fractal, matmul) and documentation New files: - taichi/rhi/flagos/*: RHI device implementation - taichi/codegen/flagos/*: Code generation layer - taichi/runtime/program_impls/flagos/*: Program implementation - examples/flagos/*: Example programs - docs/flagos_integration_design.md: Design documentation Usage: ti.init(arch=ti.flagos, flagos_chip='mlu370') See FLAGOS_CHANGES.md for detailed change log.
|
|
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| auto thread_idx = | ||
| builder->CreateIntrinsic(Intrinsic::nvvm_read_ptx_sreg_tid_x, {}, {}); | ||
| auto block_dim = | ||
| builder->CreateIntrinsic(Intrinsic::nvvm_read_ptx_sreg_ntid_x, {}, {}); |
There was a problem hiding this comment.
NVIDIA PTX intrinsics used for non-NVIDIA chips
High Severity
The get_spmd_info() function uses NVIDIA-specific intrinsics (nvvm_read_ptx_sreg_tid_x and nvvm_read_ptx_sreg_ntid_x) to get thread and block information. FlagOS targets non-NVIDIA AI chips (MLU, Ascend, DCU, GCU), where these NVIDIA PTX intrinsics are invalid and will produce incorrect code or compilation failures.


This commit adds support for FlagOS (unified AI chip software stack) to Taichi, enabling Taichi programs to run on various AI chips including MLU (Cambricon), Ascend (Huawei), DCU (Hygon), and GCU (Enflame).
Major changes:
New files:
Usage:
ti.init(arch=ti.flagos, flagos_chip='mlu370')
See FLAGOS_CHANGES.md for detailed change log.
Issue: #
Brief Summary
copilot:summary
Walkthrough
copilot:walkthrough
Note
High Risk
High risk because it introduces a new architecture/backend path through core program initialization, codegen, and device memory/kernel launch plumbing; many operations are still stubbed (
TI_NOT_IMPLEMENTED) and could fail at runtime if exercised.Overview
Adds a new
Arch::flagosbackend end-to-end: arch registration and LLVM-usage wiring, aflagos_chipcompile option exposed to Python, andProgramselection ofFlagosProgramImplwhen built withTI_WITH_FLAGOS.Introduces new FlagOS-specific modules for RHI/device, LLVM task/kernel codegen, and kernel compilation/launch scaffolding (with placeholders for FlagOS SDK/FlagTree integration), and wires them into the build via
TI_WITH_FLAGOSCMake options and new subdirectories.Adds FlagOS documentation and example scripts (
examples/flagos) demonstratingti.init(arch=ti.flagos, flagos_chip=...)and basic benchmarks.Written by Cursor Bugbot for commit 6cbc8b2. This will update automatically on new commits. Configure here.