Skip to content

Commit

Permalink
[AutoParallel] Fit vpp for gradient_merge pass (#60560)
Browse files Browse the repository at this point in the history
* add dist attr

* add op namescope
  • Loading branch information
AndSonder committed Jan 9, 2024
1 parent 10a11d8 commit 5e35868
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ def _append_gradient_merge_backward_op(
attrs={
'axis': -1,
OP_ROLE_KEY: OpRole.Backward,
"op_namescope": "/auto_parallel/gradient_merge",
},
)

Expand Down Expand Up @@ -376,8 +377,16 @@ def true_apply_gradient():
)

paddle.static.nn.cond(cond_var, true_fn=true_apply_gradient, false_fn=None)
cond_dist_attr = dist_context.get_tensor_dist_attr_for_program(cond_var)
cond_op = main_program.global_block().ops[-1]
cond_op._set_attr(OP_ROLE_KEY, OpRole.Optimize)
naive_set_dist_op_attr_for_program_by_mesh_and_mapping(
cond_op,
process_mesh=cond_dist_attr.process_mesh,
ref_mapping=cond_dist_attr.dims_mapping,
ctx=dist_context,
chunk_id=cond_dist_attr.chunk_id,
)


def parse_program(
Expand Down

0 comments on commit 5e35868

Please sign in to comment.