Created
July 22, 2026 02:51
-
-
Save Dirga36/358073162f1fa83aa922109a3d4931e9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import torch | |
| model = MyModel().cuda() | |
| optimizer = torch.optim.AdamW(model.parameters(), lr=3e-4) | |
| # Compile once, reuse across the training loop | |
| compiled_model = torch.compile(model) | |
| for batch in dataloader: | |
| inputs, targets = batch | |
| optimizer.zero_grad() | |
| outputs = compiled_model(inputs.cuda()) | |
| loss = criterion(outputs, targets.cuda()) | |
| loss.backward() | |
| optimizer.step() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment