-
Notifications
You must be signed in to change notification settings - Fork 130
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
Support torch.compile
for RF
#1491
Comments
I just want to mention here, especially after the discussion with @NeoLegends this morning, that also I "naively" tried to wrap some of my (pure PyTorch) ASR trainings and recognitions with torch.compile, none of the experiments were in any sense successful so far (either it caused re-compiling for every batch, or just not a faster execution, both CPU and GPU). This was with PyTorch 2.2 though, not sure how much has improved since then. |
Can you reference some of the issues with dynamic shapes for With JAX, I know that people use this approach successfully. But then, I think dynamic shapes support is planned to be added to JAX (jax-ml/jax#14634). Another approach I have seen is that people implement actually only a chunk-based or frame-based model (all static shapes) and then everything dynamic happens in a Python loop around that. |
After reviewing some of the public issues, it seems that this was more of a problem with either more special cases or earlier versions of PyTorch. Nevertheless there is the e.g. bullet point #4 here: Which matches my observation, you get a compile crash, constant re-compilation (e.g. for every batch size), or slowdown. https://lightning.ai/docs/pytorch/latest/advanced/compile.html Older, not so related issues anymore are e.g.: So I would say, we need to test this again with PyTorch 2.4, and spend much more time than a few hours. Probably we will work on this also in the context of the work of @sleepyeldrazi on efficient export and runtimes. |
I'm not really sure whether that is possible because we have our own
Tensor
class which wraps around thetorch.Tensor
, and similarly all the PyTorch functions are wrapped inside RF.However, I found out that there is TensorDict, which also wraps around PyTorch tensors, and it is explicitly stated that this is compatible with
torch.compile
, so maybe it is possible. In that case, it behaves like a dict, but does not inherit from dict, it just inherits fromcollections.abc.MutableMapping
, see here.So, let us discuss here possibilities and options to support
torch.compile
directly with the RF PyTorch backend.Related:
torch.compile
for PyTorch in general (not specific about RF): PyTorchtorch.compile
, scripting, tracing for faster computation (specifically training) #1436The text was updated successfully, but these errors were encountered: