Skip to content

Commit 30f8fdb

Browse files
committed
Merge branch 'yuya/perf/cuda-graph-memory' into yuya/perf/moe-paged-stash
Signed-off-by: yaoyu-33 <yaoyu.094@gmail.com> # Conflicts: # tests/unit_tests/moe/test_backend_config.py
2 parents 304de5f + deab038 commit 30f8fdb

560 files changed

Lines changed: 34107 additions & 7950 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.

.agents/contributor-skills/build-and-dependency/SKILL.md

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -84,21 +84,27 @@ The media extras (`vlm-media`, `diffusion-media`, `media`) bundle FFmpeg and are
8484
deliberately **excluded from `all`** and from the container image — add them
8585
explicitly for video/image decode.
8686

87-
### Option 3: pip
87+
### Option 3: uv pip
8888

8989
Full install (matches `uv sync --extra all`):
9090

9191
```bash
92-
pip install -e ".[all]"
92+
uv venv
93+
source .venv/bin/activate
94+
uv pip install -e ".[all]"
9395
```
9496

95-
Login-node / submitter-only install — lightweight package for SLURM, k8s, or
96-
NeMo-Run job submission without local CUDA deps:
97+
To add NeMo Run submission support to the base package:
9798

9899
```bash
99-
pip install nemo-automodel[cli]
100+
uv venv
101+
source .venv/bin/activate
102+
uv pip install "nemo-automodel[cli]"
100103
```
101104

105+
The `cli` extra is additive: it adds `nemo-run` but does not remove the base
106+
package's core training dependencies, including PyTorch.
107+
102108
## Package Management
103109

104110
Always use `uv`. Do not introduce `pip install` commands in scripts or docs.
@@ -120,31 +126,20 @@ export HF_HOME="/path/to/hf_cache" # Hugging Face cache directory
120126

121127
## CLI Usage
122128

123-
The entry point is `automodel` (defined at `nemo_automodel._cli.app:main`).
129+
The entry point is `automodel` (defined at `nemo_automodel.cli.app:main`).
124130

125-
Pattern: `automodel <command> <domain> -c <config.yaml>`
131+
Pattern: `uv run automodel <config.yaml> [--nproc-per-node N] [--key.subkey value ...]`
126132

127133
```bash
128-
# LLM
129-
automodel finetune llm -c examples/llm_finetune/llama3_2/llama3_2_1b_squad.yaml
130-
automodel pretrain llm -c config.yaml
131-
automodel kd llm -c config.yaml
132-
automodel benchmark llm -c config.yaml
133-
134-
# VLM
135-
automodel finetune vlm -c config.yaml
136-
137-
# Diffusion
138-
automodel finetune diffusion -c config.yaml
139-
140-
# Retrieval
141-
automodel finetune retrieval -c config.yaml
134+
# The YAML's recipe field selects LLM, VLM, diffusion, or retrieval behavior.
135+
uv run automodel examples/llm_finetune/llama3_2/llama3_2_1b_squad.yaml --nproc-per-node 8
142136
```
143137

144138
Override any config value from the CLI:
145139

146140
```bash
147-
automodel finetune llm -c config.yaml --model.name_or_path meta-llama/Llama-3.2-1B
141+
uv run automodel examples/llm_finetune/llama3_2/llama3_2_1b_squad.yaml \
142+
--model.pretrained_model_name_or_path meta-llama/Llama-3.2-1B
148143
```
149144

150145
## Common Pitfalls

.github/workflows/cicd-main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,8 @@ jobs:
687687
verbose: true
688688
flags: ${{ matrix.flag }}
689689
base_sha: ${{ fromJSON(steps.get-pr-info.outputs.pr-info || '{}').base.sha }}
690+
override_pr: ${{ fromJSON(steps.get-pr-info.outputs.pr-info || '{}').number }}
691+
override_commit: ${{ fromJSON(steps.get-pr-info.outputs.pr-info || '{}').head.sha }}
690692

691693
- name: Upload artifacts
692694
uses: actions/upload-artifact@v6

.github/workflows/claude-review.yml

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ permissions:
1212

1313
jobs:
1414
claude-review:
15-
uses: NVIDIA-NeMo/FW-CI-templates/.github/workflows/_claude_review.yml@v1.7.0
15+
uses: NVIDIA-NeMo/FW-CI-templates/.github/workflows/_claude_review.yml@209ac7913b0419a5ccbac47b02d00fbea4939243 #v1.8.4
1616
with:
1717
model: ${{ vars.CLAUDE_MODEL }}
1818
prompt: |
@@ -107,6 +107,16 @@ jobs:
107107
- ambiguous public signatures: boolean-trap parameters, multiple
108108
same-typed positional runtime arguments that should be keyword-only,
109109
or long anonymous tuple returns that need a named typed result.
110+
- Model-specific ownership is mandatory. Model-specific logic may live
111+
only under `nemo_automodel/components/models/<model>/`. Treat logic as
112+
model-specific when it names or branches on a model or family, hard-codes
113+
its module/parameter paths or weight layout, or implements its
114+
architecture, initialization, or parallelization policy. If changed code
115+
adds or expands such logic anywhere else, including another directory
116+
under `nemo_automodel/components/` or a recipe, report a critical finding
117+
and require relocation to the owning model package. Shared components may
118+
expose generic typed contracts and invoke model-owned hooks, but must not
119+
encode model identities or model-specific policy.
110120
- Tensor contract docstrings. For every new function or method, or any
111121
function/method whose signature or tensor-handling body is materially
112122
changed, that accepts a tensor input, require its docstring to document
@@ -118,12 +128,20 @@ jobs:
118128
`nn.Parameter`, optional tensors, variadic tensors, and tensors nested in
119129
tuples/lists/mappings/dataclasses as tensor inputs. Require the Google-style
120130
`Args` section and, when values are returned, `Returns` section to document:
121-
- every tensor input and output's semantic shape and axis order, with
122-
symbolic dimensions defined at first use (for example, `B` = batch, `S`
123-
= sequence, `H` = hidden). Flag vague descriptions such as "embedding
124-
tensor" or unexplained `[B, S, H]` notation. If arbitrary ranks or
125-
leading dimensions are accepted, state that explicitly and identify the
126-
constrained axes (for example, `[..., H]` with `H` = hidden size);
131+
- every tensor input and output's semantic shape and axis order. Follow
132+
the common format `hidden_states: Tensor of shape [batch, sequence,
133+
hidden].` Use clear, conventional dimension names such as `batch`,
134+
`sequence`, `tokens`, `hidden`, `heads`, `channels`, and `vocab` without
135+
explaining them. Define non-obvious or model-specific dimension names at
136+
first use. Flag vague descriptions such as "embedding tensor" or
137+
layouts that do not follow this format. If arbitrary ranks or leading
138+
dimensions are accepted, state that explicitly and identify the
139+
constrained axes (for example, `hidden_states: Tensor of shape [...,
140+
hidden], with arbitrary leading dimensions.`). When reporting a layout
141+
documentation finding, include a concrete compliant rewrite in the
142+
review; for example, `fused_qkv: Tensor of shape [batch, sequence, 3,
143+
heads, head_dim], where axis 2 stores query, key, and value in that
144+
order.`;
127145
- nonstandard logical layout such as packed, padded, ragged, flattened,
128146
interleaved, fused-QKV/GateUp, THD, or channels-first/channels-last, and
129147
the before/after layout when the API transforms it;
@@ -163,6 +181,29 @@ jobs:
163181
that class's nested `ModelCapabilities` dataclass (static pattern) or
164182
inside the `get_capabilities(cls, config)` classmethod (dynamic
165183
dispatch pattern).
184+
- Checkpoint-free model initialization. When a PR adds or materially
185+
changes model parameters, persistent buffers, initialization methods,
186+
routing state, or a random-init recipe path, verify that construction
187+
followed by the production initialization path leaves every tensor that
188+
can affect the first forward/backward in a valid state without loading a
189+
checkpoint:
190+
- flag parameters or persistent buffers allocated with `torch.empty`, or
191+
initialized to sentinel/placeholder values, unless every supported
192+
model variant and stage (including auxiliary heads and MTP blocks)
193+
overwrites them before use. A later checkpoint load is not a substitute
194+
when checkpoint-free or random-init training is supported;
195+
- require routing/index tables to satisfy the downstream dispatcher's
196+
structural invariants before first use: indices must be in range and,
197+
when the dispatcher requires it (for example DeepEP top-k routing),
198+
expert IDs for each token must be distinct. An all-zero placeholder is
199+
valid only when it satisfies the actual routing contract;
200+
- require a focused test that disables checkpoint/base-model loading,
201+
invokes the production initializer, and asserts finite initialized
202+
parameters plus the relevant buffer/routing invariants. When this state
203+
affects execution or gradients, also require a finite first
204+
forward/backward on the smallest representative backend/topology; apply
205+
the distributed test matrix below when a single-process backend cannot
206+
exercise the contract.
166207
- Low-precision dtype hazards in RoPE / precision-sensitive buffers. Flag
167208
when a module registers a floating-point buffer used to build rotary
168209
tables — `inv_freq`, `freqs_cis`, or precomputed `cos`/`sin` — and the

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,8 @@ uv venv
198198
# Choose ONE:
199199
uv sync --frozen # LLM recipes (default)
200200
# uv sync --frozen --extra vlm --extra vlm-media # VLM recipes (Qwen/Mistral/Omni need vlm-media for video/vision; fixes: ImportError: qwen_vl_utils is not installed)
201-
# uv sync --frozen --extra cuda # Optional CUDA deps (e.g., Transformer Engine, bitsandbytes)
201+
# uv sync --frozen --extra cuda # Optional CUDA deps (e.g., Transformer Engine, Mamba SSM)
202+
# uv sync --frozen --extra cuda_source # Optional bitsandbytes dependency
202203
# uv sync --frozen --extra all # Most optional deps (includes `vlm` and `cuda`; NOTE: excludes media — add --extra media for video/image decode)
203204
# uv sync --frozen --all-extras # Everything (includes `fa`, `moe`, `media`, etc.)
204205

@@ -224,7 +225,7 @@ uv run automodel examples/llm_finetune/llama3_2/llama3_2_1b_hellaswag.yaml --npr
224225
```
225226

226227
> [!TIP]
227-
> **Login-node / CI installs:** If you only need to submit jobs (SLURM, k8s, NeMo-Run) and don't need to train locally, install the lightweight CLI package: `pip install nemo-automodel[cli]`
228+
> **NeMo-Run submission:** The `cli` extra adds NeMo Run to the base package: `uv pip install "nemo-automodel[cli]"`. It is additive; the base package still installs its core training dependencies, including PyTorch.
228229
229230

230231
## LLM Pre-training

0 commit comments

Comments
 (0)