Skip to content

[BE]: Fix typing None override other optimizers#153386

Closed
Skylion007 wants to merge 4 commits intopytorch:mainfrom
Skylion007:skylion007/typing-optimizer-none-overload-2025-05-12
Closed

[BE]: Fix typing None override other optimizers#153386
Skylion007 wants to merge 4 commits intopytorch:mainfrom
Skylion007:skylion007/typing-optimizer-none-overload-2025-05-12

Conversation

@Skylion007
Copy link
Collaborator

@Skylion007 Skylion007 commented May 12, 2025

Follow up to #153367 to fix other instances of it throughout the codebase

Also fully type NamedOptimizer since we were so close

cc @H-Huang @awgu @wanchaol @fegin @fduwjj @wz337 @wconstab @d4l3k @ezyang @malfet @xuzhao9 @gramster

@pytorch-bot
Copy link

pytorch-bot bot commented May 12, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/153386

Note: Links to docs will display an error until the docs builds have been completed.

✅ You can merge normally! (1 Unrelated Failure)

As of commit 8f0b493 with merge base dc47295 (image):

BROKEN TRUNK - The following job failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pytorch-bot pytorch-bot bot added the oncall: distributed Add this issue/PR to distributed oncall triage queue label May 12, 2025
@Skylion007 Skylion007 added topic: not user facing topic category release notes: optimizer Relating to optimizers, torch.optim module: typing Related to mypy type annotations and removed topic: not user facing topic category labels May 12, 2025
@Skylion007 Skylion007 requested a review from malfet May 12, 2025 16:50
@janeyx99 janeyx99 added the topic: not user facing topic category label May 12, 2025
Copy link
Contributor

@janeyx99 janeyx99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls fix lint

@Skylion007 Skylion007 force-pushed the skylion007/typing-optimizer-none-overload-2025-05-12 branch from 2eb3282 to 89b9559 Compare May 12, 2025 18:38
@Skylion007 Skylion007 force-pushed the skylion007/typing-optimizer-none-overload-2025-05-12 branch from 89b9559 to be75382 Compare May 12, 2025 20:40
*args,
**kwargs,
*args: tuple[Any, ...],
**kwargs: dict[str, Any],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kwargs should be typed Any unless their values are dict. And args should be Any

Copy link
Collaborator Author

@Skylion007 Skylion007 May 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cyyever they can't be expanded unless the keys are string so it should be fine (raises a type error)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cyyever Actually, doing [str, Any] is safer and I'm pretty sure preferrable as it can detect those kind of type errors ahead of time

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By Python syntax, their keys are of course strings.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah so this should be the appropriate typing for kwargs.

@cyyever
Copy link
Collaborator

cyyever commented May 14, 2025

@pytorchmergebot merge -i

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label May 14, 2025
@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged while ignoring the following 0 checks:

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@pytorchmergebot
Copy link
Collaborator

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
For more information see pytorch-bot wiki.

@cyyever
Copy link
Collaborator

cyyever commented May 14, 2025

@pytorchmergebot merge -i

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged while ignoring the following 0 checks:

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@Skylion007
Copy link
Collaborator Author

@pytorchbot merge

@pytorchmergebot
Copy link
Collaborator

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
For more information see pytorch-bot wiki.

@pytorchmergebot
Copy link
Collaborator

Merge started

Your 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

Advanced Debugging
Check the merge workflow status
here

@pytorchmergebot
Copy link
Collaborator

Merge failed

Reason: 1 mandatory check(s) failed. The first few are:

Dig deeper by viewing the failures on hud

Details for Dev Infra team Raised by workflow job

Failing merge rule: Core Maintainers

@Skylion007
Copy link
Collaborator Author

@pytorchbot merge -i

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged while ignoring the following 1 checks: pull / cuda12.4-py3.10-gcc9-sm75 / test (pr_time_benchmarks, 1, 1, linux.g4dn.metal.nvidia.gpu)

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@Skylion007 Skylion007 added the better-engineering Relatively self-contained tasks for better engineering contributors label May 14, 2025
@Skylion007 Skylion007 mentioned this pull request May 14, 2025
pytorchmergebot pushed a commit that referenced this pull request May 14, 2025
Fix typo from #153386

Pull Request resolved: #153561
Approved by: https://github.com/albanD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

better-engineering Relatively self-contained tasks for better engineering contributors ciflow/trunk Trigger trunk jobs on your pull request Merged module: typing Related to mypy type annotations oncall: distributed Add this issue/PR to distributed oncall triage queue open source release notes: optimizer Relating to optimizers, torch.optim topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants