Skip to content

fix: change default batch sizes for dp workloads - #528

Merged
binaryaaron merged 4 commits into
mainfrom
binaryaaron/transformers-v5-oom-batch-size-fix
May 28, 2026
Merged

fix: change default batch sizes for dp workloads#528
binaryaaron merged 4 commits into
mainfrom
binaryaaron/transformers-v5-oom-batch-size-fix

Conversation

@binaryaaron

@binaryaaron binaryaaron commented May 27, 2026

Copy link
Copy Markdown
Collaborator

followup from #483 - there's a regression in memory performance in transformers v5. this is the minimal fix for our specific workloads; I'll put up a more comprehensive change that should help with observability and memory pressure during training after this.

Summary

This PR lowers the physical microbatch size used by the DP run configs from 8 to 4 and raises gradient_accumulation_steps to 16.

The effective batch size stays at 64, but each forward/backward pass uses fewer examples. This is the minimal fix for the recent larger-model DP OOMs without changing the shared training defaults for non-DP runs.

Why

DP training is not inherently constrained to batch_size: 1, but larger physical batches increase activation and per-sample-gradient memory. The prior DP configs used batch_size: 8 with the global default accumulation of 8. Moving to 4 x 16 preserves optimizer-step batch semantics while reducing peak memory pressure.

Changes

  • Update DP SLURM configs to use:
    • training.batch_size: 4
    • training.gradient_accumulation_steps: 16
  • Update required e2e DP configs to match the new DP run shape.

Test Plan

  • make check
  • slurm run (will report back)

Summary by CodeRabbit

  • Chores
    • Reduced per-device training batch sizes across distributed-parallel configs (mostly 8→4; one model adjusted to 2).
    • Standardized/added gradient accumulation to 16 across DP training configs to preserve effective batch size.
    • Result: improved memory efficiency and more balanced resource use for distributed training runs.

Review Change Stack

@binaryaaron
binaryaaron requested review from a team as code owners May 27, 2026 16:17
@binaryaaron binaryaaron changed the title chore: change default batch sizes fix: change default batch sizes for dp workloads May 27, 2026
@coderabbitai

coderabbitai Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: c49b914a-850c-4100-9f83-a3c52b9303b5

📥 Commits

Reviewing files that changed from the base of the PR and between f535cb6 and 972d223.

📒 Files selected for processing (1)
  • tests/e2e/required_configs/mistral-dp.yaml
✅ Files skipped from review due to trivial changes (1)
  • tests/e2e/required_configs/mistral-dp.yaml
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: Unit Tests (3.12)
  • GitHub Check: Unit Tests (3.13)
  • GitHub Check: Unit Tests (3.11)
  • GitHub Check: Smoke Tests
  • GitHub Check: Typecheck
  • GitHub Check: Analyze (Python)
  • GitHub Check: Analyze (python)
  • GitHub Check: Analyze (javascript-typescript)

Walkthrough

Updated DP training batch sizes and added/retained training.gradient_accumulation_steps=16 across SLURM job configs and corresponding E2E required test fixtures (Mistral: batch_size 8→2; TinyLlama & SmolLM3: batch_size 8→4).

Changes

DP Training Batch Size Adjustments

Layer / File(s) Summary
SLURM DP config updates
script/slurm/configs/mistral-dp.yaml, script/slurm/configs/tinyllama-dp.yaml, script/slurm/configs/smollm3-dp.yaml
Mistral SLURM DP training.batch_size changed 8 → 2. TinyLlama and SmolLM3 SLURM DP training.batch_size changed 8 → 4. training.gradient_accumulation_steps set or retained at 16.
E2E required configs updates
tests/e2e/required_configs/mistral-dp.yaml, tests/e2e/required_configs/smollm3-dp.yaml, tests/e2e/required_configs/tinyllama-dp.yaml
E2E fixtures updated: Mistral training.batch_size set to 2; TinyLlama and SmolLM3 training.batch_size set to 4; training.gradient_accumulation_steps: 16 added/retained.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

config tests

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: change default batch sizes for dp workloads' directly and clearly summarizes the main change: adjusting batch sizes in DP (data-parallel) training configurations.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch binaryaaron/transformers-v5-oom-batch-size-fix

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

@coderabbitai coderabbitai Bot added the chore Maintenance not tied to a user-visible change label May 27, 2026
@greptile-apps

greptile-apps Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR reduces the physical microbatch size for all three DP SLURM configs (Mistral-7B, SmolLM3-3B, TinyLlama) and adds explicit gradient_accumulation_steps: 16 to preserve the effective batch size at 64 — a targeted fix for the transformers v5 memory regression. The e2e required configs are updated to match.

  • smollm3 and tinyllama: batch_size 8→4, gradient_accumulation_steps default(8)→16, effective batch stays at 64 ✓
  • mistral: batch_size 8→2, gradient_accumulation_steps default(8)→16, effective batch drops from 64 to 32 — inconsistent with the stated goal and the other two models

Confidence Score: 4/5

Safe to merge for smollm3 and tinyllama; the Mistral config silently halves the effective batch size from 64 to 32, contradicting the PR's stated invariant.

Two of the three model configs correctly preserve effective batch size at 64. The Mistral config uses batch_size: 2 instead of 4, yielding 2x16=32, not 64 as stated. This affects both the SLURM run config and the e2e required config and needs resolution before merging.

script/slurm/configs/mistral-dp.yaml and tests/e2e/required_configs/mistral-dp.yaml — both use batch_size: 2, giving an effective batch size of 32 instead of 64.

Important Files Changed

Filename Overview
script/slurm/configs/mistral-dp.yaml batch_size lowered to 2 (not 4 like the other models), giving effective batch size 32 instead of the stated 64 — contradicts PR intent.
script/slurm/configs/smollm3-dp.yaml batch_size 4 × gradient_accumulation_steps 16 = 64 effective batch size — correct and matches stated intent.
script/slurm/configs/tinyllama-dp.yaml batch_size 4 × gradient_accumulation_steps 16 = 64 effective batch size — correct and matches stated intent.
tests/e2e/required_configs/mistral-dp.yaml Mirrors the SLURM config with batch_size 2, giving effective batch size 32 — same discrepancy as the SLURM config.
tests/e2e/required_configs/smollm3-dp.yaml batch_size 4 × gradient_accumulation_steps 16 = 64 — correct and consistent with SLURM config.
tests/e2e/required_configs/tinyllama-dp.yaml batch_size 4 × gradient_accumulation_steps 16 = 64 — correct and consistent with SLURM config.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[DP Training Config] --> B{Model}
    B --> C[SmolLM3-3B]
    B --> D[TinyLlama-1.1B]
    B --> E[Mistral-7B]
    C --> C1["batch_size: 4\ngrad_accum: 16\nEffective: 64"]
    D --> D1["batch_size: 4\ngrad_accum: 16\nEffective: 64"]
    E --> E1["batch_size: 2\ngrad_accum: 16\nEffective: 32"]
    style E1 fill:#ffcccc
Loading

Reviews (4): Last reviewed commit: "fix: udpate mistral-dp e2e" | Re-trigger Greptile

@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: 3


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 193f104c-9a00-4f3a-a58a-0bbc68157478

📥 Commits

Reviewing files that changed from the base of the PR and between a811d20 and e53acab.

📒 Files selected for processing (6)
  • script/slurm/configs/mistral-dp.yaml
  • script/slurm/configs/smollm3-dp.yaml
  • script/slurm/configs/tinyllama-dp.yaml
  • tests/e2e/required_configs/mistral-dp.yaml
  • tests/e2e/required_configs/smollm3-dp.yaml
  • tests/e2e/required_configs/tinyllama-dp.yaml
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: Smoke Tests
  • GitHub Check: Unit Tests (3.11)
  • GitHub Check: Unit Tests (3.12)
  • GitHub Check: Unit Tests (3.13)
  • GitHub Check: Analyze (Python)
  • GitHub Check: Typecheck
  • GitHub Check: Analyze (python)
  • GitHub Check: Analyze (javascript-typescript)
🧰 Additional context used
📓 Path-based instructions (6)
**/*.yaml

📄 CodeRabbit inference engine (STYLE_GUIDE.md)

**/*.yaml: Use 2-space indentation in YAML files.
Use colon-space (: ) for key-value pairs in YAML.
Include SPDX copyright headers at the top of YAML files.
Use unquoted values in YAML unless special characters require them.
Include a newline at the end of YAML files.

Files:

  • script/slurm/configs/smollm3-dp.yaml
  • script/slurm/configs/tinyllama-dp.yaml
  • script/slurm/configs/mistral-dp.yaml
  • tests/e2e/required_configs/smollm3-dp.yaml
  • tests/e2e/required_configs/tinyllama-dp.yaml
  • tests/e2e/required_configs/mistral-dp.yaml

⚙️ CodeRabbit configuration file

Review YAML for 2-space indentation, SPDX headers when required, unquoted values unless needed, and newline at EOF.

Files:

  • script/slurm/configs/smollm3-dp.yaml
  • script/slurm/configs/tinyllama-dp.yaml
  • script/slurm/configs/mistral-dp.yaml
  • tests/e2e/required_configs/smollm3-dp.yaml
  • tests/e2e/required_configs/tinyllama-dp.yaml
  • tests/e2e/required_configs/mistral-dp.yaml
**/*.{py,sh,yaml,yml}

📄 CodeRabbit inference engine (STYLE_GUIDE.md)

Include SPDX copyright header at the top: # SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. and # SPDX-License-Identifier: Apache-2.0. The make format command handles this automatically.

Files:

  • script/slurm/configs/smollm3-dp.yaml
  • script/slurm/configs/tinyllama-dp.yaml
  • script/slurm/configs/mistral-dp.yaml
  • tests/e2e/required_configs/smollm3-dp.yaml
  • tests/e2e/required_configs/tinyllama-dp.yaml
  • tests/e2e/required_configs/mistral-dp.yaml
**/*

📄 CodeRabbit inference engine (STYLE_GUIDE.md)

**/*: Include a newline at the end of all files, never trailing whitespace. This is enforced by pre-commit.
Use line length of 120 characters for code, comments, and docstrings (configured in ruff.toml).

Files:

  • script/slurm/configs/smollm3-dp.yaml
  • script/slurm/configs/tinyllama-dp.yaml
  • script/slurm/configs/mistral-dp.yaml
  • tests/e2e/required_configs/smollm3-dp.yaml
  • tests/e2e/required_configs/tinyllama-dp.yaml
  • tests/e2e/required_configs/mistral-dp.yaml

⚙️ CodeRabbit configuration file

**/*: Review as a senior maintainer for NeMo Safe Synthesizer. Prioritize issues that can change behavior, break user workflows, weaken privacy guarantees, hide failures, make tests unreliable, or create maintenance risk. Avoid generic style commentary unless it points to a concrete project convention that automated tools will not catch.
Comment only when the finding is actionable and tied to changed code. For each finding, state the impact, the condition that triggers it, and the smallest practical fix. Prefer one precise comment over broad advice. Do not ask for refactors outside the PR scope unless the changed code creates the problem.
Review type guidance: - Potential issue: use for correctness bugs, data loss, privacy leaks,
security risks, broken public APIs, invalid config behavior, missing
validation, hidden failures, nondeterministic tests, or CI breakage.

  • Refactor suggestion: use for local maintainability problems introduced
    by the diff when they have clear future cost, such as duplicated setup,
    unclear boundaries, over-mocking, avoidable complexity, or opaque test
    helpers.
  • Nitpick: avoid in chill mode. Do not emit formatting, import-order,
    wording, or style-only comments unless automated tools cannot catch the
    issue and it affects maintainability.

Severity guidance: - Critical: security/privacy leaks, data loss, training/test/holdout
contamination, or broken release/package/core pipeline execution.

  • Major: incorrect generation/training/evaluation behavior, broken
    CLI/SDK public API, invalid config defaults or validators, or GPU/vLLM
    cleanup and process-isolation bugs likely to fail CI or production
    runs.
  • Minor: localized bugs, missing focused tests for changed behavior, or
    bad test patterns that weaken regression coverage.
  • Trivial: small cleanup with no behavior impact. Usually suppress in
    chill mode.
  • Info: context only. Avoid unless it helps reviewers understand risk.
    Safe-Synthesizer-specific review focus: - Data ...

Files:

  • script/slurm/configs/smollm3-dp.yaml
  • script/slurm/configs/tinyllama-dp.yaml
  • script/slurm/configs/mistral-dp.yaml
  • tests/e2e/required_configs/smollm3-dp.yaml
  • tests/e2e/required_configs/tinyllama-dp.yaml
  • tests/e2e/required_configs/mistral-dp.yaml
**/*.{yaml,yml}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

All YAML files require SPDX copyright headers, automatically added by make format

Files:

  • script/slurm/configs/smollm3-dp.yaml
  • script/slurm/configs/tinyllama-dp.yaml
  • script/slurm/configs/mistral-dp.yaml
  • tests/e2e/required_configs/smollm3-dp.yaml
  • tests/e2e/required_configs/tinyllama-dp.yaml
  • tests/e2e/required_configs/mistral-dp.yaml
script/**

⚙️ CodeRabbit configuration file

Review standalone scripts for reproducibility and operational safety. Check argument validation, quoting, repo-root detection, environment variables, generated artifacts, external commands, GPU/cluster assumptions, and whether the script should be wired through Makefile or documented in README/docs.

Files:

  • script/slurm/configs/smollm3-dp.yaml
  • script/slurm/configs/tinyllama-dp.yaml
  • script/slurm/configs/mistral-dp.yaml
tests/**

📄 CodeRabbit inference engine (.cursor/rules/repo-navigation.mdc)

Tests should mirror the src/ directory structure in tests/

Files:

  • tests/e2e/required_configs/smollm3-dp.yaml
  • tests/e2e/required_configs/tinyllama-dp.yaml
  • tests/e2e/required_configs/mistral-dp.yaml
🔇 Additional comments (3)
script/slurm/configs/mistral-dp.yaml (1)

5-5: LGTM!

script/slurm/configs/smollm3-dp.yaml (1)

5-5: LGTM!

script/slurm/configs/tinyllama-dp.yaml (1)

5-5: LGTM!

Comment thread tests/e2e/required_configs/mistral-dp.yaml Outdated
Comment thread tests/e2e/required_configs/smollm3-dp.yaml Outdated
Comment thread tests/e2e/required_configs/tinyllama-dp.yaml Outdated
Signed-off-by: Aaron Gonzales <aagonzales@nvidia.com>
@binaryaaron
binaryaaron force-pushed the binaryaaron/transformers-v5-oom-batch-size-fix branch from e53acab to 54b6543 Compare May 27, 2026 16:22
@coderabbitai coderabbitai Bot added bug Defects in shipped behavior and removed chore Maintenance not tied to a user-visible change labels May 27, 2026
@greptile-apps

greptile-apps Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor

Want your agent to iterate on Greptile's feedback? Try greploops.

@codecov

codecov Bot commented May 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@NVIDIA-NeMo NVIDIA-NeMo deleted a comment from greptile-apps Bot May 27, 2026

@kendrickb-nvidia kendrickb-nvidia left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approval pending positive outcome from slurm runs

Apply the reduced DP microbatch shape to SmolLM3 and remove the stale TinyLlama comment so Slurm configs consistently use 4 x 16 batching.

Signed-off-by: Aaron Gonzales <aagonzales@nvidia.com>
Signed-off-by: Matthew Kornfield <mkornfield@nvidia.com>

@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


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 053b75c7-101c-49e5-b1fd-7f940040c04d

📥 Commits

Reviewing files that changed from the base of the PR and between f113815 and f535cb6.

📒 Files selected for processing (1)
  • script/slurm/configs/mistral-dp.yaml
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: Smoke Tests
  • GitHub Check: Unit Tests (3.12)
  • GitHub Check: Unit Tests (3.11)
  • GitHub Check: Unit Tests (3.13)
  • GitHub Check: Typecheck
  • GitHub Check: Analyze (Python)
  • GitHub Check: Analyze (python)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.yaml

📄 CodeRabbit inference engine (STYLE_GUIDE.md)

**/*.yaml: Use 2-space indentation in YAML files.
Use colon-space (: ) for key-value pairs in YAML.
Include SPDX copyright headers at the top of YAML files.
Use unquoted values in YAML unless special characters require them.
Include a newline at the end of YAML files.

Files:

  • script/slurm/configs/mistral-dp.yaml

⚙️ CodeRabbit configuration file

Review YAML for 2-space indentation, SPDX headers when required, unquoted values unless needed, and newline at EOF.

Files:

  • script/slurm/configs/mistral-dp.yaml
**/*.{py,sh,yaml,yml}

📄 CodeRabbit inference engine (STYLE_GUIDE.md)

Include SPDX copyright header at the top: # SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. and # SPDX-License-Identifier: Apache-2.0. The make format command handles this automatically.

Files:

  • script/slurm/configs/mistral-dp.yaml
**/*

📄 CodeRabbit inference engine (STYLE_GUIDE.md)

**/*: Include a newline at the end of all files, never trailing whitespace. This is enforced by pre-commit.
Use line length of 120 characters for code, comments, and docstrings (configured in ruff.toml).

Files:

  • script/slurm/configs/mistral-dp.yaml

⚙️ CodeRabbit configuration file

**/*: Review as a senior maintainer for NeMo Safe Synthesizer. Prioritize issues that can change behavior, break user workflows, weaken privacy guarantees, hide failures, make tests unreliable, or create maintenance risk. Avoid generic style commentary unless it points to a concrete project convention that automated tools will not catch.
Comment only when the finding is actionable and tied to changed code. For each finding, state the impact, the condition that triggers it, and the smallest practical fix. Prefer one precise comment over broad advice. Do not ask for refactors outside the PR scope unless the changed code creates the problem.
Review type guidance: - Potential issue: use for correctness bugs, data loss, privacy leaks,
security risks, broken public APIs, invalid config behavior, missing
validation, hidden failures, nondeterministic tests, or CI breakage.

  • Refactor suggestion: use for local maintainability problems introduced
    by the diff when they have clear future cost, such as duplicated setup,
    unclear boundaries, over-mocking, avoidable complexity, or opaque test
    helpers.
  • Nitpick: avoid in chill mode. Do not emit formatting, import-order,
    wording, or style-only comments unless automated tools cannot catch the
    issue and it affects maintainability.

Severity guidance: - Critical: security/privacy leaks, data loss, training/test/holdout
contamination, or broken release/package/core pipeline execution.

  • Major: incorrect generation/training/evaluation behavior, broken
    CLI/SDK public API, invalid config defaults or validators, or GPU/vLLM
    cleanup and process-isolation bugs likely to fail CI or production
    runs.
  • Minor: localized bugs, missing focused tests for changed behavior, or
    bad test patterns that weaken regression coverage.
  • Trivial: small cleanup with no behavior impact. Usually suppress in
    chill mode.
  • Info: context only. Avoid unless it helps reviewers understand risk.
    Safe-Synthesizer-specific review focus: - Data ...

Files:

  • script/slurm/configs/mistral-dp.yaml
**/*.{yaml,yml}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

All YAML files require SPDX copyright headers, automatically added by make format

Files:

  • script/slurm/configs/mistral-dp.yaml
script/**

⚙️ CodeRabbit configuration file

Review standalone scripts for reproducibility and operational safety. Check argument validation, quoting, repo-root detection, environment variables, generated artifacts, external commands, GPU/cluster assumptions, and whether the script should be wired through Makefile or documented in README/docs.

Files:

  • script/slurm/configs/mistral-dp.yaml
🔇 Additional comments (1)
script/slurm/configs/mistral-dp.yaml (1)

1-13: LGTM!

Comment thread script/slurm/configs/mistral-dp.yaml
Comment thread script/slurm/configs/mistral-dp.yaml
Signed-off-by: Aaron Gonzales <aagonzales@nvidia.com>
@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor

Actionable comments posted: 0

Comment thread script/slurm/configs/mistral-dp.yaml
Comment thread tests/e2e/required_configs/mistral-dp.yaml
@binaryaaron
binaryaaron merged commit 3d9f82a into main May 28, 2026
20 checks passed
@binaryaaron
binaryaaron deleted the binaryaaron/transformers-v5-oom-batch-size-fix branch May 28, 2026 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Defects in shipped behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants