Skip to content

[example, doc] fix: Fix RLHF script bugs and tutorial tokenization path#2364

Closed
yaoyu-33 wants to merge 1 commit intomainfrom
fix/rlhf-bridge-bugs-and-tutorial-path
Closed

[example, doc] fix: Fix RLHF script bugs and tutorial tokenization path#2364
yaoyu-33 wants to merge 1 commit intomainfrom
fix/rlhf-bridge-bugs-and-tutorial-path

Conversation

@yaoyu-33
Copy link
Contributor

@yaoyu-33 yaoyu-33 commented Feb 12, 2026

Summary

This PR fixes two bugs in the RLHF example script and one path issue in the tutorial notebook.

Changes

Bug 1: Missing trust_remote_code field in Args dataclass

  • Added trust_remote_code: bool = False to the Args dataclass
  • Added trust_remote_code=ns.trust_remote_code, to Args constructor
  • Fixes AttributeError when accessing args.trust_remote_code

Bug 2: Missing pg_collection argument in get_model() call

  • Added import: from megatron.core.process_groups_config import ProcessGroupCollection
  • Added pg_collection = ProcessGroupCollection.use_mpu_process_groups() after initialize_megatron()
  • Added pg_collection=pg_collection, to get_model() call
  • Fixes TypeError: get_model() missing required keyword-only argument 'pg_collection'

Bug 3: Incorrect path in tutorial notebook

  • Changed MEGATRON_LM_PATH=/opt/megatron-lm/ to MEGATRON_LM_PATH=/opt/Megatron-Bridge/3rdparty/Megatron-LM/
  • Fixes FileNotFoundError when running tokenization cell in NeMo container

Testing

  • Fixed issues reported in the bug descriptions
  • All changes follow existing code patterns and API requirements

Summary by CodeRabbit

  • New Features

    • Added trust_remote_code configuration option for RLHF training workflows.
    • Enhanced process group collection integration for distributed training.
  • Documentation

    • Added comprehensive Git commit workflow guide with standardized practices.
    • Updated training tutorial path references.
  • Chores

    • Updated Megatron-LM submodule to latest version.
    • Updated CLI invocation method for improved compatibility.

- Add missing trust_remote_code field to Args dataclass in rlhf_with_bridge.py
- Add missing pg_collection argument to get_model() call
- Fix MEGATRON_LM_PATH in reduced_precision_training.ipynb to use correct path

Signed-off-by: yaoyu-33 <yaoyu.094@gmail.com>
@copy-pr-bot
Copy link

copy-pr-bot bot commented Feb 12, 2026

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@yaoyu-33
Copy link
Contributor Author

/ok to test bc5232c

@yaoyu-33 yaoyu-33 closed this Feb 12, 2026
@yaoyu-33 yaoyu-33 deleted the fix/rlhf-bridge-bugs-and-tutorial-path branch February 12, 2026 23:29
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 12, 2026

📝 Walkthrough

Walkthrough

PR updates a Megatron-LM submodule reference, introduces Git commit workflow documentation, extends an RLHF example with process group collection support and new configuration options, and updates a tutorial path reference.

Changes

Cohort / File(s) Summary
Submodule & Path Updates
3rdparty/Megatron-LM, tutorials/training/reduced_precision_training.ipynb
Megatron-LM submodule commit reference bumped; tutorial Megatron-LM path updated to reflect new 3rdparty location.
Documentation
GIT_COMMIT_SKILLS.md
New guide documenting standardized Git commit workflow, including branch management, staging, pre-commit hooks, commit message formatting (modules/types/breaking changes), sign-off requirements, and PR procedures.
RLHF Example Enhancement
examples/rl/rlhf_with_bridge.py
CLI commands updated from CUDA/env-based to uv run invocations; Args dataclass extended with trust_remote_code field; config wiring threaded with trust_remote_code parameter; ProcessGroupCollection initialization added post-Megatron setup; get_model() signature updated to accept and propagate pg_collection.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • ananthsub
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Merge Conflict Detection ⚠️ Warning ❌ Merge conflicts detected (7 files):

⚔️ 3rdparty/Megatron-LM (content)
⚔️ examples/rl/rlhf_with_bridge.py (content)
⚔️ scripts/performance/configs/qwen/qwen3_workload_base_configs.py (content)
⚔️ scripts/performance/setup_experiment.py (content)
⚔️ src/megatron/bridge/training/train.py (content)
⚔️ tutorials/training/reduced_precision_training.ipynb (content)
⚔️ uv.lock (content)

These conflicts must be resolved before merging into main.
Resolve conflicts locally and push changes to this branch.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main changes in the PR: fixing RLHF script bugs and updating the tutorial tokenization path, matching the PR objectives.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Test Results For Major Changes ✅ Passed Changes are minor bug fixes to example code and tutorials, not major features or breaking changes affecting core functionality.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/rlhf-bridge-bugs-and-tutorial-path
⚔️ Resolve merge conflicts (beta)
  • Auto-commit resolved conflicts to branch fix/rlhf-bridge-bugs-and-tutorial-path
  • Create stacked PR with resolved conflicts
  • Post resolved changes as copyable diffs in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@GIT_COMMIT_SKILLS.md`:
- Around line 35-36: Remove the hardcoded, user-specific PATH export and replace
it with a generic instruction: delete the line containing export
PATH="/Users/yuya/Library/Python/3.9/bin:$PATH" and instead state that
contributors should ensure pre-commit is installed and available on their PATH
(e.g., install via pip/pipx or add their own user bin to PATH), leaving the
pre-commit run line unchanged so examples use the generic pre-commit run
command.
🧹 Nitpick comments (3)
examples/rl/rlhf_with_bridge.py (1)

1-1: Copyright year should be updated to 2026.

The copyright header says 2025 but the current year is 2026. Since lines in this file are being modified in this PR, consider updating the copyright year.

Proposed fix
-# Copyright (c) 2025, NVIDIA CORPORATION.  All rights reserved.
+# Copyright (c) 2025-2026, NVIDIA CORPORATION.  All rights reserved.
GIT_COMMIT_SKILLS.md (2)

1-143: This file appears to be a personal workflow cheat-sheet rather than project documentation.

This document reads like an AI-agent or personal developer instruction set (hardcoded local paths, specific branch/file references in examples, CI trigger commands). It doesn't align with the PR's stated scope of fixing RLHF script bugs and the tutorial tokenization path.

Consider whether this file should:

  1. Be excluded from this PR entirely (it's unrelated to the bug fixes).
  2. Be moved to a CONTRIBUTING.md section or .github/ directory if it's intended as contributor guidance.
  3. Have the examples generalized (replace specific file/branch names with placeholders).

63-92: Example section uses overly specific references that will become stale.

Line 76 references a specific test file (tests/unit_tests/models/gemma_vl/test_gemma3_vl_bridge.py), line 83 references a specific commit message, and line 89 references a specific branch (feature/provider-bridge-refactor-3). These are real session artifacts that will confuse future readers.

Replace with generic placeholders like <your-file>, <your-branch>, etc.

Proposed fix for the example section
 # 3. Stage changes
-git add tests/unit_tests/models/gemma_vl/test_gemma3_vl_bridge.py
+git add path/to/your/changed_file.py
 
 # 4. Run pre-commit
-export PATH="/Users/yuya/Library/Python/3.9/bin:$PATH"
 pre-commit run
 
 # 5. Commit with sign-off
-git commit -s -m "[test] fix: Fix gemma3_vl bridge test for image_token_id default"
+git commit -s -m "[module] type: Your descriptive commit message"
 
 # 6. Push
 git push
 
 # 7. Check for PR and trigger CI
-PR_NUMBER=$(gh pr list --head feature/provider-bridge-refactor-3 --json number --jq '.[0].number')
+PR_NUMBER=$(gh pr list --head feature/your-feature-name --json number --jq '.[0].number')
 COMMIT_HASH=$(git rev-parse HEAD)
 gh pr comment $PR_NUMBER --body "/ok to test $COMMIT_HASH"

Comment on lines +35 to +36
export PATH="/Users/yuya/Library/Python/3.9/bin:$PATH"
pre-commit run
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Hardcoded user-specific PATH leaks a local username and won't work for other contributors.

Lines 35 and 79 both contain /Users/yuya/Library/Python/3.9/bin — this is a macOS-specific path tied to a single developer's machine. It won't work for anyone else and inadvertently exposes a username.

If pre-commit is installed properly (e.g., via uv or pip), it should already be on $PATH. Remove the export PATH=... line or replace it with a generic instruction.

Proposed fix
 ### 4. Run Pre-commit Hooks
 ```bash
-export PATH="/Users/yuya/Library/Python/3.9/bin:$PATH"
 pre-commit run

And similarly in the example section (line 79):
```diff
 # 4. Run pre-commit
-export PATH="/Users/yuya/Library/Python/3.9/bin:$PATH"
 pre-commit run
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export PATH="/Users/yuya/Library/Python/3.9/bin:$PATH"
pre-commit run
pre-commit run
🤖 Prompt for AI Agents
In `@GIT_COMMIT_SKILLS.md` around lines 35 - 36, Remove the hardcoded,
user-specific PATH export and replace it with a generic instruction: delete the
line containing export PATH="/Users/yuya/Library/Python/3.9/bin:$PATH" and
instead state that contributors should ensure pre-commit is installed and
available on their PATH (e.g., install via pip/pipx or add their own user bin to
PATH), leaving the pre-commit run line unchanged so examples use the generic
pre-commit run command.

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