at-dispatch-v2

Convert PyTorch AT_DISPATCH macros to AT_DISPATCH_V2 format in ATen C++ code.

1|Updated Apr 12, 2026
One-click install
npx skills add https://github.com/teddytennant/rusttorch --skill at-dispatch-v2-teddytennant
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: at-dispatch-v2
Source: https://github.com/teddytennant/rusttorch/tree/main/.claude/skills/at-dispatch-v2
Command: npx skills add https://github.com/teddytennant/rusttorch --skill at-dispatch-v2-teddytennant

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill automates updating PyTorch AT_DISPATCH macros to the v2 format, enabling safer, more scalable kernel dispatch.

Core Features & Use Cases

  • Macro conversion: Transform AT_DISPATCH_* macros to AT_DISPATCH_V2.
  • Pattern handling: Reorder arguments, wrap lambdas with AT_WRAP, and expand type groups.
  • Include management: Ensure #include <ATen/Dispatch_v2.h> is present.

Quick Start

Convert a typical AT_DISPATCH_ALL_TYPES_AND3... block to AT_DISPATCH_V2(dtype, "kernel", AT_WRAP(&{...}), AT_EXPAND(AT_ALL_TYPES), kBFloat16, kHalf, kBool);

Frequently Asked Questions about at-dispatch-v2

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

FAQPage Schema
How do I convert AT_DISPATCH macros to AT_DISPATCH_V2 in PyTorch C++ code?

AT_DISPATCH_V2 conversion transforms legacy AT_DISPATCH_ALL_TYPES_AND* macros to v2 format by reordering arguments, wrapping lambdas with AT_WRAP, expanding type groups with AT_EXPAND, and adding #include <ATen/Dispatch_v2.h> to aten/src/ATen/native/ kernel implementations.

What's the difference between AT_DISPATCH and AT_DISPATCH_V2?

AT_DISPATCH_V2 provides safer, more scalable kernel dispatch with explicit type enumeration and structured argument ordering, replacing the older AT_DISPATCH macro patterns that relied on type group macros like AT_DISPATCH_ALL_TYPES_AND*.

Do I need to update all AT_DISPATCH macros to v2 format?

AT_DISPATCH_V2 migration applies specifically to AT_DISPATCH_ALL_TYPES_AND*, AT_DISPATCH_FLOATING_TYPES*, and related dispatch macros in ATen kernel operator implementations; legacy patterns should be converted to maintain consistency with PyTorch's dispatch infrastructure.

What happens to type groups like AT_ALL_TYPES when converting to AT_DISPATCH_V2?

Type groups expand using AT_EXPAND during AT_DISPATCH_V2 conversion, replacing macro-based type grouping with explicit individual type listings such as kBFloat16, kHalf, and kBool for precise kernel dispatch.

Can I use AT_DISPATCH_V2 with existing ATen kernel code?

AT_DISPATCH_V2 integration requires converting macro invocations in ATen kernel operator implementations, wrapping dispatch logic with AT_WRAP, and ensuring the Dispatch_v2.h header is included for compatibility with modern PyTorch dispatch patterns.

What files need modification when converting to AT_DISPATCH_V2?

Conversions target aten/src/ATen/native/ directory files containing AT_DISPATCH macro invocations in kernel operator implementations, updating macro signatures and adding required dispatch v2 headers.