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

Add test for ShapeEnv recording fallback. #109944

Closed
wants to merge 3 commits into from

Conversation

ysiraichi
Copy link
Collaborator

@ysiraichi ysiraichi commented Sep 23, 2023

Stack from ghstack (oldest at bottom):

This PR adds a test for the previous PR in this stack: #109904. In summary, it calls
functions decorated with @record_shapeenv_event, that don't have an explicit ShapeEnv
parameter, with arguments that don't hold a ShapeEnv instance.

cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @Xia-Weiwen @wenzhe-nrv @jiayisunx @chenyang78 @aakhundov @kadeng

This PR adds a test for the previous PR in this stack: #109904. In summary, it calls
functions decorated with `@record_shapeenv_event`, that don't have an explicit `ShapeEnv`
parameter, with arguments that don't hold a `ShapeEnv` instance.

[ghstack-poisoned]
@pytorch-bot pytorch-bot bot added the release notes: fx release notes category label Sep 23, 2023
@pytorch-bot
Copy link

pytorch-bot bot commented Sep 23, 2023

🔗 Helpful Links

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

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

✅ No Failures

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

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

This PR adds a test for the previous PR in this stack: #109904. In summary, it calls
functions decorated with `record_shapeenv_event`, that don't have an explicit `ShapeEnv`
parameter, with arguments that don't hold a `ShapeEnv` instance.

cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx chenyang78 aakhundov kadeng

[ghstack-poisoned]
@ysiraichi ysiraichi requested a review from ezyang September 25, 2023 16:44
@ezyang
Copy link
Contributor

ezyang commented Sep 25, 2023

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Sep 25, 2023
@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 pushed a commit that referenced this pull request Sep 26, 2023
This PR adds a test for checking `ShapeEnv` state when it's built with
`should_record_events=False`.

Pull Request resolved: #109945
Approved by: https://github.com/ezyang
ghstack dependencies: #109904, #109944
@atalman
Copy link
Contributor

atalman commented Sep 26, 2023

This is failing internally

=================================== FAILURES ===================================
_____________ MiscTests.test_shape_env_recorded_function_fallback ______________

self = <caffe2.test.dynamo.test_misc.MiscTests testMethod=test_shape_env_recorded_function_fallback>

    def test_shape_env_recorded_function_fallback(self):
        # Make sure the record/replay mechanism for ShapeEnv will fallback
        # if no ShapeEnv instance is found.
>       constrain_range(5, min=2, max=10)

../buck-out/v2/gen/fbcode/363cd7e240f5d021/caffe2/test/dynamo/__test_dynamo__/test_dynamo#link-tree/caffe2/test/dynamo/test_misc.py:7506: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../buck-out/v2/gen/fbcode/363cd7e240f5d021/caffe2/test/dynamo/__test_dynamo__/test_dynamo#link-tree/torch/fx/experimental/recording.py:232: in wrapper
    self = _extract_shape_env_and_assert_equal(args, kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

args = (5,), kwargs = {'max': 10, 'min': 2}


=================================== FAILURES ===================================
_ DynamicShapesMiscTests.test_shape_env_recorded_function_fallback_dynamic_shapes _

self = <torch._dynamo.testing.DynamicShapesMiscTests testMethod=test_shape_env_recorded_function_fallback_dynamic_shapes>

    def test_shape_env_recorded_function_fallback(self):
        # Make sure the record/replay mechanism for ShapeEnv will fallback
        # if no ShapeEnv instance is found.
>       constrain_range(5, min=2, max=10)

../buck-out/v2/gen/fbcode/363cd7e240f5d021/caffe2/test/dynamo/__test_dynamo__/test_dynamo#link-tree/caffe2/test/dynamo/test_misc.py:7506: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../buck-out/v2/gen/fbcode/363cd7e240f5d021/caffe2/test/dynamo/__test_dynamo__/test_dynamo#link-tree/torch/fx/experimental/recording.py:232: in wrapper
    self = _extract_shape_env_and_assert_equal(args, kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

args = (5,), kwargs = {'max': 10, 'min': 2}

@atalman
Copy link
Contributor

atalman commented Sep 26, 2023

@pytorchbot revert -m "New test failing internally" -c ghfirst

@pytorchmergebot
Copy link
Collaborator

@pytorchbot successfully started a revert job. Check the current status here.
Questions? Feedback? Please reach out to the PyTorch DevX Team

@pytorchmergebot
Copy link
Collaborator

@ysiraichi your PR has been successfully reverted.

pytorchmergebot added a commit that referenced this pull request Sep 26, 2023
@ysiraichi
Copy link
Collaborator Author

@ezyang @atalman Could you tell me what is the error raised there?

@ezyang ezyang reopened this Sep 26, 2023
@ezyang
Copy link
Contributor

ezyang commented Sep 26, 2023

atalman didn't post the full log. Here is the full log

============================= test session starts ==============================
platform linux -- Python 3.8.6, pytest-7.2.2, pluggy-0.13.1
rootdir: /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/fbcode
plugins: hypothesis-6.70.1
collected 337 items

. F

=================================== FAILURES ===================================
_____________ MiscTests.test_shape_env_recorded_function_fallback ______________

self = <caffe2.test.dynamo.test_misc.MiscTests testMethod=test_shape_env_recorded_function_fallback>

    def test_shape_env_recorded_function_fallback(self):
        # Make sure the record/replay mechanism for ShapeEnv will fallback
        # if no ShapeEnv instance is found.
>       constrain_range(5, min=2, max=10)

../buck-out/v2/gen/fbcode/363cd7e240f5d021/caffe2/test/dynamo/__test_dynamo__/test_dynamo#link-tree/caffe2/test/dynamo/test_misc.py:7506: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../buck-out/v2/gen/fbcode/363cd7e240f5d021/caffe2/test/dynamo/__test_dynamo__/test_dynamo#link-tree/torch/fx/experimental/recording.py:232: in wrapper
    self = _extract_shape_env_and_assert_equal(args, kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

args = (5,), kwargs = {'max': 10, 'min': 2}

    def _extract_shape_env_and_assert_equal(args, kwargs):
        from torch.fx.experimental.symbolic_shapes import ShapeEnv, SymTypes
    
        def assert_equal(old: Optional[ShapeEnv], new: ShapeEnv) -> ShapeEnv:
            if old is not None:
                assert old is new, "call with different ShapeEnv"
            return new
    
        shape_env = None
        for val in itertools.chain(args, kwargs.values()):
            if isinstance(val, ShapeEnv):
                shape_env = assert_equal(shape_env, val)
            if isinstance(val, SymTypes):
                shape_env = assert_equal(shape_env, val.node.shape_env)
    
>       assert shape_env is not None, "ShapeEnv not found"
E       AssertionError: ShapeEnv not found

../buck-out/v2/gen/fbcode/363cd7e240f5d021/caffe2/test/dynamo/__test_dynamo__/test_dynamo#link-tree/torch/fx/experimental/recording.py:188: AssertionError
=========================== short test summary info ============================
FAILED ::MiscTests::test_shape_env_recorded_function_fallback - AssertionErro...
============================== 1 failed in 8.48s ===============================


self = <caffe2.test.dynamo.test_misc.MiscTests testMethod=test_shape_env_recorded_function_fallback>

    def test_shape_env_recorded_function_fallback(self):
        # Make sure the record/replay mechanism for ShapeEnv will fallback
        # if no ShapeEnv instance is found.
>       constrain_range(5, min=2, max=10)

../buck-out/v2/gen/fbcode/363cd7e240f5d021/caffe2/test/dynamo/__test_dynamo__/test_dynamo#link-tree/caffe2/test/dynamo/test_misc.py:7506: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../buck-out/v2/gen/fbcode/363cd7e240f5d021/caffe2/test/dynamo/__test_dynamo__/test_dynamo#link-tree/torch/fx/experimental/recording.py:232: in wrapper
    self = _extract_shape_env_and_assert_equal(args, kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

args = (5,), kwargs = {'max': 10, 'min': 2}

    def _extract_shape_env_and_assert_equal(args, kwargs):
        from torch.fx.experimental.symbolic_shapes import ShapeEnv, SymTypes
    
        def assert_equal(old: Optional[ShapeEnv], new: ShapeEnv) -> ShapeEnv:
            if old is not None:
                assert old is new, "call with different ShapeEnv"
            return new
    
        shape_env = None
        for val in itertools.chain(args, kwargs.values()):
            if isinstance(val, ShapeEnv):
                shape_env = assert_equal(shape_env, val)
            if isinstance(val, SymTypes):
                shape_env = assert_equal(shape_env, val.node.shape_env)
    
>       assert shape_env is not None, "ShapeEnv not found"
E       AssertionError: ShapeEnv not found

../buck-out/v2/gen/fbcode/363cd7e240f5d021/caffe2/test/dynamo/__test_dynamo__/test_dynamo#link-tree/torch/fx/experimental/recording.py:188: AssertionError

@ysiraichi
Copy link
Collaborator Author

@ezyang thank you for the log. It seems that it was executed without the previous PR in this stack (#109904). Let me rebase it.

This PR adds a test for the previous PR in this stack: #109904. In summary, it calls
functions decorated with `record_shapeenv_event`, that don't have an explicit `ShapeEnv`
parameter, with arguments that don't hold a `ShapeEnv` instance.

cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx chenyang78 aakhundov kadeng

[ghstack-poisoned]
ysiraichi added a commit that referenced this pull request Sep 26, 2023
This PR adds a test for the previous PR in this stack: #109904. In summary, it calls
functions decorated with `record_shapeenv_event`, that don't have an explicit `ShapeEnv`
parameter, with arguments that don't hold a `ShapeEnv` instance.

ghstack-source-id: eaa3bafd7d13e3fac2e9cab4e2b2ea93b7a32a57
Pull Request resolved: #109944
@ezyang
Copy link
Contributor

ezyang commented Sep 27, 2023

@pytorchbot merge

@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

@kit1980 kit1980 removed the Reverted label Sep 29, 2023
@facebook-github-bot facebook-github-bot deleted the gh/ysiraichi/92/head branch September 30, 2023 14:23
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 open source release notes: fx release notes category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants