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

bool inherited from number #125577

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

Ma-Jian1
Copy link
Contributor

@Ma-Jian1 Ma-Jian1 commented May 6, 2024

Copy link

pytorch-bot bot commented May 6, 2024

🔗 Helpful Links

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

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 5512c87 with merge base ead97ee (image):

FLAKY - The following job failed but was likely due to flakiness present on trunk:

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

@jbschlosser jbschlosser added the oncall: jit Add this issue/PR to JIT oncall triage queue label May 7, 2024
@colesbury colesbury requested a review from EikanWang May 9, 2024 03:35
@colesbury
Copy link
Member

@EikanWang - would you please review this PR?

@colesbury colesbury added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label May 9, 2024
@EikanWang
Copy link
Collaborator

LGTM.

@EikanWang EikanWang requested review from jgong5 and ezyang May 9, 2024 08:18
Copy link
Collaborator

@EikanWang EikanWang left a comment

Choose a reason for hiding this comment

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

Please fix UT failures.

@pytorch-bot pytorch-bot bot added the release notes: jit release notes category label May 10, 2024
@pytorch-bot pytorch-bot bot added the NNC label May 13, 2024
@pytorch-bot pytorch-bot bot added the module: mkldnn Related to Intel IDEEP or oneDNN (a.k.a. mkldnn) integration label May 13, 2024
@EikanWang EikanWang removed the module: mkldnn Related to Intel IDEEP or oneDNN (a.k.a. mkldnn) integration label May 14, 2024
@Ma-Jian1
Copy link
Contributor Author

@ezyang Could you help to take a review?

@ezyang
Copy link
Contributor

ezyang commented May 15, 2024

You are still failing a bunch of tests

@Ma-Jian1
Copy link
Contributor Author

hi all,
torch/optim/asgd.py is not part of this patch. what should I do next?
@EikanWang @ezyang

@ezyang
Copy link
Contributor

ezyang commented May 21, 2024

@pytorchbot merge -r

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

@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here

@pytorchmergebot
Copy link
Collaborator

Successfully rebased boolean-in-cpp-api onto refs/remotes/origin/viable/strict, please pull locally before adding more changes (for example, via git checkout boolean-in-cpp-api && git pull --rebase)

@pytorchmergebot
Copy link
Collaborator

Merge failed

Reason: Approvers from one of the following sets are needed:

  • superuser (pytorch/metamates)
  • Core Reviewers (mruberry, lezcano, Skylion007, ngimel, peterbell10)
  • Core Maintainers (soumith, gchanan, ezyang, dzhulgakov, malfet)
Details for Dev Infra team Raised by workflow job

Failing merge rule: Core Maintainers

@ezyang
Copy link
Contributor

ezyang commented May 21, 2024

I am not convinced I want to deal with the fallout from this in TorchScript. @davidberard98 for a second opinion

@facebook-github-bot
Copy link
Contributor

@davidberard98 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@davidberard98
Copy link
Contributor

davidberard98 commented May 22, 2024

I'm seeing internal failures - not sure if I'll be able to get to this for a few days, but I'll need to take a closer look to understand what's failing. I'll report back once I have a better understanding.

Actually, the failures are from torchvision - specifically from test_convert_image_dtype. I'm guessing this will repro in OSS but I haven't tried.

@Ma-Jian1
Copy link
Contributor Author

hi @davidberard98 ,does it still failed on your test?

@davidberard98
Copy link
Contributor

@Ma-Jian1 yes - do you think you can check using torchvision to better understand the failures?

@Ma-Jian1
Copy link
Contributor Author

hi @davidberard98 ,I clone torchvision into local pytorch fold,and run python setup.py develop in torchvision subfolder, and then python -m pytest -sv test/test_transforms_tensor.py -k test_convert_image_dtype, I can reproduce 3 failed cases.
but after I reverted my patch, the failure still existed.
seems not related to my patch?

investigated further:
I found the max_int literal 2147483647.0 will be captured as 2147483648. in torch.script, so weird.

test/test_transforms_tensor.py::test_convert_image_dtype[out_dtype0-in_dtype0-cpu] graph(%image.1 : Tensor,
      %dtype.1 : int):
  %382 : int = prim::Constant[value=4294967294]()
  %377 : float = prim::Constant[value=9.2233720368547758e+18]()
  %376 : float = prim::Constant[value=2147483648.]()
  %333 : Function = prim::Constant[name="_max_value"]()
  %332 : str = prim::Constant[value="builtins.RuntimeError"]() # /home/jianma/repo/pytorch/vision/torchvision/transforms/_functional_tensor.py:79:18
  %329 : str = prim::Constant[value="The cast from {} to {} cannot be performed safely."]() # /home/jianma/repo/pytorch/vision/torchvision/transforms/_functional_tensor.py:78:18
  %321 : int = prim::Constant[value=7]() # /home/jianma/repo/pytorch/vision/torchvision/transforms/_functional_tensor.py:76:27
  %319 : bool = prim::Constant[value=1]() # /home/jianma/repo/pytorch/vision/torchvision/transforms/_functional_tensor.py:75:12
  %312 : int = prim::Constant[value=4]() # /home/jianma/repo/pytorch/vision/torchvision/transforms/_functional_tensor.py:75:68
  %311 : int = prim::Constant[value=3]() # /home/jianma/repo/pytorch/vision/torchvision/transforms/_functional_tensor.py:75:55
  %307 : int = prim::Constant[value=6]() # /home/jianma/repo/pytorch/vision/torchvision/transforms/_functional_tensor.py:75:27
  %206 : bool = prim::Constant[value=0]()
  %205 : NoneType = prim::Constant()
  %12 : int = prim::Constant[value=0]() # /home/jianma/repo/pytorch/vision/torchvision/transforms/_functional_tensor.py:71:24
  %64 : float = prim::Constant[value=0.001]() # /home/jianma/repo/pytorch/vision/torchvision/transforms/_functional_tensor.py:86:14
  %72 : float = prim::Constant[value=1.]() # /home/jianma/repo/pytorch/vision/torchvision/transforms/_functional_tensor.py:88:37
  %3 : int = prim::dtype(%image.1)
  %5 : bool = aten::eq(%3, %dtype.1) # /home/jianma/repo/pytorch/vision/torchvision/transforms/_functional_tensor.py:65:7
  %305 : Tensor = prim::If(%5) # /home/jianma/repo/pytorch/vision/torchvision/transforms/_functional_tensor.py:65:4
    block0():
      -> (%image.1)
    block1():
      %198 : bool = aten::is_floating_point(%image.1) # /home/jianma/repo/pytorch/vision/torchvision/transforms/_functional_tensor.py:68:7
      %201 : Tensor = prim::If(%198) # /home/jianma/repo/pytorch/vision/torchvision/transforms/_functional_tensor.py:68:4
        block0():
          %207 : Tensor = aten::tensor(%12, %dtype.1, %205, %206) # /home/jianma/repo/pytorch/vision/torchvision/transforms/_functional_tensor.py:71:11
          %208 : bool = aten::is_floating_point(%207) # /home/jianma/repo/pytorch/vision/torchvision/transforms/_functional_tensor.py:71:11
          %345 : Tensor = prim::If(%208) # /home/jianma/repo/pytorch/vision/torchvision/transforms/_functional_tensor.py:71:8
            block0():
              %215 : Tensor = aten::to(%image.1, %dtype.1, %206, %206, %205) # /home/jianma/repo/pytorch/vision/torchvision/transforms/_functional_tensor.py:72:19
              -> (%215)
            block1():
              %306 : int = prim::dtype(%image.1)
              %308 : bool = aten::eq(%306, %307) # /home/jianma/repo/pytorch/vision/torchvision/transforms/_functional_tensor.py:75:12
              %310 : bool = prim::If(%308) # /home/jianma/repo/pytorch/vision/torchvision/transforms/_functional_tensor.py:75:12
                block0():
                  %314 : int[] = prim::ListConstruct(%311, %312)
                  %315 : bool = aten::__contains__(%314, %dtype.1) # /home/jianma/repo/pytorch/vision/torchvision/transforms/_functional_tensor.py:75:45
                  -> (%315)
                block1():
                  -> (%206)
              %318 : bool = prim::If(%310) # /home/jianma/repo/pytorch/vision/torchvision/transforms/_functional_tensor.py:75:12
                block0():
                  -> (%319)
                block1():
                  %320 : int = prim::dtype(%image.1)
                  %322 : bool = aten::eq(%320, %321) # /home/jianma/repo/pytorch/vision/torchvision/transforms/_functional_tensor.py:76:12
                  %324 : bool = prim::If(%322) # /home/jianma/repo/pytorch/vision/torchvision/transforms/_functional_tensor.py:76:12
                    block0():
                      %326 : bool = aten::eq(%dtype.1, %312) # /home/jianma/repo/pytorch/vision/torchvision/transforms/_functional_tensor.py:76:45
                      -> (%326)
                    block1():
                      -> (%206)
                  -> (%324)
               = prim::If(%318) # /home/jianma/repo/pytorch/vision/torchvision/transforms/_functional_tensor.py:75:8
                block0():
                  %330 : int = prim::dtype(%image.1)
                  %msg.7 : str = aten::format(%329, %330, %dtype.1) # /home/jianma/repo/pytorch/vision/torchvision/transforms/_functional_tensor.py:78:18
                   = prim::RaiseException(%msg.7, %332) # /home/jianma/repo/pytorch/vision/torchvision/transforms/_functional_tensor.py:79:12
                  -> ()
                block1():
                  -> ()
              %334 : int = prim::CallFunction(%333, %dtype.1) # /home/jianma/repo/pytorch/vision/torchvision/transforms/_functional_tensor.py:87:24
              %max_val.7 : float = aten::Float(%334) # /home/jianma/repo/pytorch/vision/torchvision/transforms/_functional_tensor.py:87:18
              %337 : float = aten::add(%max_val.7, %72) # /home/jianma/repo/pytorch/vision/torchvision/transforms/_functional_tensor.py:88:27
              %338 : float = aten::sub(%337, %64) # /home/jianma/repo/pytorch/vision/torchvision/transforms/_functional_tensor.py:88:27
              %result.7 : Tensor = aten::mul(%image.1, %338) # /home/jianma/repo/pytorch/vision/torchvision/transforms/_functional_tensor.py:88:17
              %343 : Tensor = aten::to(%result.7, %dtype.1, %206, %206, %205) # /home/jianma/repo/pytorch/vision/torchvision/transforms/_functional_tensor.py:89:15
              -> (%343)
          -> (%345)
        block1():
           = prim::Print(%376) # /home/jianma/repo/pytorch/vision/torchvision/transforms/_functional_tensor.py:93:8
          %263 : Tensor = aten::tensor(%12, %dtype.1, %205, %206) # /home/jianma/repo/pytorch/vision/torchvision/transforms/_functional_tensor.py:97:11
          %264 : bool = aten::is_floating_point(%263) # /home/jianma/repo/pytorch/vision/torchvision/transforms/_functional_tensor.py:97:11
          %375 : Tensor = prim::If(%264) # /home/jianma/repo/pytorch/vision/torchvision/transforms/_functional_tensor.py:97:8
            block0():
              %image.65 : Tensor = aten::to(%image.1, %dtype.1, %206, %206, %205) # /home/jianma/repo/pytorch/vision/torchvision/transforms/_functional_tensor.py:98:20
              %273 : Tensor = aten::div(%image.65, %376) # /home/jianma/repo/pytorch/vision/torchvision/transforms/_functional_tensor.py:99:19
              -> (%273)
            block1():
               = prim::Print(%377) # /home/jianma/repo/pytorch/vision/torchvision/transforms/_functional_tensor.py:103:8
               = prim::Print(%377, %376, %382) # /home/jianma/repo/pytorch/vision/torchvision/transforms/_functional_tensor.py:116:12
              %image.91 : Tensor = aten::to(%image.1, %dtype.1, %206, %206, %205) # /home/jianma/repo/pytorch/vision/torchvision/transforms/_functional_tensor.py:117:20
              %373 : Tensor = aten::mul(%image.91, %382) # /home/jianma/repo/pytorch/vision/torchvision/transforms/_functional_tensor.py:118:19
              -> (%373)
          -> (%375)
      -> (%201)
  return (%305)

@Ma-Jian1
Copy link
Contributor Author

I have to run "pip uninstall torch" several times to clean the virtual env.
now verified that the test passed without this patch.

@Ma-Jian1
Copy link
Contributor Author

hi @davidberard98, the failed case in torchvision is related to cast int to float, which has an accuracy issue.
fixed it and add an extra unit test.

@Ma-Jian1
Copy link
Contributor Author

Ma-Jian1 commented Jul 2, 2024

hi @davidberard98 ,
could you help to take a review?
I have no mac device, and it shouldn't affect this unit test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/trunk Trigger trunk jobs on your pull request NNC oncall: jit Add this issue/PR to JIT oncall triage queue open source release notes: jit release notes category triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bool as scalar in jit ir API not working as expected.
10 participants