Skip to content
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

Unify MYPYINDUCTOR and MYPY #118432

Closed
wants to merge 6 commits into from
Closed

Conversation

ezyang
Copy link
Contributor

@ezyang ezyang commented Jan 26, 2024

Stack from ghstack (oldest at bottom):

The original motivation for MYPYINDUCTOR was a faster type checking configuration that only checked a subset of files. With the removal of follow_imports = ignore, we are now able to use dmypy to do fast incremental typechecking, eliminating the need for this.

Perhaps erroneously, when I tee'ed up this PR I elected to delete the follow_imports = skip designations in the mypy-inductor.ini. This lead to a number of extra type error suppressions that I manually edited. You will need to review.

Signed-off-by: Edward Z. Yang ezyang@meta.com

cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @peterbell10 @ipiszy @yf225 @chenyang78 @kadeng @muchulee8 @aakhundov @ColinPeppler

Signed-off-by: Edward Z. Yang <ezyang@meta.com>

[ghstack-poisoned]
@pytorch-bot pytorch-bot bot added the release notes: onnx torch.onnx related changes that should show up in the release notes label Jan 26, 2024
Copy link

pytorch-bot bot commented Jan 26, 2024

🔗 Helpful Links

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

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

✅ No Failures

As of commit 5772c25 with merge base ff8e335 (image):
💚 Looks good so far! There are no failures yet. 💚

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

Signed-off-by: Edward Z. Yang <ezyangmeta.com>

cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx peterbell10 ipiszy yf225 chenyang78 kadeng muchulee8 aakhundov ColinPeppler

[ghstack-poisoned]
The original motivation for MYPYINDUCTOR was a faster type checking configuration that only checked a subset of files. With the removal of `follow_imports = ignore`, we are now able to use dmypy to do fast incremental typechecking, eliminating the need for this.

Perhaps erroneously, when I tee'ed up this PR I elected to delete the `follow_imports = skip` designations in the mypy-inductor.ini. This lead to a number of extra type error suppressions that I manually edited. You will need to review.

Signed-off-by: Edward Z. Yang <ezyangmeta.com>

cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx peterbell10 ipiszy yf225 chenyang78 kadeng muchulee8 aakhundov ColinPeppler

[ghstack-poisoned]
The original motivation for MYPYINDUCTOR was a faster type checking configuration that only checked a subset of files. With the removal of `follow_imports = ignore`, we are now able to use dmypy to do fast incremental typechecking, eliminating the need for this.

Perhaps erroneously, when I tee'ed up this PR I elected to delete the `follow_imports = skip` designations in the mypy-inductor.ini. This lead to a number of extra type error suppressions that I manually edited. You will need to review.

Signed-off-by: Edward Z. Yang <ezyangmeta.com>

cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx peterbell10 ipiszy yf225 chenyang78 kadeng muchulee8 aakhundov ColinPeppler

[ghstack-poisoned]
@ezyang ezyang requested review from int3, malfet and albanD January 26, 2024 23:51
The original motivation for MYPYINDUCTOR was a faster type checking configuration that only checked a subset of files. With the removal of `follow_imports = ignore`, we are now able to use dmypy to do fast incremental typechecking, eliminating the need for this.

Perhaps erroneously, when I tee'ed up this PR I elected to delete the `follow_imports = skip` designations in the mypy-inductor.ini. This lead to a number of extra type error suppressions that I manually edited. You will need to review.

Signed-off-by: Edward Z. Yang <ezyangmeta.com>

cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx peterbell10 ipiszy yf225 chenyang78 kadeng muchulee8 aakhundov ColinPeppler

[ghstack-poisoned]
The original motivation for MYPYINDUCTOR was a faster type checking configuration that only checked a subset of files. With the removal of `follow_imports = ignore`, we are now able to use dmypy to do fast incremental typechecking, eliminating the need for this.

Perhaps erroneously, when I tee'ed up this PR I elected to delete the `follow_imports = skip` designations in the mypy-inductor.ini. This lead to a number of extra type error suppressions that I manually edited. You will need to review.

Signed-off-by: Edward Z. Yang <ezyangmeta.com>

cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx peterbell10 ipiszy yf225 chenyang78 kadeng muchulee8 aakhundov ColinPeppler

[ghstack-poisoned]
@ezyang ezyang added the topic: not user facing topic category label Jan 27, 2024
ezyang added a commit that referenced this pull request Jan 27, 2024
Signed-off-by: Edward Z. Yang <ezyangmeta.com>

ghstack-source-id: 3f27751d06d3f4b5d71e79e23858660478b2e194
Pull Request resolved: #118432
@ezyang
Copy link
Contributor Author

ezyang commented Jan 27, 2024

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Jan 27, 2024
pytorchmergebot pushed a commit that referenced this pull request Jan 28, 2024
When using dmypy, this setting is enabled and cannot be turned off. Force it for regular mypy too.

Signed-off-by: Edward Z. Yang <ezyang@meta.com>

Pull Request resolved: #118467
Approved by: https://github.com/Skylion007
ghstack dependencies: #118414, #118418, #118432
pytorchmergebot pushed a commit that referenced this pull request Jan 28, 2024
Signed-off-by: Edward Z. Yang <ezyang@meta.com>
Pull Request resolved: #118468
Approved by: https://github.com/Skylion007
ghstack dependencies: #118414, #118418, #118432, #118467
pytorchmergebot pushed a commit that referenced this pull request Jan 28, 2024
dmypy silently ignores follow_imports = skip, so to get parity between
dmypy and mypy we have to suck it up and type: ignore all of the sympy
typing problems.

The suppressions were added automatically with the following script generated by GPT-4:

```
import re

# Read the error file
with open("error_file.txt", "r") as f:
    errors = f.readlines()

# Parse the lines with errors and error types
error_lines = {}
for error in errors:
    match = re.match(r"(.*):(\d+):\d+: error:.*\[(.*)\]", error)
    if match:
        file_path, line_number, error_type = match.groups()
        if file_path not in error_lines:
            error_lines[file_path] = {}
        error_lines[file_path][int(line_number)] = error_type

# Insert ignore comments in the source files
for file_path, lines in error_lines.items():
    with open(file_path, "r") as f:
        code = f.readlines()
    for line_number, error_type in sorted(lines.items(), key=lambda x: x[0], reverse=True):
        code[line_number - 1] = code[line_number - 1].rstrip() + f"  # type: ignore[{error_type}]\n"
    with open(file_path, "w") as f:
        f.writelines(code)
```

Signed-off-by: Edward Z. Yang <ezyang@meta.com>

Pull Request resolved: #118469
Approved by: https://github.com/Skylion007
ghstack dependencies: #118414, #118418, #118432, #118467, #118468
pytorchmergebot pushed a commit that referenced this pull request Jan 28, 2024
Signed-off-by: Edward Z. Yang <ezyang@meta.com>
Pull Request resolved: #118475
Approved by: https://github.com/suo
ghstack dependencies: #118414, #118418, #118432, #118467, #118468, #118469
pytorchmergebot pushed a commit that referenced this pull request Jan 28, 2024
As we force a specific version of mypy, it's OK to use the agglomerated flag.

Signed-off-by: Edward Z. Yang <ezyang@meta.com>
Pull Request resolved: #118479
Approved by: https://github.com/Skylion007, https://github.com/albanD
ghstack dependencies: #118414, #118418, #118432, #118467, #118468, #118469, #118475
pytorchmergebot pushed a commit that referenced this pull request Jan 28, 2024
Signed-off-by: Edward Z. Yang <ezyang@meta.com>
Pull Request resolved: #118480
Approved by: https://github.com/Skylion007, https://github.com/albanD
ghstack dependencies: #118414, #118418, #118432, #118467, #118468, #118469, #118475, #118479
pytorchmergebot pushed a commit that referenced this pull request Jan 28, 2024
Signed-off-by: Edward Z. Yang <ezyang@meta.com>
Pull Request resolved: #118481
Approved by: https://github.com/Skylion007, https://github.com/albanD
ghstack dependencies: #118414, #118418, #118432, #118467, #118468, #118469, #118475, #118479, #118480
@@ -44,14 +44,14 @@ def run_tests(needs=()):
class TestCase(TorchTestCase):
@classmethod
def tearDownClass(cls):
cls._exit_stack.close()
cls._exit_stack.close() # type: ignore[attr-defined]
Copy link
Contributor

Choose a reason for hiding this comment

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

we should add _exit_stack as an uninitialized class member instead

i.e.

class TestCase(TorchTestCase):
   _exit_stack: <type>

@@ -1,3 +1,5 @@
# mypy: ignore-errors
Copy link
Contributor

Choose a reason for hiding this comment

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

this should probably be autogen'ed as part of gen_attention_patterns.py

@@ -343,11 +343,11 @@ def _is_valid_binary(match, fn):
if any(
not (
hasattr(n.args[0], "meta")
and isinstance(n.args[0].meta.get("val", None), torch.Tensor)
and isinstance(n.args[0].meta.get("val", None), torch.Tensor) # type: ignore[union-attr]
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess we should probably type meta as a Dict of Any values?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

SEND FIXES PLZ!!

@facebook-github-bot facebook-github-bot deleted the gh/ezyang/2527/head branch January 31, 2024 15:23
jeffdaily pushed a commit to ROCm/pytorch that referenced this pull request Feb 8, 2024
The original motivation for MYPYINDUCTOR was a faster type checking configuration that only checked a subset of files. With the removal of `follow_imports = ignore`, we are now able to use dmypy to do fast incremental typechecking, eliminating the need for this.

Perhaps erroneously, when I tee'ed up this PR I elected to delete the `follow_imports = skip` designations in the mypy-inductor.ini. This lead to a number of extra type error suppressions that I manually edited. You will need to review.

Signed-off-by: Edward Z. Yang <ezyang@meta.com>

Pull Request resolved: pytorch#118432
Approved by: https://github.com/Skylion007
ghstack dependencies: pytorch#118414, pytorch#118418
jeffdaily pushed a commit to ROCm/pytorch that referenced this pull request Feb 8, 2024
When using dmypy, this setting is enabled and cannot be turned off. Force it for regular mypy too.

Signed-off-by: Edward Z. Yang <ezyang@meta.com>

Pull Request resolved: pytorch#118467
Approved by: https://github.com/Skylion007
ghstack dependencies: pytorch#118414, pytorch#118418, pytorch#118432
jeffdaily pushed a commit to ROCm/pytorch that referenced this pull request Feb 8, 2024
Signed-off-by: Edward Z. Yang <ezyang@meta.com>
Pull Request resolved: pytorch#118468
Approved by: https://github.com/Skylion007
ghstack dependencies: pytorch#118414, pytorch#118418, pytorch#118432, pytorch#118467
jeffdaily pushed a commit to ROCm/pytorch that referenced this pull request Feb 8, 2024
dmypy silently ignores follow_imports = skip, so to get parity between
dmypy and mypy we have to suck it up and type: ignore all of the sympy
typing problems.

The suppressions were added automatically with the following script generated by GPT-4:

```
import re

# Read the error file
with open("error_file.txt", "r") as f:
    errors = f.readlines()

# Parse the lines with errors and error types
error_lines = {}
for error in errors:
    match = re.match(r"(.*):(\d+):\d+: error:.*\[(.*)\]", error)
    if match:
        file_path, line_number, error_type = match.groups()
        if file_path not in error_lines:
            error_lines[file_path] = {}
        error_lines[file_path][int(line_number)] = error_type

# Insert ignore comments in the source files
for file_path, lines in error_lines.items():
    with open(file_path, "r") as f:
        code = f.readlines()
    for line_number, error_type in sorted(lines.items(), key=lambda x: x[0], reverse=True):
        code[line_number - 1] = code[line_number - 1].rstrip() + f"  # type: ignore[{error_type}]\n"
    with open(file_path, "w") as f:
        f.writelines(code)
```

Signed-off-by: Edward Z. Yang <ezyang@meta.com>

Pull Request resolved: pytorch#118469
Approved by: https://github.com/Skylion007
ghstack dependencies: pytorch#118414, pytorch#118418, pytorch#118432, pytorch#118467, pytorch#118468
jeffdaily pushed a commit to ROCm/pytorch that referenced this pull request Feb 8, 2024
Signed-off-by: Edward Z. Yang <ezyang@meta.com>
Pull Request resolved: pytorch#118475
Approved by: https://github.com/suo
ghstack dependencies: pytorch#118414, pytorch#118418, pytorch#118432, pytorch#118467, pytorch#118468, pytorch#118469
jeffdaily pushed a commit to ROCm/pytorch that referenced this pull request Feb 8, 2024
As we force a specific version of mypy, it's OK to use the agglomerated flag.

Signed-off-by: Edward Z. Yang <ezyang@meta.com>
Pull Request resolved: pytorch#118479
Approved by: https://github.com/Skylion007, https://github.com/albanD
ghstack dependencies: pytorch#118414, pytorch#118418, pytorch#118432, pytorch#118467, pytorch#118468, pytorch#118469, pytorch#118475
jeffdaily pushed a commit to ROCm/pytorch that referenced this pull request Feb 8, 2024
jeffdaily pushed a commit to ROCm/pytorch that referenced this pull request Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/inductor ciflow/trunk Trigger trunk jobs on your pull request Merged module: dynamo module: inductor release notes: onnx torch.onnx related changes that should show up in the release notes topic: not user facing topic category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants