-
Notifications
You must be signed in to change notification settings - Fork 25.6k
remove allow-untyped-defs from ao/quantization/experimental/fake_quantize.py #144091
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/144091
Note: Links to docs will display an error until the docs builds have been completed. ⏳ No Failures, 3 PendingAs of commit 68d7766 with merge base d88a8c4 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
level_indices: Tensor | ||
|
||
def __init__(self, observer=APoTObserver, **observer_kwargs): | ||
def __init__(self, observer: Callable = APoTObserver, **observer_kwargs: Any): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_P = ParamSpec("_P")
_R = TypeVar("_R")
...
class APoTFakeQuantize(FakeQuantizeBase):
def __init__(self, observer: Callable[_P, _R] = APoTObserver, *observer_args: _P.args, **observer_kwargs: _P.kwargs):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Although that may cascade into a bunch of other type errors...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah exactly:
>>> Lint for torch/ao/quantization/experimental/fake_quantize.py:
Error (MYPY) [assignment]
Incompatible default for argument "observer" (default has type
"type[APoTObserver]", argument has type "Callable[_P, _R]")
20 | level_indices: Tensor
21 |
22 | def __init__(
>>> 23 | self, observer: Callable[_P, _R] = APoTObserver, **observer_kwargs: Any
24 | ):
25 | super().__init__()
26 | self.activation_post_process = observer(**observer_kwargs)
Error (MYPY) [call-arg]
Too few arguments
23 | self, observer: Callable[_P, _R] = APoTObserver, **observer_kwargs: Any
24 | ):
25 | super().__init__()
>>> 26 | self.activation_post_process = observer(**observer_kwargs)
27 | self.dtype = self.activation_post_process.dtype
28 |
29 | def calculate_qparams(self, signed: bool = False) -> tuple[Tensor, Tensor, Tensor, Tensor]: # type: ignore[override]
Error (MYPY) [attr-defined]
"_R" has no attribute "dtype"
24 | ):
25 | super().__init__()
26 | self.activation_post_process = observer(**observer_kwargs)
>>> 27 | self.dtype = self.activation_post_process.dtype
28 |
29 | def calculate_qparams(self, signed: bool = False) -> tuple[Tensor, Tensor, Tensor, Tensor]: # type: ignore[override]
30 | return self.activation_post_process.calculate_qparams(signed=signed)
Error (MYPY) [attr-defined]
"_R" has no attribute "calculate_qparams"
27 | self.dtype = self.activation_post_process.dtype
28 |
29 | def calculate_qparams(self, signed: bool = False) -> tuple[Tensor, Tensor, Tensor, Tensor]: # type: ignore[override]
>>> 30 | return self.activation_post_process.calculate_qparams(signed=signed)
31 |
32 | def forward(self, X: torch.Tensor) -> Tensor: # type: ignore[override]
33 | if self.observer_enabled[0] == 1:
Error (MYPY) [attr-defined]
"_R" has no attribute "forward"
31 |
32 | def forward(self, X: torch.Tensor) -> Tensor: # type: ignore[override]
33 | if self.observer_enabled[0] == 1:
>>> 34 | self.activation_post_process.forward(X)
35 | result = self.activation_post_process.calculate_qparams(signed=False)
36 | self.alpha = result[0]
37 | self.gamma = result[1]
Error (MYPY) [attr-defined]
"_R" has no attribute "calculate_qparams"
32 | def forward(self, X: torch.Tensor) -> Tensor: # type: ignore[override]
33 | if self.observer_enabled[0] == 1:
34 | self.activation_post_process.forward(X)
>>> 35 | result = self.activation_post_process.calculate_qparams(signed=False)
36 | self.alpha = result[0]
37 | self.gamma = result[1]
38 | self.quantization_levels = result[2]
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
@pytorchmergebot merge -f "Unrelated pending" |
The merge job was canceled or timed out. This most often happen if two merge requests were issued for the same PR, or if merge job was waiting for more than 6 hours for tests to finish. In later case, please do not hesitate to reissue the merge command |
Merge startedYour change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Stack from ghstack (oldest at bottom):