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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

torch.export 'inline in skipfiles: Signature.bind | bind /usr/lib/python3.10/inspect.py, skipped according trace_rules.lookup SKIP_DIRS' #126242

Open
stellaraccident opened this issue May 14, 2024 · 1 comment

Comments

@stellaraccident
Copy link

stellaraccident commented May 14, 2024

馃悰 Describe the bug

I recently added some code to a library which did some dynamic signature munging, and it triggers this error on torch.export:

torch._dynamo.exc.Unsupported: 'inline in skipfiles: Signature.bind | bind /usr/lib/python3.10/inspect.py, skipped according trace_rules.lookup SKIP_DIRS'

This is originating from code like this (which is just doing some lazy selection of a target function for something):

    def __init__(self, sigf: Callable):
        self._sig = inspect.signature(sigf)

    def __call__(self, *args, **kwargs):
        tensor_names = self._tensor_names
        bound_args = self._sig.bind(*args, **kwargs)
        bound_args.apply_defaults()
        value_spec = tuple(bound_args.arguments[k] for k in tensor_names)

Note that the constructor happens at module load time (outside of dynamo) and the call happens during dynamo tracing.

I don't recall seeing this listed in the DB or elsewhere as explicitly unsupported. Is there a plan for it or some workaround (I can also rewrite the code to something less dynamic but thought I'd ask first)?

Error logs

    return super().call_function(tx, args, kwargs)
  File "/home/rsuderman/.local/python/lib/python3.10/site-packages/torch/_dynamo/variables/functions.py", line 293, in call_function
    return super().call_function(tx, args, kwargs)
  File "/home/rsuderman/.local/python/lib/python3.10/site-packages/torch/_dynamo/variables/functions.py", line 90, in call_function
    return tx.inline_user_function_return(self, [*self.self_args(), *args], kwargs)
  File "/home/rsuderman/.local/python/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 741, in inline_user_function_return
    return InliningInstructionTranslator.inline_call(self, fn, args, kwargs)
  File "/home/rsuderman/.local/python/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 2427, in inline_call
    return cls.inline_call_(parent, func, args, kwargs)
  File "/home/rsuderman/.local/python/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 2471, in inline_call_
    result = InliningInstructionTranslator.check_inlineable(func)
  File "/home/rsuderman/.local/python/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 2448, in check_inlineable
    unimplemented(
  File "/home/rsuderman/.local/python/lib/python3.10/site-packages/torch/_dynamo/exc.py", line 212, in unimplemented
    raise Unsupported(msg)
torch._dynamo.exc.Unsupported: 'inline in skipfiles: Signature.bind | bind /usr/lib/python3.10/inspect.py, skipped according trace_rules.lookup SKIP_DIRS'

Minified repro

No response

Versions

torch==2.4.0.dev20240428+cpu
torchaudio==2.2.1
torchvision==0.19.0.dev20240416+cpu

cc @ezyang @msaroufim @bdhirsh @anijain2305 @chauhang @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @chenyang78 @kadeng @avikchaudhuri @gmagogsfm @zhxchen17 @tugsbayasgalan @angelayi @suo @ydwu4

@ezyang
Copy link
Contributor

ezyang commented May 15, 2024

So, you could patch Dynamo to yolo trace into it, but it probably won't work anyway. No reason for this not to work, but yes, making it less dynamic would help.

stellaraccident added a commit to nod-ai/sharktank that referenced this issue May 15, 2024
This reverts commit 834e558.

Per advice on pytorch/pytorch#126242, reworks the dispatch mechanism to be static. Also adds a test to ensure export is functional when these ops are used.
rsuderman pushed a commit to nod-ai/sharktank that referenced this issue May 15, 2024
This reverts commit 834e558.

Per advice on pytorch/pytorch#126242, reworks
the dispatch mechanism to be static. Also adds a test to ensure export
is functional when these ops are used.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants