Back to blog
Guide

How to Add Unsigned Integer Support to PyTorch Operators with add-uint-support

Skill Gallery TeamJanuary 31, 20264 min read

Have you encountered type errors because a PyTorch operator doesn't support unsigned integer types (uint16, uint32, uint64)? Extending ATen kernel type dispatch requires precise understanding of macro structures.

This article explains how to add uint type support to AT_DISPATCH macros using the add-uint-support skill from the PyTorch repository.

What This Skill Does

add-uint-support updates AT_DISPATCH macros in PyTorch operators to add uint16/uint32/uint64 support:

  • Verifies AT_DISPATCH_V2 format prerequisite
  • Guides selection between two addition methods (explicit add vs type group substitution)
  • Provides a decision tree for choosing the right approach
  • Updates all dispatch sites in a file consistently

This skill is for developers working on PyTorch core who need to expand operator type coverage.

Installation

Prerequisites

  • Claude Code installed
  • Access to PyTorch repository source code

Install Command

claude mcp add github.com/pytorch/pytorch/tree/main/.claude/skills/add-uint-support

Usage

Basic Usage

Specify the file where uint support should be added:

Add uint type support to this file

Two Methods

Method 1: Add AT_BAREBONES_UNSIGNED_TYPES explicitly

// After
AT_DISPATCH_V2(dtype, "op", AT_WRAP([&]() {
  kernel<scalar_t>();
}), AT_EXPAND(AT_ALL_TYPES), AT_EXPAND(AT_BAREBONES_UNSIGNED_TYPES));

Method 2: Replace AT_INTEGRAL_TYPES with AT_INTEGRAL_TYPES_V2

// After
AT_DISPATCH_V2(dtype, "op", AT_WRAP([&]() {
  kernel<scalar_t>();
}), AT_EXPAND(AT_INTEGRAL_TYPES_V2));

Decision Tree

Use Method 2 when AT_INTEGRAL_TYPES is present; otherwise use Method 1.

Important Considerations

V2 Format Required

Legacy AT_DISPATCH macros must first be converted to V2 format using the at-dispatch-v2 skill.

Floating-Point Only Operators Are Out of Scope

Operators using only AT_FLOATING_TYPES should not be modified as they don't semantically need uint support.

Update All Dispatch Sites Consistently

When a file has multiple dispatch sites (CPU, CUDA), update all of them consistently.

Summary

add-uint-support enables adding uint16/uint32/uint64 support to PyTorch operators by selecting the appropriate method from a clear decision tree. The skill also handles V2 conversion prerequisites.

For full specifications, visit the skill detail page.

add-uint-support Skill Details

add-uint-supportpytorchcppatentype-dispatch

Related posts