bigtech-foss

PyTorch adds torch::stable::add to stable ABI

Key Takeaway

PyTorch introduces a stable addition operator to support the torchvision stable-ABI port.

Summary

PyTorch has added the torch::stable::add operator to its stable Application Binary Interface (ABI), gated by the TORCH_VERSION_2_16_0 flag. This change provides a standardized way to perform tensor addition, which is required for the torchvision stable-ABI port to function without workarounds. The new operator mirrors the existing torch::stable::subtract functionality.

Technical details of the addition operator

  • Implements torch::stable::add(self, other, double alpha = 1.0) using the aten C shim aoti_torch_aten_add_Tensor.
  • Uses a double for the alpha parameter instead of a Scalar due to C shim lowering.
  • Adding two integral or boolean tensors is rejected by aten, though mixed integral/floating point inputs work via type promotion.
  • Includes a new libtorch_agn_2_16 extension and updated documentation for stable operators.

Why it matters

This update enables the torchvision stable-ABI port to operate more cleanly by removing the need for subtraction-based workarounds.

Original reference: github.com →