Repository navigation
[graph_trainer] Accumulate PP gradients in backward graphs - #5208
Conversation
b472914 to
c8d3f06
Compare
c8d3f06 to
fcc3878
Compare
fcc3878 to
48086f5
Compare
Some WGrad outputs reach the accumulation buffer through a functional add chain, especially repeated native and MXFP8 contributions. Validate the complete left-linear chain before rewriting it, fuse supported producers in eager BF16 leaf order, and leave unsupported chains unchanged. The PP gradient-accumulation hookup follows in #5208. Validation: 24 WGrad tests passed.
48086f5 to
d14347b
Compare
| ("full_bw_repeat", graphs.modules.full_bw_repeat), | ||
| ("full_bw_first", graphs.modules.full_bw_first), |
There was a problem hiding this comment.
This is doubling the number of graph we need to worry about.
and it's for per-stage... every bw stage have 2 versions...
I wonder if the perf gain is really worth it.
The alternative is to just use one graph, and always do gradient accumulation for mb0. My bet is that it would matter less than 1% for E2E.
There was a problem hiding this comment.
esp when we have fused gradient accumulation, and the number of microbatch is probably >10.
There was a problem hiding this comment.
I will do perf testing to get real numbers.
There was a problem hiding this comment.
Tested PP ingraph grad accumulation - this was ~+8.5% of TPS even on local 4 GBs.
d14347b to
1997c4f
Compare
PP previously returned each microbatch parameter gradient to the Python runtime for accumulation. That kept the cross-microbatch dataflow outside the captured backward graphs. Use the same first/repeated lifecycle as SPMD gradient accumulation. The first executed backward returns the initial gradients; repeated full, split-dW, and multiplexed backward graphs accept those handles, update them in place, and return the latest handles. The scheduled REDUCE_GRAD consumes the final handles once. When WGrad fusion is enabled, replace supported producer-to-add chains with their fused forms; unsupported producers retain the explicit add_.
SherlockNoMad
left a comment
There was a problem hiding this comment.
thanks, this is much simpler than the 2 graph variant.
I wonder if we should do the same for spmd with ga case, i.e. make the first mb graph just take gradient buffer as input, and do the redundant accumulate into zero for mb0.
There will be a perf hit, but is simpler.
PP previously returned each microbatch parameter gradient to the Python runtime for accumulation. That kept the cross-microbatch dataflow outside the captured backward graphs. Give each PP stage persistent accumulator buffers and use one accumulating full, split-dW, or multiplexed backward graph for every microbatch. Before the first executed backward for a stage each step, zero the buffers; subsequent backwards update and return the same handles. The scheduled REDUCE_GRAD consumes the final handles once. Using one graph avoids separate first/repeated graph construction and compilation for every stage. When WGrad fusion is enabled, replace supported producer-to-add chains with their fused forms; unsupported producers retain the explicit add_.
1997c4f to
6acf5e9
Compare
PP previously returned each microbatch parameter gradient to Python for accumulation.
Use one accumulating graph per PP backward path and stage. The first executed backward for each stage in a step zeroes its persistent accumulators; every full, split-dW, and multiplexed backward updates and returns the same handles; REDUCE_GRAD consumes the final handles once.
With the shared add-chain support from #5119, supported WGrad producers fuse into the accumulator when enabled. Unsupported producers retain explicit add_.
Validation: 90 focused WGrad and GraphPP runtime tests passed.