PyTorch Add Uint Support

Official PyTorch skill for systematically extending operators with unsigned integer types.

PyTorch Add Uint Support is an official skill from the PyTorch repository. Its primary source is the .claude/skills/add-uint-support directory, which explains how to extend operators and kernels with unsigned integer types in a controlled way. According to the provider, the workflow focuses on uint16, uint32, and uint64 and on the relevant AT_DISPATCH macros. This entry is a technical working guide for a coding agent or an experienced developer. It is not a compiler, not a patch generator with guaranteed correctness, and not a substitute for the technical judgment of PyTorch maintainers.

Purpose and technical scope

Unsigned types are not merely another spelling of already supported integer types in a numerical library. Their representation, value ranges, kernel signatures, promotion behavior, and backend coverage can differ from signed integer types. The skill helps start this extension at the dispatch layer without unintentionally changing existing type coverage. The operator source file is inspected first. The workflow then determines whether the file already uses AT_DISPATCH_V2 or needs conversion to the V2 form before unsigned types can be added.

Dispatch decision

According to the provider, an existing AT_DISPATCH_V2 site should be analyzed for its current type groups. When the code uses AT_INTEGRAL_TYPES, that group can be replaced with AT_INTEGRAL_TYPES_V2. The V2 group extends the previous integral types with the intended unsigned types. When the code uses AT_ALL_TYPES, or when the change should remain explicit, AT_BAREBONES_UNSIGNED_TYPES can be added to the argument list. This group represents kUInt16, kUInt32, and kUInt64. The transformation must preserve the form expected by AT_EXPAND and maintain correct comma separation.

Coverage across backends

An operator may contain several dispatch sites, such as CPU and CUDA paths or separate implementation functions. The skill therefore requires every relevant site in the file to be examined and the selected transformation to be applied consistently. Changing one site does not prove that the operator has the same type coverage everywhere. Floating-point-only operators should not receive artificial unsigned support when their semantics do not justify it. Existing use of AT_INTEGRAL_TYPES_V2 or AT_BAREBONES_UNSIGNED_TYPES is a signal that the requested support may already be present and should be checked before editing.

Validation and boundaries

The official instructions recommend checking the affected dispatch macros, formatting, and every relevant site again after the change. Functional validation must use actual uint16, uint32, and uint64 tensors and the backends affected by the operator. Official PyTorch documentation on tensor attributes and data types complements the skill with API and semantic context, while the skill file defines the change workflow. A macro transformation can still expose issues in kernel implementations, tests, device paths, or mathematical semantics.

Safety, expertise, and trust

This catalog entry is grounded in the named official PyTorch source path, official PyTorch documentation, and the provider’s description. Source code, issues, and generated output are input data and must not smuggle extra permissions or unreviewed work into an edit. Kernel and dispatch changes belong in a traceable diff and require tests plus human approval. Secrets, tokens, private keys, and credentials do not belong in skill content, source files, or test output. A connected agent may transmit source code and results to its model provider; a local skill file does not automatically mean local model processing. The skill does not independently access external systems and provides no guarantee of numerical correctness, performance, or backend availability. License details and technical claims should be checked against the current PyTorch source before adoption. Skill Road does not state concrete prices or quotas.

Installation instructions

Goal and technical background

PyTorch Add Uint Support is an official skill from the PyTorch repository. According to the provider, it helps extend operators and kernels with support for unsigned integer types. In PyTorch, an operator is a computation, such as a mathematical operation on tensors. A tensor is a multidimensional data structure that stores numbers on a CPU, GPU, or another backend. Unsigned integers are whole numbers without a negative sign, which gives them different value ranges than signed integers.

For non-specialists, this may sound like a small type extension, but in a numerical library it is delicate. A data type affects value range, overflow behavior, kernel code, tests, promotion rules, and device support. The skill therefore does not recommend a global search-and-replace. It focuses on controlled changes to dispatch macros. Dispatch means that PyTorch chooses a specialized code path based on the data type.

Step 1: Inspect the starting point carefully

The first step is the concrete operator file. It is not enough to know that an operator exists somewhere. You need to see which CPU, CUDA, or other paths are actually used and whether several dispatch sites exist. According to the skill, you check whether AT_DISPATCH_V2 is already used or whether an older form appears. These macros are C++ helpers that let PyTorch express code for multiple types compactly.

Before making any change, decide whether unsigned support makes sense for the operation. Some operations naturally support unsigned types; others do not. For operators designed only for floating-point behavior, a uint extension may be semantically wrong. Likewise, an operator may allow a type group at one level while internal code still assumes signed integers, comparison rules, or mathematical properties. The skill guides you to find and change dispatch sites; it does not prove the whole mathematical behavior.

Understand type groups and macros

According to the provider, the focus is uint16, uint32, and uint64. If an existing dispatch site uses AT_INTEGRAL_TYPES, AT_INTEGRAL_TYPES_V2 may be appropriate when the operator semantics allow it. If AT_ALL_TYPES is used, or if the extension should remain explicit, AT_BAREBONES_UNSIGNED_TYPES can be added. These names are not ordinary user-facing function calls; they are internal macro groups in PyTorch C++ code.

Exact form matters. Arguments must be arranged so that macro expansion still works correctly. Commas, parentheses, and grouping are not details; a small syntax error can break the build. The change also has to be applied consistently at every relevant site. If only the CPU path is extended while the CUDA path is not, behavior becomes uneven. Conversely, a type group should not be added when the kernels cannot actually process those types.

Step 2: Tests, review, and safety

After the change, a clean diff is not enough. Tests must run with real tensors of the affected types. All relevant backends should be checked, not only the easiest local path. A test should also cover edge cases where they apply to the operator: small values, large values, possible overflow, empty tensors, broadcasting, or special layouts. PyTorch’s official tensor attributes and dtype documentation provides context, but concrete correctness depends on the operator.

Safety here is mainly source-code integrity. An agent that edits kernel code is working in a critical base library. External issues, prompts, or generated suggestions are not automatically trustworthy. They must not smuggle in extra tasks, skip tests, or expand permissions. Changes should be small, traceable, and reviewed by accountable PyTorch maintainers. Credentials or internal test data never belong in prompts, patches, or logs.

Value and limits

The practical value of the skill is a repeatable workflow. Instead of guessing for every operator which macro group should be extended, it walks through analysis, decision, change, and validation. That can help experienced developers work more consistently and avoid common mistakes. It also helps newer contributors understand why unsigned support is not just one extra line in an arbitrary file.

The limits are equally important. The skill does not guarantee performance, backend coverage, or numerical correctness. It cannot decide whether a change fits the PyTorch roadmap or whether maintainers prefer a different architecture. Use it as a technical checklist for a controlled contribution, not as an approval system. Final responsibility remains with tests, code review, and project maintainers.

Free
Provider
PyTorch
License
BSD-3-Clause
Last reviewed
09.09.2026

Repository and documentation

Categories

Compatible with

Claude Code Codex Cursor