Skip to content

fix(megatron_bridge): save TensorBoard logs by default#968

Open
blugassi wants to merge 2 commits into
NVIDIA:mainfrom
blugassi:fix/megatron-bridge-tensorboard-dir
Open

fix(megatron_bridge): save TensorBoard logs by default#968
blugassi wants to merge 2 commits into
NVIDIA:mainfrom
blugassi:fix/megatron-bridge-tensorboard-dir

Conversation

@blugassi

@blugassi blugassi commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Summary
Set Megatron-Bridge’s default TensorBoard directory to /nemo_run/tb_logs. Improve training-report checks to reject missing, empty, or malformed artifacts with clear logs. User overrides remain supported.

Test Plan
Tested on Linux with Python 3.12 and pytest 9.1:

python -m pytest tests/report_generator/training/test_training_parser.py
tests/workloads/megatron_bridge/test_command_gen_strategy_slurm.py
tests/workloads/megatron_run/test_megatron_run.py
'tests/test_acceptance.py::test_sbatch_generation[megatron-bridge]'
Result: 79 tests passed.

Additional Notes
Existing logger.tensorboard_dir overrides are unchanged.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: d1d5ec06-50fc-4a73-b059-f8134bd0d312

📥 Commits

Reviewing files that changed from the base of the PR and between 4c73044 and ab02db2.

📒 Files selected for processing (2)
  • src/cloudai/report_generator/training/parser.py
  • tests/report_generator/training/test_training_parser.py

📝 Walkthrough

Walkthrough

The changes add a default TensorBoard directory to Megatron Bridge SLURM commands, preserve custom overrides, test generated launcher output, and strengthen TrainingParser.can_parse artifact validation.

Changes

Megatron Bridge TensorBoard configuration

Layer / File(s) Summary
Add and validate TensorBoard directory override
src/cloudai/workloads/megatron_bridge/slurm_command_gen_strategy.py, tests/workloads/megatron_bridge/test_command_gen_strategy_slurm.py, tests/ref_data/megatron-bridge.sbatch
Adds /nemo_run/tb_logs as the default logger.tensorboard_dir, verifies custom override precedence, and updates the launcher reference command.

Training parser validation

Layer / File(s) Summary
Validate training artifacts
src/cloudai/report_generator/training/parser.py, tests/report_generator/training/test_training_parser.py
Requires recursive TensorBoard event files and valid, non-empty JSON or YAML configuration artifacts, logging warnings and returning False when validation fails.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: srivatsankrishnan, podkidyshev, jeffnvidia

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: setting Megatron-Bridge TensorBoard logs to save by default.
Description check ✅ Passed The description is directly related to the code changes and testing for TensorBoard defaults and parser validation.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@blugassi blugassi force-pushed the fix/megatron-bridge-tensorboard-dir branch from 3bf8daa to 548fec1 Compare July 14, 2026 11:58

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/cloudai/report_generator/training/parser.py`:
- Around line 79-80: Update the directory validation in can_handle_directory()
to require at least one actual TensorBoard event file matching the
events.out.tfevents* pattern, rather than accepting any non-empty directory.
Preserve the existing warning and skip behavior when no readable event files are
present.
- Around line 82-84: Update can_parse() to validate the config artifact’s
contents, not only config_path.is_file(), before returning True; ensure
malformed or empty JSON/YAML causes the method to return False. Alternatively,
update get_model_config() failures used by parse() to be caught and converted
into a False parseability result, preserving the existing skip behavior for
invalid training reports.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: f1cdc005-6e8b-4dad-8e74-acf4ba06050f

📥 Commits

Reviewing files that changed from the base of the PR and between 3bf8daa and 548fec1.

📒 Files selected for processing (4)
  • src/cloudai/report_generator/training/parser.py
  • src/cloudai/workloads/megatron_bridge/slurm_command_gen_strategy.py
  • tests/ref_data/megatron-bridge.sbatch
  • tests/workloads/megatron_bridge/test_command_gen_strategy_slurm.py

Comment thread src/cloudai/report_generator/training/parser.py Outdated
Comment thread src/cloudai/report_generator/training/parser.py
@blugassi blugassi force-pushed the fix/megatron-bridge-tensorboard-dir branch from 548fec1 to 3ce59b5 Compare July 14, 2026 13:00
Set the default log directory to the saved run output so training reports can consume TensorBoard metrics while preserving user overrides.

Signed-off-by: Ben Lugassi <blugassi@nvidia.com>
@blugassi blugassi force-pushed the fix/megatron-bridge-tensorboard-dir branch from 3ce59b5 to 4c73044 Compare July 14, 2026 13:24

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/cloudai/report_generator/training/parser.py`:
- Around line 80-100: Optionally optimize can_parse and parse by caching the
validated dictionary returned by get_model_config for JSON/YAML artifacts and
reusing it through _resolve_model_config, avoiding a second disk parse per run
while preserving existing validation behavior.

In `@tests/report_generator/training/test_training_parser.py`:
- Around line 485-522: Update the outer parameter container in the
pytest.mark.parametrize call for test_can_parse_rejects_invalid_file_config from
a tuple to a list, while keeping each individual pytest.param row and test
behavior unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: d7a5889e-6e0f-4a7f-a63f-87b029042d37

📥 Commits

Reviewing files that changed from the base of the PR and between 3ce59b5 and 4c73044.

📒 Files selected for processing (5)
  • src/cloudai/report_generator/training/parser.py
  • src/cloudai/workloads/megatron_bridge/slurm_command_gen_strategy.py
  • tests/ref_data/megatron-bridge.sbatch
  • tests/report_generator/training/test_training_parser.py
  • tests/workloads/megatron_bridge/test_command_gen_strategy_slurm.py

Comment thread src/cloudai/report_generator/training/parser.py
Comment thread tests/report_generator/training/test_training_parser.py
Reject missing or invalid training artifacts before parsing and log why report generation is skipped.

Signed-off-by: Ben Lugassi <blugassi@nvidia.com>
@blugassi blugassi force-pushed the fix/megatron-bridge-tensorboard-dir branch from 4c73044 to ab02db2 Compare July 14, 2026 13:28

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/report_generator/training/test_training_parser.py`:
- Around line 475-482: Update the test setup around parser.can_parse to place
custom.tfevents.log inside a nested directory under tb_dir, while keeping the
existing non-empty-directory and configuration assertions unchanged. This
ensures recursive TensorBoard event discovery is required.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: d7ca2872-70ba-418d-954d-5e3996d76d51

📥 Commits

Reviewing files that changed from the base of the PR and between 4c73044 and ab02db2.

📒 Files selected for processing (2)
  • src/cloudai/report_generator/training/parser.py
  • tests/report_generator/training/test_training_parser.py

Comment thread tests/report_generator/training/test_training_parser.py
@blugassi

Copy link
Copy Markdown
Contributor Author

@coderabbitai resume

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Reviews resumed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant