PyTorch raises NotImplementedError for integer mean/var/std in PR #192351
PyTorch changes integer mean/var/std errors to NotImplementedError — here's why
A new PyTorch commit, PR #192351, tweaks how the framework handles certain statistical operations on integer tensors. Previously, calling mean, var, or std on integer input raised a plain RuntimeError, implying the operation was fundamentally invalid. In reality, these functions are mathematically well-defined for integers—NumPy simply promotes them to floating-point and computes normally. The PyTorch maintainers realized the error message was misleading, so they switched it to NotImplementedError, signaling that the feature could exist but hasn't been built yet. The change also covers var_mean, std_mean, nanmean, and gradient computations, making the entire family consistent.
The commit stands out for more than its technical content: it was authored with the assistance of Claude (via Claude Code) and co-authored by Claude Opus 4.8, highlighting how AI-assisted development is now commonplace even in core infrastructure like PyTorch, which boasts over 102k GitHub stars and 28.9k forks. The update doesn't add new functionality—integer mean/var/std still raise errors—but it corrects the semantics, giving developers clearer feedback. This is especially useful for those migrating from NumPy or working with mixed-type pipelines, where the previous RuntimeError caused confusion. The community approved the PR, with Skylion007 reviewing, and it landed on the trunk branch. For library authors and ML engineers, this small but meaningful change reduces ambiguity in PyTorch's error handling and sets a clearer path toward potential float-promotion support down the line.
- PR #192351 switches integer input errors from RuntimeError to NotImplementedError for mean, var, std, var_mean, std_mean, nanmean, and gradient
- The change aligns PyTorch's semantics with NumPy, where integer reductions are well-defined via float promotion
- Authored with Claude Code and co-authored by Claude Opus 4.8, showing AI-assisted contributions in a project with 102k stars
Why It Matters
Clarifies PyTorch's API semantics, ends confusing RuntimeErrors, and hints at future float-promotion support for integer stats.