This repository was archived by the owner on Aug 1, 2025. It is now read-only.

Description
There are a lot of .item()
calls inside of optimizer.step()
, e.g:
https://github.com/pytorch/pytorch/blob/master/torch/optim/asgd.py#L182-L212
These .item()
calls inside of the for loop cause graph break when enabling dynamo and finally hitting cache limit. I took a closer look at these usages and found actually we can remove these call because the results were feed into other downstream tensor operations.
I did a simple verification on ASGD
and found removing .item()
works well and no graph break on Dynamo end.
I'd like to check if there are other constraints to prevent us from doing this. If not, I can go ahead to fix this.
cc @jansel