def METHOD_NAME(grad):
    ddp_state_for_reversed_params[param][0] = True
    for cur_param, (ready, deleted) in ddp_state_for_reversed_params.items():
        if deleted:
            continue
        if ready:
            ddp_state_for_reversed_params[cur_param][1] = True
            # NOTE(jianhao)(higher-order-grad): local allreduce doesn't have gradient function, higher-order grad may be unsupported
            if cur_param is param:
                flow._C.local_all_reduce(grad, True)
            else:
                flow._C.local_all_reduce(cur_param.grad, True)
        else:
            break