Skip to content

feat: add Gemma4 support#2224

Draft
sharonyu-115 wants to merge 9 commits intoNVIDIA-NeMo:mainfrom
sharonyu-115:gemma4-support
Draft

feat: add Gemma4 support#2224
sharonyu-115 wants to merge 9 commits intoNVIDIA-NeMo:mainfrom
sharonyu-115:gemma4-support

Conversation

@sharonyu-115
Copy link
Copy Markdown
Contributor

@sharonyu-115 sharonyu-115 commented Apr 7, 2026

What does this PR do ?

To address #2212

Issues

List issues that this PR closes (syntax):

Usage

  • You can potentially add a usage example below
# Add a code snippet demonstrating how to use this

Before your PR is "Ready for review"

Pre checks:

  • Make sure you read and followed Contributor guidelines
  • Did you write any new necessary tests?
  • Did you run the unit tests and functional tests locally? Visit our Testing Guide for how to run tests
  • Did you add or update any necessary documentation? Visit our Document Development Guide for how to write, build and test the docs.

Additional Information

  • ...

sharonyu-115 and others added 2 commits April 7, 2026 01:31
- Register gemma4 in AUTOMODEL_FACTORY (utils.py)
- Add KV sharing support: use_cache=True for models with num_kv_shared_layers > 0 (train.py)
- Freeze visual/audio encoders for text-only training to fix checkpoint resume (setup.py)
- Inject mm_token_type_ids for Gemma4 text-only inputs (train.py, dtensor_policy_worker.py)
- Extend skip_tokenizer_init workaround to Gemma4ForConditionalGeneration (vllm_worker.py)
- Bump transformers 5.3.0 -> 5.5.0, vllm 0.17.1 -> 0.19.0 (pyproject.toml)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Shuang Yu <shuangy@nvidia.com>
- grpo-gemma4-e2b-it-1n8g-fsdp2-automodel.yaml: E2B-it on 1 node
- dapo-gemma4-31b-it-4n8g-fsdp2.yaml: 31B-it DAPO with dynamic sampling

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Shuang Yu <shuangy@nvidia.com>
@copy-pr-bot
Copy link
Copy Markdown

copy-pr-bot bot commented Apr 7, 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.

@sharonyu-115
Copy link
Copy Markdown
Contributor Author

/ok to test b3b4d3c

@sharonyu-115 sharonyu-115 added the CI:L1 Run doctests, unit tests, and functional tests label Apr 8, 2026
@zpqiu zpqiu changed the title Gemma4 support feat: add Gemma4 support Apr 8, 2026
@zpqiu zpqiu added CI:L1 Run doctests, unit tests, and functional tests and removed CI:L1 Run doctests, unit tests, and functional tests labels Apr 8, 2026
- Apply ruff-format line wrapping to setup.py, train.py, dtensor_policy_worker.py
- Minimize recipe YAMLs (remove redundant defaults matching base config)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Shuang Yu <shuangy@nvidia.com>
@zpqiu zpqiu added CI:L1 Run doctests, unit tests, and functional tests and removed CI:L1 Run doctests, unit tests, and functional tests labels Apr 8, 2026
@sharonyu-115 sharonyu-115 added CI:L1 Run doctests, unit tests, and functional tests and removed CI:L1 Run doctests, unit tests, and functional tests labels Apr 8, 2026
@zpqiu zpqiu marked this pull request as ready for review April 8, 2026 05:36
@zpqiu zpqiu requested review from a team as code owners April 8, 2026 05:36
@zpqiu zpqiu added CI:L1 Run doctests, unit tests, and functional tests and removed CI:L1 Run doctests, unit tests, and functional tests labels Apr 8, 2026
@zpqiu zpqiu marked this pull request as draft April 8, 2026 05:37
@zpqiu
Copy link
Copy Markdown
Contributor

zpqiu commented Apr 8, 2026

/ok to test 360cb8a

Regenerated lockfile to match pyproject.toml dependency bumps.
Required for CI build container (uv sync --locked).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Shuang Yu <shuangy@nvidia.com>
@sharonyu-115
Copy link
Copy Markdown
Contributor Author

/ok to test 7353904

Regenerated with pinned Automodel submodule (92635e74) in
CI base image (cuda-dl-base:25.05) to match CI's uv sync --locked.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Shuang Yu <shuangy@nvidia.com>
@sharonyu-115
Copy link
Copy Markdown
Contributor Author

/ok to test e90e80c

@sharonyu-115
Copy link
Copy Markdown
Contributor Author

/ok to test 04fc41c

@sharonyu-115
Copy link
Copy Markdown
Contributor Author

/ok to test 9d9fd36

sharonyu-115 and others added 4 commits April 9, 2026 20:14
Update Automodel submodule from 92635e74 to 3a3f6858 (latest main).
Fixes CI test_automodel_types.py TypeError caused by check_model_inputs
API change in transformers 5.5.0. Regenerate uv.lock.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Shuang Yu <shuangy@nvidia.com>
vLLM 0.19.0 refactored chat preprocessing from OpenAIServingChat into a
new OpenAIServingRender service class. This broke the NeMo-RL HTTP server
in two ways: (1) OpenAIServingChat/Tokenization now require an
openai_serving_render constructor arg, and (2) the _preprocess_chat method
override was silently dead since it moved to OpenAIServingRender.

Move the prefix-token replacement logic into a NeMoRLOpenAIServingRender
subclass that overrides preprocess_chat, and pass it to both serving classes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Shuang Yu <shuangy@nvidia.com>
Add missing test suite scripts for the two new Gemma 4 recipe configs
to fix the test_all_recipe_yamls_accounted_for_in_test_suites CI check.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Shuang Yu <shuangy@nvidia.com>
Temporarily remove --exitfirst (-x) from pytest addopts so CI runs
all tests instead of stopping at the first failure.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Shuang Yu <shuangy@nvidia.com>
@sharonyu-115
Copy link
Copy Markdown
Contributor Author

/ok to test 23e1d27

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI:L1 Run doctests, unit tests, and functional tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants