Skip to content

Nondeterministic type checking on pytorch/vision #19121

@hauntsaninja

Description

@hauntsaninja
Collaborator

Repro with e.g. mypy_primer --new 'v1.15' --old 'v1.15' -k vision --debug:

diff --git a/mypy_primer/projects.py b/mypy_primer/projects.py
index 09c050c..0309cff 100644
--- a/mypy_primer/projects.py
+++ b/mypy_primer/projects.py
@@ -547,7 +547,7 @@ def get_projects() -> list[Project]:
         ),
         Project(
             location="https://github.com/pytorch/vision",
-            mypy_cmd=None,  # "{mypy}",
+            mypy_cmd="{mypy}",
             pyright_cmd="{pyright}",
             deps=["numpy", "pillow"],

Linking hauntsaninja/mypy_primer#161

Activity

sterliakov

sterliakov commented on May 21, 2025

@sterliakov
Collaborator

One more example with random primer diffs on xarray, it only started appearing recently: #19102 (comment)

hauntsaninja

hauntsaninja commented on May 23, 2025

@hauntsaninja
CollaboratorAuthor

xarray might be a newer regression, since I can't repro with a few runs of mypy_primer --new 'v1.15' --old 'v1.15' -k pydata/xarray --debug --output concise. I'll try to bisect it later

sterliakov

sterliakov commented on May 23, 2025

@sterliakov
Collaborator
hauntsaninja

hauntsaninja commented on May 24, 2025

@hauntsaninja
CollaboratorAuthor

Simple minimised version of torchvision:

printf '
def draw(
    colors1: list[str | tuple[int, int, int]] | str | tuple[int, int, int] | None,
    colors2: list[str | tuple[int, int, int]] | str | tuple[int, int, int] | None,
) -> None:
    for c1, c2 in zip(colors1, colors2):
        reveal_type(c1)
        reveal_type(c2)
' > test.py


first_output="$(mypy test.py)"
echo "$first_output"
echo "----------"
for run in {2..10}; do
  current_output="$(mypy test.py)"
  echo "$current_output"
  echo "----------"
  if [[ "$current_output" != "$first_output" ]]; then
    echo output mismatch
    exit 1
  fi
done

Also linking #16979 and #18125

hauntsaninja

hauntsaninja commented on May 26, 2025

@hauntsaninja
CollaboratorAuthor

The vision one will be fixed by #19147

I think something similar will fix xarray. Both of these look like nonassociative issue (not a noncommutative issue!). I will do it in a follow up PR

added a commit that references this issue on May 28, 2025
f328ad6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @hauntsaninja@sterliakov

      Issue actions

        Nondeterministic type checking on pytorch/vision · Issue #19121 · python/mypy