Skip to content

❓ [Question] How to save the compiled while using torch.compile #3525

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

Open
klin2024 opened this issue May 20, 2025 · 1 comment
Open

❓ [Question] How to save the compiled while using torch.compile #3525

klin2024 opened this issue May 20, 2025 · 1 comment
Labels
question Further information is requested

Comments

@klin2024
Copy link

For the example below, how do I save the compiled model?

backend = "torch_tensorrt"
tp_model = torch.compile(
tp_model,
backend=backend,
options={
"truncate_long_and_double": True,
"enabled_precisions": {torch.float32, torch.float16},
"use_python_runtime": True,
"min_block_size": 1,
},
dynamic=False,
)

@klin2024 klin2024 added the question Further information is requested label May 20, 2025
@narendasan
Copy link
Collaborator

torch.compile is not serializable. There are two options. You can enable the engine cache which create a persistent cache you can use between sessions or you could use the MutableTorchTensorRTModule which has a similar UX but is serializable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants