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

PyTorch torch.compile, scripting, tracing for faster computation (specifically training) #1436

Open
albertz opened this issue Oct 17, 2023 · 2 comments

Comments

@albertz
Copy link
Member

albertz commented Oct 17, 2023

For the first few steps, it could run without tracing/scripting, but then it could enable it and from then on use the Torch graph directly (very similar to TF computation graph). So maybe some option like torch_jit_enable_after_step: int.

Tracing should always work for static sizes and no (or always same) control flow.

Questions:

  • How to handle dynamic dims? With tracing for ONNX, this is somehow possible, but how to use this directly?
  • How to handle dynamic control flow? Maybe we can use scripting just for the loop, and tracing otherwise? With RF, we already try to make control flow explicit, so there we should be able to do all automatically?

Instead of using the old-style scripting/tracing, probably better would be to use torch.compile now. I'm not sure if the questions above are relevant there as well.

This might be even more helpful for RF, due to the overhead of RF (although the overhead has greatly been reduced now, see #1402), but it would just be as helpful for pure PT as well. This feature would not be specific to RF in any way, except that RF maybe can provide special handling of control flow for this. For RF, some other aspects might become relevant, so #1491 is specifically about this.

@albertz albertz mentioned this issue Oct 17, 2023
45 tasks
@albertz
Copy link
Member Author

albertz commented Oct 17, 2023

Just now, I found about torch.export, which references functorch.experimental.control_flow for control flow:

https://pytorch.org/tutorials/intermediate/torch_export_tutorial.html
https://pytorch.org/executorch/stable/tutorials/export-to-executorch-tutorial.html

@albertz albertz changed the title PyTorch scripting and tracing for faster computation (specifically training) PyTorch torch.compile, scripting, tracing for faster computation (specifically training) Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant