Add nightly sync workflow from main to dev - #4165
Merged
Merged
Conversation
Automates a daily sync of main into dev at 4:00 AM China time (20:00 UTC) on weekdays. The workflow: - Closes any previous unmerged sync PR before creating a new one - Merges main into dev, preferring main on all conflicts (-X theirs) - Takes main's pyproject.toml and uv.lock for lock-file consistency - Creates a draft PR labeled "nightly-sync" for human review Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
After merging main into dev, also take main's versions of key integration files (training.py, initialize.py, utils.py, data_samplers.py, layer_wise_optimizer.py) that have deep semantic dependencies on conflict-resolved modules. This prevents runtime AttributeError and TypeError from auto-merged dev code referencing APIs removed in main. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Phlip79
added a commit
to Phlip79/Megatron-LM
that referenced
this pull request
Apr 6, 2026
This workflow belongs on the main branch (PR NVIDIA#4165), not the sync PR. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Instead of a fragile hardcoded file list, the workflow now takes main's version for ALL files that exist in both branches after the merge. This prevents semantic conflicts where auto-merged dev code references APIs that main renamed/removed. Dev-only new files are preserved. Also adds a black formatting step to fix trailing whitespace issues that appear when main's files differ from dev's formatting baseline. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The sync workflow now also restores files that exist in main but were deleted or renamed in dev (e.g. hybrid_cp_schedule.py). Without this, main's code that imports these files will fail with ModuleNotFoundError. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Redesigned the main-to-dev nightly sync to use Claude Code Action for: - Merge conflict resolution (prioritizing main) - Iterative CI failure fixing (no retry limit) - Automatic "/ok to test" CI triggering - Marking PR ready for review when all tests pass Key changes: - Schedule: daily at 20:00 UTC (all days) - Branch pattern: main2dev/dd_mm_yyyy - Uses secrets.PAT for push/PR/CI operations - Uses svcnvidia-nemo-ci as git committer - Closes previous unmerged sync PRs by branch pattern - Claude loops indefinitely: fix → push → trigger CI → wait → check → repeat Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Key changes: - Remove blanket "take main for all shared files" — preserves dev features (HyperConnection, CheckpointManager, etc.) - Only override specific files with confirmed semantic conflicts - Tell Claude to read CLAUDE.md and build-and-test skill first - Goal-oriented prompt instead of prescriptive shell commands - Add concurrency group to prevent overlapping runs - Add Agent to allowedTools for complex fixes - Teach Claude to surgically restore missing classes rather than replacing entire files - Remove trigger_phrase (not needed for direct_prompt) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove the cron schedule. The workflow can be re-enabled with a schedule trigger once the manual dispatch has been validated. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Member
Author
|
/claude review |
Phlip79
marked this pull request as ready for review
April 7, 2026 23:32
Member
Author
|
/ok to test d929db9 |
…nt step Add data_schedule.py as override candidate, run pylint on megatron/core files after formatting, poll CI every 2min with per-job failure checking, and improve guidance for files with divergent main/dev classes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Member
Author
|
/ok to test 9826d45 |
Member
Author
|
/ok to test 93581f7 |
Signed-off-by: oliver könig <okoenig@nvidia.com>
Contributor
|
The general setup looks great. Here are some issues and suggestions:
As of the real PR it attempted, #4213, I found couple (potential) issues
|
Changes based on review of PR NVIDIA#4213 and NVIDIA#4165: 1. Don't blindly restore files deleted by dev — check whether main's code actually imports them before restoring. Dev may have intentionally removed files to simplify testing. 2. Include remerge-diff in PR body so reviewers can inspect only the conflict resolutions without wading through the full merge diff. 3. Add warning about squashed-merge chains: when dev has PR1→PR2→PR3 but only PR1 is on main, -X theirs may overwrite PR2/PR3's follow-up changes. Claude should check git log on dev for follow-up commits before favoring main. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Tighten the nightly sync workflow prompt and skill so the bot cannot
mark the PR ready while non-exempt checks are pending or failing.
- Replace the loose Phase 4 gate with a strict "all terminal, all
green" rule: every non-exempt required check in statusCheckRollup
must be COMPLETED + {SUCCESS, SKIPPED, NEUTRAL}. Queued or
in_progress is never acceptable.
- Explicitly ban background tasks (Bash/Agent run_in_background,
ScheduleWakeup, &, nohup, disown, setsid, tail -f on background
output) and explain why: the GitHub Actions step process owns the
shell and is destroyed on exit, so backgrounded work cannot resume.
- Anchor CI polling to `gh pr view --json statusCheckRollup` — the
actions/runs/.../jobs endpoint alone misses external status
contexts (GitLab CI, copy-pr-bot, etc.), which was the failure mode
on run 24800621116.
- Distinguish outer loop (agent's sequence of tool calls) from inner
loop (single blocking Bash call); provide a validated bash template
that normalizes CheckRun and StatusContext entries, uses
Nemo_CICD_Test as a sentinel to close the empty-rollup edge case,
and classifies against the exempt regex.
- Align exempt list with actual check names seen on PR NVIDIA#4159:
approval (codeowners-approval, check-approval,
multi-approval-bot-summary, is-not-external-contributor),
coverage (Coverage (unit-test), Coverage_Fake), docs
(build-docs / Build docs, build-docs-summary).
# Conflicts: # pyproject.toml # skills/nightly-sync/SKILL.md # uv.lock
This branch targets main and should only add the nightly-sync workflow and skill. It should not touch pyproject.toml, uv.lock, or Dockerfile.ci.dev. The prior commit 1844bb0 (take dev's versions) was correct for the sync bot's runtime behavior (merging main->dev) but wrong to include in a PR to main — dev's dep pins, Python version floor, and transformer-engine range must not propagate back to main. Restore main's versions here.
The first sync run (PR NVIDIA#4436) violated two invariants that the prior prompt treated as soft guidance: 1. .github/CODEOWNERS was modified (+45/-1) — the -X theirs merge pulled main's detailed CODEOWNERS on top of dev's one-liner. 2. gh pr ready was invoked with a known non-exempt failure (gpt/gpt3_mcore_te_tp2_pp2_mhc) AND ~54 functional tests still QUEUED on H100/GB200. Changes: - State the CODEOWNERS rule as a HARD invariant in the Files to Override section: never modify, restore via `git checkout origin/dev -- .github/CODEOWNERS`, verify diff is empty. - Add a new "Pre-push invariant checks" bash block that runs before every push (initial and fix-push) and exits 1 if CODEOWNERS diverges from origin/dev.
Reviewers skim the PR stats line to gauge the real code surface, but the total is dominated by golden-value JSON and uv.lock churn. Add a Phase 2 instruction to compute and include Python-only additions / deletions (via 'git diff --numstat origin/dev...HEAD -- *.py') in the PR body.
GitHub Actions cron is UTC-only and does not follow DST, so the job runs at 1 PM PST during the winter months.
Member
Author
|
/ok to test 0d8ad45 |
opus[1m] is the Claude Code rolling alias for the latest Opus model with the 1M-context variant. It auto-resolves to the current Opus (4.7 today, 4.8+ automatically). Avoids having to bump this workflow on each Opus release.
ko3n1g
approved these changes
Apr 28, 2026
Contributor
|
/ok to test ddab623 |
Contributor
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/25046906403 |
yangbofun
pushed a commit
to xlm-research/Megatron-LM
that referenced
this pull request
May 22, 2026
Signed-off-by: oliver könig <okoenig@nvidia.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: Philip Petrakian <> Co-authored-by: oliver könig <okoenig@nvidia.com>
yhgalaxy
pushed a commit
to yhgalaxy/Megatron-LM
that referenced
this pull request
Jun 17, 2026
Signed-off-by: oliver könig <okoenig@nvidia.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: Philip Petrakian <> Co-authored-by: oliver könig <okoenig@nvidia.com> Signed-off-by: yhgalaxy <yhgalaxy@outlook.com>
jon-barker
pushed a commit
to jon-barker/Megatron-LM
that referenced
this pull request
Jul 10, 2026
Signed-off-by: oliver könig <okoenig@nvidia.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: Philip Petrakian <> Co-authored-by: oliver könig <okoenig@nvidia.com> Signed-off-by: Jon Barker <jbarker@aws-cmh-slurm-1-vscode-02.cm.cluster>
terminator123
pushed a commit
to 021ai/Megatron-LM
that referenced
this pull request
Aug 3, 2026
Signed-off-by: oliver könig <okoenig@nvidia.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: Philip Petrakian <> Co-authored-by: oliver könig <okoenig@nvidia.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a GitHub Actions workflow that syncs
mainintodevusing Claude Code Action. Currently manual-dispatch only (workflow_dispatch) for testing. A cron schedule will be added once validated.Test workloads can be found here.
How it works
main2dev/*branch is closedgit merge -X theirsto prefer main on textual conflictsmain2dev/dd_mm_yyyy/ok to test <sha>comment usingsecrets.PATDesign decisions
-X theirsfor merge conflicts, but dev-only additions (new classes, modules) are kept through normal git merge