Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 1 addition & 22 deletions megatron/core/pipeline_parallel/schedules.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
is_vp_last_stage,
)
from megatron.core.process_groups_config import ProcessGroupCollection
from megatron.core.transformer.cuda_graphs import create_cudagraphs
from megatron.core.transformer.cuda_graphs import create_cudagraphs, set_current_microbatch
Comment thread
jiemingz marked this conversation as resolved.
from megatron.core.transformer.enums import CudaGraphScope
from megatron.core.transformer.moe.router import MoEAuxLossAutoScaler
from megatron.core.utils import (
Expand Down Expand Up @@ -197,27 +197,6 @@ def custom_backward(output, grad_output):
)


def set_current_microbatch(model, microbatch_id):
"""Set the current microbatch."""
decoder_exists = True
model_with_decoder = None
try:
model_with_decoder = get_attr_wrapped_model(
model, "decoder", allow_none=False, return_model_obj=True
)
except RuntimeError:
decoder_exists = False
if decoder_exists and model_with_decoder is not None:
for layer in model_with_decoder.decoder.layers:
layer.current_microbatch = microbatch_id
if hasattr(model_with_decoder, 'mtp'):
for layer in model_with_decoder.mtp.layers:
assert hasattr(
layer, 'mtp_model_layer'
), f"MTP layer {layer} must have 'mtp_model_layer' attribute"
layer.mtp_model_layer.current_microbatch = microbatch_id


def forward_step_calc_loss(
model,
output_tensor,
Expand Down
Loading
Loading