at-dispatch-v2

Convert legacy AT_DISPATCH macros to AT_DISPATCH_V2 in ATen kernels.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

The legacy AT_DISPATCH macros in PyTorch C++ code are verbose and error-prone to port to the AT_DISPATCH_V2 API, hindering migration of kernels and native operators.

Core Features & Use Cases

  • Provides a clear migration pattern to replace AT_DISPATCH_* macros with AT_DISPATCH_V2 in aten/src/ATen/native/ and CUDA kernels.
  • Enforces essential includes and lambda wrapping (AT_WRAP) to avoid argument parsing issues.
  • Use Case: porting a dispatch-heavy operator that previously used AT_DISPATCH_FLOATING_TYPES or AT_DISPATCH_ALL_TYPES to the v2 API.

Quick Start

Identify AT_DISPATCH usage and apply the standard transformation to AT_DISPATCH_V2, wrapping the lambda with AT_WRAP and inserting AT_EXPAND(...) type groups as needed.

Frequently Asked Questions about at-dispatch-v2

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

FAQPage Schema
How do I migrate PyTorch AT_DISPATCH macros to the v2 API?

AT_DISPATCH_FLOATING_TYPES and AT_DISPATCH_ALL_TYPES macros are ported to AT_DISPATCH_V2 by wrapping lambdas with AT_WRAP and placing type groups with AT_EXPAND, requiring the ATen/Dispatch_v2.h header.

What is the difference between AT_DISPATCH and AT_DISPATCH_V2 in ATen kernels?

Legacy AT_DISPATCH macros are verbose and error-prone, while AT_DISPATCH_V2 resolves this by enforcing lambda wrapping with AT_WRAP and AT_EXPAND type groups for ATen native operators and CUDA kernels.

Does the AT_DISPATCH_V2 migration work for both CPU and CUDA kernel paths?

Yes, AT_DISPATCH_V2 conversion applies to both CPU and GPU paths, covering native operators in aten/src/ATen/native/ and CUDA kernel implementations where AT_DISPATCH macros are present.

Why do I need AT_WRAP when porting to AT_DISPATCH_V2 in PyTorch?

AT_WRAP is required when porting to AT_DISPATCH_V2 to wrap lambdas and prevent argument parsing issues, ensuring the converted native operators and CUDA kernels function correctly.

What are the limitations of porting AT_DISPATCH macros to v2 in ATen code?

Conversion is limited to aten/src/ATen/native/ files and CUDA kernels, requiring strict preservation of original argument order when inserting AT_EXPAND type groups and including the Dispatch_v2.h header.