From 582a9cc3899985a45510b5624b00f72ab6ec59ab Mon Sep 17 00:00:00 2001 From: Hollow Man Date: Tue, 20 Jan 2026 00:32:56 +0200 Subject: [PATCH 1/2] Fix several syntax error *** Error compiling './Megatron-LM/examples/multimodal/evaluation/evaluate_mmmu.py'... File "./Megatron-LM/examples/multimodal/evaluation/evaluate_mmmu.py", line 107 m = re.search("'Overall': {'num': \d+, 'acc': (\d.\d+)}", output.stdout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: invalid escape sequence '\d' *** Error compiling './Megatron-LM/megatron/legacy/model/vision/esvit_swin_backbone.py'... File "./Megatron-LM/megatron/legacy/model/vision/esvit_swin_backbone.py", line 729 or pretrained_layers[0] is '*' ^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: "is" with a literal. Did you mean "=="? *** Error compiling './Megatron-LM/tests/test_utils/python_scripts/launch_nemo_run_workload.py'... File "./Megatron-LM/tests/test_utils/python_scripts/launch_nemo_run_workload.py", line 137 logger.info(f"Job succeeded with status: {job_dict["status"]}") ^^^^^^ SyntaxError: f-string: unmatched '[' Signed-off-by: Hollow Man --- examples/multimodal/evaluation/evaluate_mmmu.py | 2 +- megatron/legacy/model/vision/esvit_swin_backbone.py | 6 +++--- tests/test_utils/python_scripts/launch_nemo_run_workload.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/multimodal/evaluation/evaluate_mmmu.py b/examples/multimodal/evaluation/evaluate_mmmu.py index 90cf141cd54..122ce873f2e 100644 --- a/examples/multimodal/evaluation/evaluate_mmmu.py +++ b/examples/multimodal/evaluation/evaluate_mmmu.py @@ -104,7 +104,7 @@ def mmmu_eval(input_path, groundtruth_path): print(output.stderr) print(output.stdout) - m = re.search("'Overall': {'num': \d+, 'acc': (\d.\d+)}", output.stdout) + m = re.search(r"'Overall': {'num': \d+, 'acc': (\d\.\d+)}", output.stdout) return float(m.group(1)) * 100.0 diff --git a/megatron/legacy/model/vision/esvit_swin_backbone.py b/megatron/legacy/model/vision/esvit_swin_backbone.py index 87932040cb7..c7c67b40c64 100644 --- a/megatron/legacy/model/vision/esvit_swin_backbone.py +++ b/megatron/legacy/model/vision/esvit_swin_backbone.py @@ -726,7 +726,7 @@ def init_weights(self, pretrained='', pretrained_layers=[], verbose=True): for k, v in pretrained_dict.items(): need_init = ( k.split('.')[0] in pretrained_layers - or pretrained_layers[0] is '*' + or pretrained_layers[0] == '*' or 'relative_position_index' not in k or 'attn_mask' not in k ) @@ -785,7 +785,7 @@ def freeze_pretrained_layers(self, frozen_layers=[]): if ( name.split('.')[0] in frozen_layers or '.'.join(name.split('.')[0:2]) in frozen_layers - or (len(frozen_layers) > 0 and frozen_layers[0] is '*') + or (len(frozen_layers) > 0 and frozen_layers[0] == '*') ): for _name, param in module.named_parameters(): param.requires_grad = False @@ -796,7 +796,7 @@ def freeze_pretrained_layers(self, frozen_layers=[]): for name, param in self.named_parameters(): if ( name.split('.')[0] in frozen_layers - or (len(frozen_layers) > 0 and frozen_layers[0] is '*') + or (len(frozen_layers) > 0 and frozen_layers[0] == '*') and param.requires_grad is True ): param.requires_grad = False diff --git a/tests/test_utils/python_scripts/launch_nemo_run_workload.py b/tests/test_utils/python_scripts/launch_nemo_run_workload.py index 26a7dbd79f5..a4dd76e24b9 100644 --- a/tests/test_utils/python_scripts/launch_nemo_run_workload.py +++ b/tests/test_utils/python_scripts/launch_nemo_run_workload.py @@ -134,10 +134,10 @@ def main( succeeded = str(job_dict["status"]) == "SUCCEEDED" if succeeded: - logger.info(f"Job succeeded with status: {job_dict["status"]}") + logger.info(f"Job succeeded with status: {job_dict['status']}") sys.exit(0) - logger.error(f"Job failed with status: {job_dict["status"]}") + logger.error(f"Job failed with status: {job_dict['status']}") log_file_paths = pathlib.Path(os.getcwd()).glob("assets_dir/logs/*/*/attempt_0/*/std*.log") all_ranks_all_logs = [] for log_file_path in log_file_paths: From efc5001f33e208ab0856fe0c3f97c1c4aa288ffe Mon Sep 17 00:00:00 2001 From: Hollow Man Date: Sat, 31 Jan 2026 16:09:09 +0200 Subject: [PATCH 2/2] Add copyright header Signed-off-by: Hollow Man --- examples/multimodal/evaluation/evaluate_mmmu.py | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/multimodal/evaluation/evaluate_mmmu.py b/examples/multimodal/evaluation/evaluate_mmmu.py index 122ce873f2e..2bdc2ebbdc5 100644 --- a/examples/multimodal/evaluation/evaluate_mmmu.py +++ b/examples/multimodal/evaluation/evaluate_mmmu.py @@ -1,3 +1,4 @@ +# Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. import argparse import glob import json