Repository navigation
Optimize Dynamo Training Execute - #4523
Conversation
|
<style type="text/css"></style>
|
| # mark_step needs to be blocking since we want to access args's XLADatas | ||
| # and they can't be placeholder. | ||
| if any(torch_xla._XLAC._check_tensor_need_materialization(args)): | ||
| xm.mark_step(wait=True) |
There was a problem hiding this comment.
In general, does a synchronous mark_step can be slower than _xla_sync_multi? Since the latter does not wait for the execution.
There was a problem hiding this comment.
_xla_sync_multi is also synchronous, but it might be executing a smaller graph.
There was a problem hiding this comment.
Ah, I didn't realize that the default behavior of 'mark_step (not wait for compute)' and '_xla_sync_multi (wait for compute)' are different. Thanks for clarification!
|
Oh interesting, if I remove the I think what happened is that even I think we should not unconditionally perform the |
This also explains why my previous pr to make execution async for dynam doesn't help, it is because |
|
With the latest change, I am seeing a much more promising result
I think there still are some unit test failing, need to investigate a bit |
|
Ok I think I fixed all of the failing tests, let's wait for CI to confirm |
c5724db to
6632e48
Compare
* Optimize Dynamo Training Execute * Check before doing mark_step for dynamo * Fix failing tests
* Optimize Dynamo Training Execute * Check before doing mark_step for dynamo * Fix failing tests

This will help #4475
Currently each dynamo training step(without optimizer) will result in 5 graph execution
They are
sync_multito sync input to fwd graphsync_multito sync input to bwd graphmark_stepat the end ofoptimized_modMy finding is that
The first graph executation is uecessary. It is triggered by
GetXlaDatainxla/torch_xla/csrc/init_python_bindings.cpp
Lines 1700 to 1702 in 661ab6d
However if I check the HLO, it is actually a
DeviceDataIR(not sure why). We don't need to callapplyPendingGraphto trigger execeution to retrive the XLAData. Hence my fix inGetXlaDataThe graph 3 and graph 5 are both triggered by
aot_autograd. Instead of usexla_sync_multito only sync the partial pending tensors and usemark_stepto sync the rest, we can just do onemark_stepin the beginning to combine 2 graphs. One thing to note is that we need to make firstmark_stepto be blocking.With above 2 fixes, we can cut graph from 5 -> 3.
With the latest change, I am seeing a much more promising result
<style type="text/css"></style>