Skip to content

Commit c0312ef

Browse files
committed
Smarter string replacement
Signed-off-by: Asha Anoosheh <aanoosheh@nvidia.com>
1 parent eb73662 commit c0312ef

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

modelopt/torch/distill/plugins/megatron.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def _adjust_layer_index_for_pp(submodule_name, model_cfg):
172172
if new_layer_idx < 0:
173173
raise ValueError(f"Layer {submodule_name} does not fall on final PP rank.")
174174

175-
new_submodule_name = submodule_name.replace(match.group(0), str(new_layer_idx))
175+
new_submodule_name = submodule_name.replace(f".{match.group(0)}", f".{new_layer_idx}")
176176
if parallel_state.get_tensor_and_context_parallel_rank() == 0:
177177
logger.info(
178178
f'Distillation: Renamed layer "{submodule_name}" on final PP rank to "{new_submodule_name}"'

0 commit comments

Comments
 (0)