operator-migration

Migrate native CUDA, Triton, or custom operators into cache-dit with import safety.

1.2k|77|Updated Jun 12, 2025
One-click install
npx skills add https://github.com/vipshop/cache-dit --skill operator-migration
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: operator-migration
Source: https://github.com/vipshop/cache-dit/tree/main/.copilot/skills/operator-migration
Command: npx skills add https://github.com/vipshop/cache-dit --skill operator-migration

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill guides engineers through migrating CUDA, Triton, or other native operator/kernel families into the cache-dit repository while preserving semantics, minimizing native and Python closure, and preventing import-time failures when optional extensions are absent.

Core Features & Use Cases

  • Survey & Scope: Defines how to identify the true call chain, required native files, and the minimal closure to migrate without dragging unnecessary upstream code.
  • Design & API: Helps freeze the public surface, choose repository-aligned names, and decide what remains private versus public.
  • Build, Packaging & Safety: Advises optional-extension gating, delayed extension loading, packaging updates, and explicit dependency strategies.
  • Validation Strategy: Recommends layered tests from import safety to low-level correctness, module behavior, and end-to-end validation.
  • Example Use Case: Port a CUDA INT4 kernel from nunchaku into cache-dit with a private CUDA helper, torch.library registrations, explicit public wrappers, and targeted tests.

Quick Start

Describe the source operator and files, the intended cache-dit public API, required backends and dtypes, and the current migration status so the skill can map the minimal viable closure and validation targets.

Frequently Asked Questions about operator-migration

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

FAQPage Schema
How do I migrate custom CUDA or Triton operators into cache-dit without breaking imports?

To migrate custom CUDA or Triton operators safely, identify the minimal native closure and use delayed extension loading to prevent import-time failures. This ensures semantics are preserved while keeping optional extensions gated when native files are absent.

What is the best way to port upstream kernels from repos like nunchaku into cache-dit?

Porting upstream kernels from repos like nunchaku requires mapping the true call chain and freezing the public API surface. You design private CUDA helpers, torch.library registrations, and explicit public wrappers to maintain repository alignment.

How do I package optional native extensions in Python to avoid import errors?

Packaging optional native extensions safely requires explicit dependency strategies and optional-extension gating during the build process. By implementing delayed extension loading, you prevent import errors when users install the package without native compilation backends.

Does migrating native extensions into cache-dit require torch.library registry placement?

Migrating native extensions into cache-dit requires torch.library registry placement to correctly wire custom CUDA and Triton kernels. This mechanism ensures operators are registered properly, allowing public wrappers to call native code without import-time failures.

What validation strategy should I use when porting Triton kernels into a new repository?

Porting Triton kernels requires a layered validation strategy spanning import safety, low-level correctness, module behavior, and end-to-end testing. This ensures the migrated native operators preserve semantics and perform correctly throughout the entire call chain.

Why does importing custom CUDA operators fail when the compiled extension is missing?

Importing custom CUDA operators fails when compiled extensions are missing because native code loads immediately during module initialization. Implementing delayed extension loading and optional-extension gating prevents these import-time failures when native dependencies are absent.