Can `torch.compile` work for model with dynamic graphs?

So I guess the torch.compile won’t work for model with dynamic graphs?

Say for the first 100 epochs, I am training an RNN with 3-steps loss for the future prediction. Then in the next 100 epochs, I am training the same RNN but I changed the unrolling steps to 100-steps. Just work like a fine tunning.

Would that work?

When it runs for the first time, it should produces guards that tell us under what conditions the compiled graph is valid. If it is run again with different number of steps, the guard check would fail, and torch.compile should recompile the graph.

2 Likes