Skip to content

Commit 38eb807

Browse files
committed
fix(gemma4): finalize 27B MoE LoRA recipe (released install form, accurate transformers/MoE notes)
1 parent c6769b0 commit 38eb807

3 files changed

Lines changed: 13 additions & 14 deletions

File tree

configs/recipes/gemma4/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,5 @@ oumi launch up -c oumi://configs/recipes/gemma4/sft/e4b_lora/gcp_job.yaml --clus
6969
To launch Gemma 4 27B (MoE) LoRA training on a remote GCP 8x A100 cluster:
7070

7171
```shell
72-
oumi launch up -c configs/recipes/gemma4/sft/27b_lora/gcp_job.yaml --cluster gemma4-27b-lora
72+
oumi launch up -c oumi://configs/recipes/gemma4/sft/27b_lora/gcp_job.yaml --cluster gemma4-27b-lora
7373
```

configs/recipes/gemma4/sft/27b_lora/gcp_job.yaml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
# Job config to LoRA tune Gemma 4 27B (Mixture-of-Experts).
22
#
3-
# NOTE: This recipe installs Oumi in EDITABLE mode from the synced working dir
4-
# (`-e '.[gpu]'`) and runs the LOCAL config path (no `oumi://` prefix). This is
5-
# required while the Gemma 4 27B recipe and the `lora_exclude_modules` feature
6-
# are pre-release and not yet on `main`.
7-
#
83
# Requirements:
94
# - Set up SkyPilot GCP: https://oumi.ai/docs/en/latest/user_guides/launch/launch.html#setup
105
# - apache-2.0 license, no gating: https://huggingface.co/google/gemma-4-26B-A4B-it
116
# - Log into WandB (`wandb login`) or disable `enable_wandb`
127
#
138
# Usage:
14-
# oumi launch up -c configs/recipes/gemma4/sft/27b_lora/gcp_job.yaml --cluster gemma4-27b-lora
9+
# oumi launch up -c oumi://configs/recipes/gemma4/sft/27b_lora/gcp_job.yaml --cluster gemma4-27b-lora
1510
#
1611
# See Also:
1712
# - Documentation: https://oumi.ai/docs/en/latest/user_guides/launch/launch.html
@@ -24,8 +19,7 @@ name: gemma4-27b-lora
2419
resources:
2520
cloud: gcp
2621
accelerators: "A100:8"
27-
use_spot: true
28-
region: europe-west4 # 40GB A100s available here with abundant spot quota.
22+
use_spot: false
2923
disk_size: 500 # Disk size in GBs
3024

3125
working_dir: .
@@ -39,15 +33,15 @@ envs:
3933

4034
setup: |
4135
set -e
42-
pip install uv && SETUPTOOLS_SCM_PRETEND_VERSION_FOR_OUMI=0.0.0.dev0 uv pip install --system -e '.[gpu]' hf_transfer
36+
pip install uv && uv pip install --system oumi[gpu] hf_transfer
4337
4438
run: |
4539
set -e # Exit if any command failed.
4640
source ./configs/examples/misc/sky_init.sh
4741
4842
set -x
4943
oumi distributed torchrun -m oumi train \
50-
-c configs/recipes/gemma4/sft/27b_lora/train.yaml \
44+
-c oumi://configs/recipes/gemma4/sft/27b_lora/train.yaml \
5145
--training.run_name "${OUMI_RUN_NAME}.${SKYPILOT_TASK_ID}"
5246
5347
echo "Node ${SKYPILOT_NODE_RANK} is all done!"

configs/recipes/gemma4/sft/27b_lora/train.yaml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
# - LoRA is scoped to the text transformer only. The vision tower and the
88
# multimodal projector are excluded via `lora_exclude_modules` below; they
99
# share projection-like names with the text model but PEFT cannot adapt them.
10-
# The standard projection targets suffix-match the expert MLPs; the MoE
11-
# router ("gate") is left untouched.
10+
# NOTE: on this MoE the standard gate_proj/up_proj/down_proj names do not
11+
# match the (fused) expert MLP modules, so LoRA adapts only the attention
12+
# projections (~9.3M params). Adapting the experts needs their module names.
1213
#
1314
# Requirements:
14-
# - transformers >= 5.10.0
15+
# - transformers >= 5.5.4
1516
# - peft (installed automatically with oumi)
1617
# - apache-2.0 license, no gating: https://huggingface.co/google/gemma-4-26B-A4B-it
1718
# - Log into WandB (`wandb login`) or disable `enable_wandb`
@@ -44,6 +45,10 @@ training:
4445
save_final_model: true
4546
num_train_epochs: 1
4647
per_device_train_batch_size: 1
48+
# NOTE: gradient accumulation inflates reported loss for Gemma 4 (~4x) due
49+
# to a missing `accepts_loss_kwargs = False` on Gemma4ForConditionalGeneration.
50+
# Fixed on transformers main but not yet released as of 5.5.4. See
51+
# huggingface/transformers#40564 (same bug existed in Gemma 3).
4752
gradient_accumulation_steps: 8
4853
max_grad_norm: 1.0
4954

0 commit comments

Comments
 (0)