Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[tensor-shapes] torch.half dtype alias is missing from torch stubs

Open Beginner friendly
#5,361 3 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

@mangeshraut712 is already working on this.

Since Oct 25, 2026.

  • #5365 by @mangeshraut712 — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python, rust

Research direction

The relevant declaration is in tensor-shapes/pyrefly-torch-stubs/torch-stubs/__init__.pyi around line 680. Read the existing float16 declaration and compare it with the public torch.half alias described in the issue; the Tensor.half method is a separate API. Done when the module-level alias has the same dtype type as torch.float16 and the supplied reproduction no longer reports missing-attribute.

Written by the indexing model from the issue text.

Description

good first issue pytorch tensor-shapes
Describe the Bug

torch.half is a public dtype alias for torch.float16.

Pyrefly reports missing-attribute when the shape stubs are active.

Minimal reproduction

Save this code as repro.py. Create an empty pyrefly.toml next to it.

import torch

assert torch.half == torch.float16

Run:

python repro.py
pyrefly check repro.py

The runtime assertions pass and the process exits with code 0. The type check reports the errors below.

Expected behavior

Expose the module-level torch.half alias with the same dtype type as torch.float16.

Actual behavior
repro.py:3:8: No attribute `half` in module `torch` [missing-attribute]
Environment and current source
  • Python 3.13.13 on Linux.
  • Pyrefly 1.4.0.
  • pyrefly-torch-stubs==1.4.0.
  • PyTorch 2.13.0+cu126.

I also reproduced this with the stub sources from main at e5f077bcb2897dad3d168c45b9b64271fca94db6. The local Pyrefly binary reports pyrefly 1.4.0. I selected the checkout stub package directories with --site-packages-path. The diagnostics above use those current source files.

Current stub source. The current stub declares float16, but does not expose the module-level half alias. The existing Tensor.half method is a separate API.

Dominant language
Rust
Stars
7.1k
Forks
564
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from facebook/pyrefly

All issues in facebook/pyrefly

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.