native-op-backend

Generates native operator kernels for non-CUDA-compatible accelerators via category-based codegen.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Enabling PyTorch operators on an accelerator that is not CUDA-compatible requires hand-writing hundreds of vendor kernel bindings, which is intractable. This Skill provides a category-based codegen approach that reduces the work to a handful of templates plus a one-line-per-operator mapping table. ## Core Features & Use Cases - Category-based kernel generation: Groups operators into categories (unary, binary, reduce, gemm) so one template covers many operators, modeled on the Ascend ACLNN backend that reached 138 operators from 63 categories. - Vendor support layer guidance: Walks through writing the op_api_common/op_preparation headers, the EXEC macro hiding workspace query and execute sequences, and dtype enum mapping. - Backend slot and routing setup: Covers adding the k<Vendor> enum, the conf file that routes ops at runtime, and CMake gating via FLAGOS_BUILD_VENDOR. - Use Case: After runtime bring-up passes on a new Ascend-like chip and CUDA compatibility has been ruled out by measurement, use this Skill to generate kernels, wire routing, and verify each operator against CPU with per-op comparison tests. ## Quick Start Enable the unary operator category on my non-CUDA-compatible accelerator by generating native vendor kernels and verifying them against CPU comparison tests.

Frequently Asked Questions about native-op-backend

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

FAQPage Schema
How do I enable PyTorch operators on a non-CUDA-compatible accelerator?▼

Bind the vendor's native operator library per operator through category-based codegen. Group operators into categories like unary, binary, and reduce, write one kernel body template per category, and add one line per operator to the OPS mapping table.

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

Only after the CUDA-compatible path has been measured and failed. Native backend development is roughly an order of magnitude more work, so the cheaper boxing check is always worth running first.

Why does my registered kernel never execute at runtime?▼

Registration and routing are separate mechanisms. A kernel registered in the k<Vendor> dispatcher slot still needs a matching op = <vendor> line in the backends conf file, or it never gets routed and silently does nothing.

How do I verify native vendor kernels produce correct results?▼

Run per-operator CPU comparison tests with pytest using the vendor marker. Measured Ascend tolerances are unary at or below 4.4e-5 and binary at or below 4.7e-6; a unary op off by 1e-2 indicates a bug, not hardware noise.

What causes duplicate registration crashes when adding a backend?▼

An op that is both generated and hand-written in the same backend slot crashes at import. Keep the SKIP set and the generated set disjoint, and never declare your own dispatchers since ops.h already provides them.