runtime-bringup

Implement the torch_fl device runtime contract for a new accelerator backend.

12|18|Updated Apr 7, 2026
One-click install
npx skills add https://github.com/flagos-ai/Torch-FL --skill runtime-bringup-flagos-ai
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: runtime-bringup
Source: https://github.com/flagos-ai/Torch-FL/tree/main/.claude/skills/runtime-bringup
Command: npx skills add https://github.com/flagos-ai/Torch-FL --skill runtime-bringup-flagos-ai

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Bringing up a brand-new accelerator chip in torch_fl requires implementing a fixed runtime contract — 28 C ABI functions plus 10 allocator virtuals — before any operator can run, and getting any piece wrong (error mapping, CMake wiring, allocator selection) produces confusing failures far from the real cause. ## Core Features & Use Cases - Exact function inventory: Enumerates the 28 C ABI functions in csrc/include/flagos.h and 10 allocator virtuals, partitioned into device.cc, memory.cc, and stream.cc per vendor. - Build wiring guidance: Covers the three mandatory CMake sites, the USE_<VENDOR> macro, and the negative CUDA-include guard in caching_device_allocator.cc that is the most common mistake. - Operator-free smoke test: Provides a symbol-completeness check and a Python test proving allocation, H2D/D2H memcpy, and stream/event synchronization work with zero operators registered. - Use Case: You are porting torch_fl to Kunlun XPU. Follow the skill to pick musa/ as the reference implementation, implement the runtime floor, wire the build, and pass the smoke test before starting any operator backend work. ## Quick Start Use the runtime-bringup skill to implement the torch_fl device runtime contract for a new accelerator such as Kunlun XPU before registering any operators.

Frequently Asked Questions about runtime-bringup

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a new accelerator backend to torch_fl?▼

Implement the runtime contract first: 28 C ABI functions declared in csrc/include/flagos.h plus 10 DeviceMemoryInterface allocator virtuals, split across device.cc, memory.cc, and stream.cc. Then wire the USE_<VENDOR> macro at three CMake sites and pass the operator-free smoke test before registering any operators.

Which reference implementation should I read for a new chip port?▼

Pick based on the SDK shape: accelerator/cuda for libcudart shims, accelerator/musa for renamed CUDA-style APIs like Kunlun XPU's xpu_malloc, accelerator/ascend or gcu for different execution models, and accelerator/bpu when the chip has no stream concept.

Why does StreamQuery error mapping break the caching allocator?▼

StreamQuery and EventQuery must return ErrorNotReady for still-running work, not a generic error. The caching allocator's block-reuse path treats ErrorNotReady as not safe to reuse yet and anything else as a hard failure, so collapsing it causes deadlocks or memory corruption.

Should provides_caching return true for a new accelerator?▼

Default to false for a new chip and use the built-in block pool. Return true only if the platform ships a mature caching allocator that does not claim the PrivateUse1 allocator slot torch_fl registers, as the MUSA backend demonstrates.

Why does the build fail after adding a new vendor to CMake?▼

The most common cause is forgetting to add USE_<VENDOR> to the negative CUDA-include guard in caching_device_allocator.cc. Both cuda_memory.h and your header then get included, producing duplicate definitions or wrong-backend selection that points nowhere near the real cause.

When should I use CUDA-compatible boxing instead of a native operator backend?▼

Use CUDA-compatible boxing when the vendor ships a torch wheel containing libtorch_cuda.so whose nm output shows at::add and at::mm symbols, since it is roughly an order of magnitude less work. Otherwise implement a native operator backend, deciding from SDK evidence rather than marketing claims.