pytorch - ✅(Solved) Fix Feedback about torch.normal [1 pull requests, 2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
pytorch/pytorch#180560Fetched 2026-04-17 08:26:20
View on GitHub
Comments
2
Participants
2
Timeline
16
Reactions
0
Timeline (top)
labeled ×4mentioned ×4subscribed ×4commented ×2

Fix Action

Fixed

PR fix notes

PR #180580: doc: clarify that torch.normal does not support integer dtypes

Description (problem / solution / changelog)

Description

The documentation page for torch.normal does not mention that integer dtypes (e.g., torch.long, torch.int32) are not supported. This causes a confusing NotImplementedError on both CPU and CUDA with no explanation in the docs.

Error Reproduced

CPU: torch.normal(mean=0, std=1, size=(5,), dtype=torch.long) NotImplementedError: "normal_kernel_cpu" not implemented for 'Long'

CUDA: torch.normal(mean=0, std=1, size=(5,), dtype=torch.long, device='cuda') NotImplementedError: "normal_kernel_cuda" not implemented for 'Long'

What This PR Does

Added a .. note:: to the torch.normal docstring in torch/_torch_docs.py clarifying:

  • Only floating-point dtypes are supported
  • torch.set_default_dtype() does NOT affect integer tensor creation
  • torch.tensor(1) always returns int64 — use torch.tensor(1.0) instead

How to Fix (for users)

Wrong - raises NotImplementedError

torch.normal(mean=torch.tensor(1), std=1, size=(5,))

Correct

torch.normal(mean=torch.tensor(1.0), std=1, size=(5,))

Linked Issue

Fixes #180560

Changes

  • torch/_torch_docs.py — added dtype note to torch.normal docstring

Changed files

  • torch/_torch_docs.py (modified, +2/-2)
RAW_BUFFERClick to expand / collapse

There is the following issue on this page: https://docs.pytorch.org/docs/stable/generated/torch.normal.html

The documentation page does not indicate the following issue:

NotImplementedError: "normal_kernel_cuda" not implemented for 'Long' NotImplementedError: "normal_kernel_cpu" not implemented for 'Long'

I don't know if it's general for all devices.

cc @svekars @sekyondaMeta @AlannaBurke @pbelevich

extent analysis

TL;DR

The issue can likely be resolved by using a different data type instead of 'Long' for the torch.normal function.

Guidance

  • The error messages indicate that the "normal_kernel_cuda" and "normal_kernel_cpu" are not implemented for the 'Long' data type, suggesting a data type compatibility issue.
  • Verify the data type of the input to the torch.normal function to confirm it is 'Long'.
  • Consider using a different data type, such as 'Float' or 'Double', that is supported by the torch.normal function.
  • Check the PyTorch documentation for supported data types and potential workarounds for this issue.

Example

No code snippet is provided as the issue does not include specific code.

Notes

The issue may not be specific to all devices, and the error messages only indicate a problem with 'Long' data type on CUDA and CPU devices.

Recommendation

Apply workaround: Use a different data type, such as 'Float' or 'Double', that is supported by the torch.normal function, as the documentation does not indicate support for 'Long' data type.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

pytorch - ✅(Solved) Fix Feedback about torch.normal [1 pull requests, 2 comments, 2 participants]