Skip to content

Commit 5aef730

Browse files
authored
Merge branch 'main' into dfridman/deepseek-conversion-mtp-support
2 parents 90bc423 + ba68841 commit 5aef730

68 files changed

Lines changed: 1418 additions & 1040 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/_update_dependencies.yml‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ jobs:
102102
uses: peter-evans/create-pull-request@v6
103103
id: create-pull-request
104104
env:
105-
title: "chore(beep boop 🤖): Bump `uv.lock` (${{ inputs.target-branch}}) (${{ needs.pre-flight.outputs.date }})"
105+
title: "chore(beep boop 🤖): Bump `uv.lock` (${{ env.TARGET_BRANCH}}, mcore-${{ inputs.mcore-branch }}) (${{ needs.pre-flight.outputs.date }})"
106106
with:
107107
branch: ${{ env.SOURCE_BRANCH }}
108108
base: ${{ env.TARGET_BRANCH }}
@@ -115,6 +115,7 @@ jobs:
115115
commit-message: ${{ env.title }}
116116
signoff: true
117117
committer: "github-actions[bot] <github-actions[bot]@users.noreply.github.com>"
118+
labels: needs-more-tests
118119

119120
- name: Post /ok to test comment
120121
env:
@@ -197,8 +198,11 @@ jobs:
197198
- name: Revert submodule bump for dev branch
198199
if: ${{ inputs.mcore-branch == 'dev' }}
199200
run: |
200-
git checkout 3rdparty/Megatron-LM
201-
git checkout .main.commit
201+
git config user.name "github-actions[bot]"
202+
git config user.email "github-actions[bot]@users.noreply.github.com"
203+
git fetch origin ${{ env.TARGET_BRANCH }}
204+
git restore --source=origin/${{ env.TARGET_BRANCH }} -- 3rdparty/Megatron-LM uv.lock
205+
git add 3rdparty/Megatron-LM uv.lock
202206
git commit -m "Revert submodule bump for dev branch"
203207
git push origin ${{ env.SOURCE_BRANCH }}
204208

‎.github/workflows/build-test-publish-wheel.yml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,13 @@ concurrency:
3434

3535
jobs:
3636
pre-flight:
37-
uses: NVIDIA-NeMo/FW-CI-templates/.github/workflows/_cicd_preflight.yml@v0.73.2
37+
uses: NVIDIA-NeMo/FW-CI-templates/.github/workflows/_cicd_preflight.yml@v0.80.1
3838
with:
3939
default_runner_prefix: ${{ vars.DEFAULT_RUNNER_PREFIX }}
4040
non_nvidia_runner_prefix: ${{ vars.NON_NVIDIA_RUNNER_PREFIX }}
4141
default_test_data_path: ${{ vars.DEFAULT_TEST_DATA_PATH }}
4242
non_nvidia_test_data_path: ${{ vars.NON_NVIDIA_TEST_DATA_PATH }}
43+
sso_users_filename: ${{ vars.SSO_USERS_FILENAME }}
4344
secrets:
4445
NVIDIA_MANAGEMENT_ORG_PAT: ${{ secrets.NVIDIA_MANAGEMENT_ORG_PAT }}
4546

‎.github/workflows/cicd-main.yml‎

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,13 @@ env:
6161

6262
jobs:
6363
pre-flight:
64-
uses: NVIDIA-NeMo/FW-CI-templates/.github/workflows/_cicd_preflight.yml@v0.73.2
64+
uses: NVIDIA-NeMo/FW-CI-templates/.github/workflows/_cicd_preflight.yml@v0.80.1
6565
with:
6666
default_runner_prefix: ${{ vars.DEFAULT_RUNNER_PREFIX }}
6767
non_nvidia_runner_prefix: ${{ vars.NON_NVIDIA_RUNNER_PREFIX }}
6868
default_test_data_path: ${{ vars.DEFAULT_TEST_DATA_PATH }}
6969
non_nvidia_test_data_path: ${{ vars.NON_NVIDIA_TEST_DATA_PATH }}
70+
sso_users_filename: ${{ vars.SSO_USERS_FILENAME }}
7071
secrets:
7172
NVIDIA_MANAGEMENT_ORG_PAT: ${{ secrets.NVIDIA_MANAGEMENT_ORG_PAT }}
7273

@@ -722,9 +723,10 @@ jobs:
722723
GH_TOKEN: ${{ github.token }}
723724
# A tier is "expected" if its if-condition (excluding success()/is_ci_workload/force_run_all) would be true.
724725
# Unexpected skips in an expected tier are failures.
725-
EXPECT_L0: ${{ github.event.inputs.test_suite == '' || github.event.inputs.test_suite == 'all' || github.event.inputs.test_suite == 'functional-only' }}
726-
EXPECT_L1: ${{ (github.event.inputs.test_suite == '' || github.event.inputs.test_suite == 'all' || github.event.inputs.test_suite == 'functional-only') && (github.ref == 'refs/heads/main' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || needs.check-labels.outputs.needs_more_tests == 'true') }}
727-
EXPECT_L2: ${{ (github.event.inputs.test_suite == '' || github.event.inputs.test_suite == 'all' || github.event.inputs.test_suite == 'functional-only') && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') }}
726+
# is_ci_workload must be true, otherwise docs-only/deployment runs have no tests and trigger false positives.
727+
EXPECT_L0: ${{ needs.pre-flight.outputs.is_ci_workload == 'true' && (github.event.inputs.test_suite == '' || github.event.inputs.test_suite == 'all' || github.event.inputs.test_suite == 'functional-only') }}
728+
EXPECT_L1: ${{ needs.pre-flight.outputs.is_ci_workload == 'true' && (github.event.inputs.test_suite == '' || github.event.inputs.test_suite == 'all' || github.event.inputs.test_suite == 'functional-only') && (github.ref == 'refs/heads/main' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || needs.check-labels.outputs.needs_more_tests == 'true') }}
729+
EXPECT_L2: ${{ needs.pre-flight.outputs.is_ci_workload == 'true' && (github.event.inputs.test_suite == '' || github.event.inputs.test_suite == 'all' || github.event.inputs.test_suite == 'functional-only') && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') }}
728730
run: |
729731
FAILED_JOBS=$(gh run view $GITHUB_RUN_ID --json jobs --jq '[.jobs[] | select(.status == "completed" and .conclusion != "success" and .conclusion != "skipped")] | length') || echo 0
730732
@@ -763,12 +765,13 @@ jobs:
763765
runs-on: ubuntu-latest
764766
needs: [Nemo_CICD_Test, pre-flight]
765767
if: |
766-
(
768+
always()
769+
&& !cancelled()
770+
&& needs.pre-flight.outputs.is_ci_workload == 'false'
771+
&& (
767772
needs.pre-flight.outputs.docs_only == 'true'
768773
|| needs.pre-flight.outputs.is_deployment_workflow == 'true'
769774
)
770-
&& needs.pre-flight.outputs.is_ci_workload == 'false'
771-
&& !cancelled()
772775
steps:
773776
- name: Generate fake coverage report
774777
uses: actions/github-script@v6
@@ -788,10 +791,10 @@ jobs:
788791
runs-on: ubuntu-latest
789792
needs: [Nemo_CICD_Test, pre-flight]
790793
if: |
791-
(
792-
(needs.pre-flight.outputs.is_ci_workload == 'true' && !failure())
793-
|| success()
794-
)
794+
needs.Nemo_CICD_Test.result == 'success'
795+
&& needs.pre-flight.outputs.docs_only == 'false'
796+
&& needs.pre-flight.outputs.is_deployment_workflow == 'false'
797+
&& github.event.inputs.mcore_ref == ''
795798
&& !cancelled()
796799
strategy:
797800
matrix:

‎.github/workflows/install-test.yml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,11 @@ concurrency:
5757

5858
jobs:
5959
pre-flight:
60-
uses: NVIDIA-NeMo/FW-CI-templates/.github/workflows/_cicd_preflight.yml@v0.73.2
60+
uses: NVIDIA-NeMo/FW-CI-templates/.github/workflows/_cicd_preflight.yml@v0.80.1
6161
with:
6262
default_runner_prefix: ${{ vars.INSTALL_TEST_DEFAULT_RUNNER_PREFIX }}
6363
non_nvidia_runner_prefix: ${{ vars.INSTALL_TEST_NON_NVIDIA_RUNNER_PREFIX }}
64+
sso_users_filename: ${{ vars.SSO_USERS_FILENAME }}
6465
secrets:
6566
NVIDIA_MANAGEMENT_ORG_PAT: ${{ secrets.NVIDIA_MANAGEMENT_ORG_PAT }}
6667

‎.github/workflows/release.yaml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,13 @@ permissions:
5656

5757
jobs:
5858
pre-flight:
59-
uses: NVIDIA-NeMo/FW-CI-templates/.github/workflows/_cicd_preflight.yml@v0.73.2
59+
uses: NVIDIA-NeMo/FW-CI-templates/.github/workflows/_cicd_preflight.yml@v0.80.1
6060
with:
6161
default_runner_prefix: ${{ vars.DEFAULT_RUNNER_PREFIX }}
6262
non_nvidia_runner_prefix: ${{ vars.NON_NVIDIA_RUNNER_PREFIX }}
6363
default_test_data_path: ${{ vars.DEFAULT_TEST_DATA_PATH }}
6464
non_nvidia_test_data_path: ${{ vars.NON_NVIDIA_TEST_DATA_PATH }}
65+
sso_users_filename: ${{ vars.SSO_USERS_FILENAME }}
6566
secrets:
6667
NVIDIA_MANAGEMENT_ORG_PAT: ${{ secrets.NVIDIA_MANAGEMENT_ORG_PAT }}
6768

‎.main.commit‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
905c0e38655a61e603529b972ca9fdffd7daa667
1+
9ed8b0c4ac8e65d80fb35eecb3656c96b30df943

‎3rdparty/Megatron-LM‎

Submodule Megatron-LM updated 331 files

‎docker/common/README.md‎

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22

33
## Repository Overview
44

5-
- Megatron-Bridge (/opt/Megatron-Bridge/)
6-
- Megatron-LM (/opt/Megatron-Bridge/3rdparty/Megatron-LM/)
7-
- Evaluator (/opt/Evaluator/)
8-
- Export-Deploy (/opt/Export-Deploy/)
9-
- NeMo (/opt/NeMo/)
10-
- Run (/opt/Run/)
5+
- Megatron-Bridge (`/opt/Megatron-Bridge/`)
6+
- Megatron-LM (`/opt/Megatron-Bridge/3rdparty/Megatron-LM/`)
7+
- Evaluator (`/opt/Evaluator/`)
8+
- Export-Deploy (`/opt/Export-Deploy/`)
9+
- NeMo (`/opt/NeMo/`)
10+
- Run (`/opt/Run/`)
1111

1212
---
1313

14-
## Installed Packged
14+
## Installed Packages
1515

1616
Pip installed packages:
1717

@@ -29,7 +29,7 @@ Uv virtualenv installed packages (/opt/venv/)
2929

3030
Execute `uv pip list` to see full list of installed packages. Packages installed in /opt/venv take precedence over pip installed packages.
3131

32-
See /opt/NeMo-FW/pyproject.toml for additonal uv configurations.
32+
See `/opt/NeMo-FW/pyproject.toml` for additonal uv configurations.
3333

3434
---
3535

@@ -45,38 +45,55 @@ docker run -v <local-folder-path>:<container-folder-path> <container-image>
4545

4646
#### 1 Overwrite existing directory
4747

48-
1. Define the `<container-folder-path>` to correspond to the path defined in Repository Overview. (ie. /my-path/Megatron-Bridge/:/opt/Megatron-Bridge/)
48+
1. Define the `<container-folder-path>` to correspond to the path defined in Repository Overview. (ie. `/my-path/Megatron-Bridge/:/opt/Megatron-Bridge/`)
4949

5050
2. `cd /opt/NeMo-FW` and run `uv sync --no-cache-dir --all-groups --inexact`
5151

5252
3. Local development directory is synced to run in the container
5353

5454
#### 2 Mount directory to a different path
5555

56-
1. Modify `/opt/NeMo-FW/pyproject.toml` sections `tool.uv.sources` and `tool.uv; override-dependencies` to reflect new path. (ie. "megatron-bridge" = { path = `<container-folder-path>`, editable = true })
56+
1. Modify `/opt/NeMo-FW/pyproject.toml` sections `tool.uv.sources` and `tool.uv; override-dependencies` to reflect new path. (ie. `"megatron-bridge" = { path = <container-folder-path>, editable = true }`)
5757

5858
2. `cd /opt/NeMo-FW` and run `uv sync --no-cache-dir --all-groups --inexact`
5959

6060
3. Local development directory is synced to run in the container
6161

6262
### Installing packages inside the container
6363

64-
Packages can be installed into the uv virtualenv (`/opt/venv/`) from two locations:
64+
All packages share a single uv virtualenv (`/opt/venv/`). The *location* you install
65+
from determines which resolution rules apply — use the guide below.
6566

66-
#### From `/opt/NeMo-FW` (default)
67+
#### Which code needs this package?
6768

68-
Use this when unsure, or when the dependency is not specific to Megatron:
69+
**Megatron-Bridge/Megatron-LM** (training, model architecture):
6970

7071
```bash
71-
cd /opt/NeMo-FW
72+
cd /opt/Megatron-Bridge
7273
uv pip install <package>
7374
```
7475

75-
#### From `/opt/Megatron-Bridge`
76+
Examples of Megatron-Bridge managed packages are TransformerEngine, nvidia-resiliency-ext, nvidia-modelopt. For a complete list, please visit `/opt/Megatron-Bridge/pyproject.toml`. Any of these dependencies can be re-installed via this directory.
77+
78+
It is unsafe to install packages that are not part of Megatron-Bridge from within this directory. For changing those dependencies, please visit the next section.
7679

77-
Use this only for Megatron-specific dependencies:
80+
**NeMo toolkit, Export-Deploy, Run, or Evaluator**:
7881

7982
```bash
80-
cd /opt/Megatron-Bridge
83+
cd /opt/NeMo-FW
8184
uv pip install <package>
8285
```
86+
87+
This is safe to use for general packages. This directory also prevents accidental re-install of heavy dependencies like trt-llm or vllm. MBridge-managed packages
88+
(TransformerEngine, nvidia-resiliency-ext, nvidia-modelopt, etc.) are protected
89+
and will not be overwritten. For reinstalling those, please visit the next section.
90+
91+
**vllm, tensorrt-llm, or tensorrt**:
92+
93+
These are built from source and baked into the container at build time (see
94+
`docker/Dockerfile.fw_base`). They cannot be managed via `uv pip install`.
95+
To change them, rebuild the container.
96+
97+
**general note:**
98+
99+
Running uv pip install outside any of the two directories above might lead to a re-install of torch, thus breaking all dependencies that have been compiled against the original torch version. By running uv pip install inside any of the two directories, we can avoid this unwanted side-effect.

‎docs/models/llm/gemma2.md‎

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,14 @@ Note:
108108
- `gemma2_2b_pretrain_config`: Pre-training configuration for Gemma 2 2B
109109
- `gemma2_9b_pretrain_config`: Pre-training configuration for Gemma 2 9B
110110
- `gemma2_27b_pretrain_config`: Pre-training configuration for Gemma 2 27B
111-
- **Finetuning:**
112-
- `gemma2_2b_finetune_config`: Finetuning configuration for Gemma 2 2B with PEFT support (LoRA, DoRA)
113-
- `gemma2_9b_finetune_config`: Finetuning configuration for Gemma 2 9B with PEFT support (LoRA, DoRA)
114-
- `gemma2_27b_finetune_config`: Finetuning configuration for Gemma 2 27B with PEFT support (LoRA, DoRA)
111+
- **SFT:**
112+
- `gemma2_2b_sft_config`: Full SFT for Gemma 2 2B
113+
- `gemma2_9b_sft_config`: Full SFT for Gemma 2 9B
114+
- `gemma2_27b_sft_config`: Full SFT for Gemma 2 27B
115+
- **PEFT** (LoRA, DoRA):
116+
- `gemma2_2b_peft_config`: PEFT for Gemma 2 2B
117+
- `gemma2_9b_peft_config`: PEFT for Gemma 2 9B
118+
- `gemma2_27b_peft_config`: PEFT for Gemma 2 27B
115119

116120
Before training, ensure the following environment variables are set:
117121
1. `SAVE_DIR`: checkpoint and log saving directory
@@ -164,21 +168,19 @@ config = gemma2_27b_pretrain_config(
164168
```bash
165169
torchrun --nproc-per-node=8 run/run_recipe.py \
166170
--pretrained-checkpoint /models/gemma-2-2b \
167-
--recipe gemma2_2b_finetune_config \
168-
--peft none \
171+
--recipe gemma2_2b_sft_config \
169172
train.global_batch_size=64 \
170173
train.train_iters=1000 \
171174
checkpoint.save=$SAVE_DIR/gemma2_2b_finetune
172175
```
173176

174177
Or programmatically:
175178
```python
176-
from megatron.bridge.recipes.gemma import gemma2_2b_finetune_config
179+
from megatron.bridge.recipes.gemma import gemma2_2b_sft_config
177180

178-
config = gemma2_2b_finetune_config(
181+
config = gemma2_2b_sft_config(
179182
name="gemma2_2b_full_finetune",
180183
pretrained_checkpoint="/models/gemma-2-2b",
181-
peft="none",
182184
train_iters=1000,
183185
global_batch_size=64,
184186
)
@@ -188,8 +190,7 @@ config = gemma2_2b_finetune_config(
188190
```bash
189191
torchrun --nproc-per-node=8 run/run_recipe.py \
190192
--pretrained-checkpoint /models/gemma-2-9b \
191-
--recipe gemma2_9b_finetune_config \
192-
--peft none \
193+
--recipe gemma2_9b_sft_config \
193194
train.global_batch_size=64 \
194195
train.train_iters=1000 \
195196
checkpoint.save=$SAVE_DIR/gemma2_9b_finetune
@@ -199,8 +200,7 @@ checkpoint.save=$SAVE_DIR/gemma2_9b_finetune
199200
```bash
200201
torchrun --nproc-per-node=16 run/run_recipe.py \
201202
--pretrained-checkpoint /models/gemma-2-27b \
202-
--recipe gemma2_27b_finetune_config \
203-
--peft none \
203+
--recipe gemma2_27b_sft_config \
204204
train.global_batch_size=64 \
205205
train.train_iters=1000 \
206206
checkpoint.save=$SAVE_DIR/gemma2_27b_finetune
@@ -212,50 +212,50 @@ checkpoint.save=$SAVE_DIR/gemma2_27b_finetune
212212
```bash
213213
torchrun --nproc-per-node=8 run/run_recipe.py \
214214
--pretrained-checkpoint /models/gemma-2-2b \
215-
--recipe gemma2_2b_finetune_config \
216-
--peft lora \
215+
--recipe gemma2_2b_peft_config \
216+
--peft_scheme lora \
217217
train.global_batch_size=128 \
218218
checkpoint.save=$SAVE_DIR/gemma2_2b_lora
219219
```
220220

221221
PEFT options:
222-
- `--peft`: Set to `lora` for LoRA or `dora` for DoRA. Set to `none` for full finetuning.
222+
- `--peft_scheme`: Set to `lora` for LoRA or `dora` for DoRA. Use `gemma2_*_sft_config` for full finetuning.
223223

224224
Or programmatically:
225225
```python
226-
from megatron.bridge.recipes.gemma import gemma2_2b_finetune_config
226+
from megatron.bridge.recipes.gemma import gemma2_2b_peft_config
227227

228228
# LoRA finetuning
229-
config = gemma2_2b_finetune_config(
229+
config = gemma2_2b_peft_config(
230230
name="gemma2_2b_lora_finetune",
231231
pretrained_checkpoint="/models/gemma-2-2b",
232-
peft="lora", # or "dora"
232+
peft_scheme="lora", # or "dora"
233233
train_iters=1000,
234234
global_batch_size=128,
235235
)
236236
```
237237

238238
#### Gemma 2 9B LoRA
239239
```python
240-
from megatron.bridge.recipes.gemma import gemma2_9b_finetune_config
240+
from megatron.bridge.recipes.gemma import gemma2_9b_peft_config
241241

242-
config = gemma2_9b_finetune_config(
242+
config = gemma2_9b_peft_config(
243243
name="gemma2_9b_lora_finetune",
244244
pretrained_checkpoint="/models/gemma-2-9b",
245-
peft="lora",
245+
peft_scheme="lora",
246246
train_iters=1000,
247247
global_batch_size=128,
248248
)
249249
```
250250

251251
#### Gemma 2 27B LoRA
252252
```python
253-
from megatron.bridge.recipes.gemma import gemma2_27b_finetune_config
253+
from megatron.bridge.recipes.gemma import gemma2_27b_peft_config
254254

255-
config = gemma2_27b_finetune_config(
255+
config = gemma2_27b_peft_config(
256256
name="gemma2_27b_lora_finetune",
257257
pretrained_checkpoint="/models/gemma-2-27b",
258-
peft="lora",
258+
peft_scheme="lora",
259259
train_iters=1000,
260260
global_batch_size=128,
261261
)

0 commit comments

Comments
 (0)