[tensor-shapes] torch.lerp rejects tensor weights and omits their broadcast shape
Maintainers usually reply within 2 days
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Domain
- backend-api-design
Research direction
The issue points to tensor-shapes/pyrefly-torch-stubs/torch-stubs/__init__.pyi near line 3689. Read the torch.lerp signature and its shape expression, then run the provided repro.py with pyrefly check. Done means the Tensor weight is accepted and the inferred result shape includes its broadcast shape, so the example checks with shape (3, 2).
Written by the indexing model from the issue text.
Description
Describe the Bug
torch.lerp accepts a Tensor as its weight argument. The weight can also expand the result shape through broadcasting.
The shape stub only accepts float and computes the result shape from input and end.
Minimal reproduction
Save this code as repro.py. Create an empty pyrefly.toml next to it.
import torch
start = torch.zeros(2)
end = torch.ones(2)
weight = torch.full((3, 1), 0.5)
result = torch.lerp(start, end, weight)
assert result.shape == (3, 2)
assert torch.equal(result, torch.full((3, 2), 0.5))
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
Accept Tensor weights. Include the weight shape when computing the broadcast result. In this example, the result shape is (3, 2).
Actual behavior
repro.py:6:33: Argument `Tensor[[3, 1]]` is not assignable to parameter `weight` with type `float` in function `torch.lerp` [bad-argument-type]
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 signature declares weight: float and returns Tensor[broadcast(Shape, OtherShape)]. The Tensor-weight case needs a third shape.
- Dominant language
- Rust
- Stars
- 7.1k
- Forks
- 564
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from facebook/pyrefly
-
`pyrefly report .` panics if stream not read completelyPossibly taken @asukaminato0721 claimed this today. Opencrash
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
facebook/pyrefly#5362 · 1 assignee ·
Maintainers usually reply within 2 days
-
[tensor-shapes] torch.half dtype alias is missing from torch stubsPossibly taken @mangeshraut712 claimed this today. Opengood first issue pytorch tensor-shapes
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
facebook/pyrefly#5361 · 3 comments ·
Maintainers usually reply within 2 days
-
[tensor-shapes] torch.empty overloads omit requires_gradPossibly taken @Cha-Imaa claimed this today. Openpytorch tensor-shapes
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
facebook/pyrefly#5359 · 2 comments · 1 assignee ·
Maintainers usually reply within 2 days
-
bug(stubgen): `typing` / `_typeshed` imports are emitted above `from __future__ import annotations`Possibly taken @mangeshraut712 claimed this today. Opengood first issue stubgen
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
facebook/pyrefly#5321 · 1 comment ·
Maintainers usually reply within 2 days
-
[tensor-shapes] NumPy mean and sum declare rank-zero ndarrays for scalar resultsPossibly taken @mangeshraut712 claimed this today. Opentensor-shapes
Difficulty 4/5 3-5 days Newbie friendliness 55/100
Maintainers usually reply within 2 days
All issues in facebook/pyrefly
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
Maintainers usually reply within 1 day
-
C-bug needs-triage O-UEFI T-libs
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
bug priority: P3 ready-for-agent
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
shep-pm/shep-kelpie#1332 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
ramensoftware/windhawk#1156 · 2 comments ·
-
area/cli complexity:trivial good first issue Stellar Wave test
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Externalize-Labs/externalize#23 ·
Maintainers usually reply within 1 day