-
Notifications
You must be signed in to change notification settings - Fork 25.5k
Description
🐛 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