Skip to content

Commit d0ecda2

Browse files
author
Yunchao Yang
committed
[gemma4] Address PR review: hg:// 12B cards, Literal audio_mode, drop getattr
- Point gemma4_12b{,_it} cards at hg://google/gemma-4-12B{,-it} instead of the internal /checkpoint/smallomnillm path so the OSS cards don't leak cluster-only paths. - Type Gemma4AudioConfig.audio_mode as Literal["conformer", "linear"] — the only two supported pipelines — for static checking. - Drop defensive getattr(config.audio_config, "audio_mode", ...) calls in Gemma4Factory; audio_mode is a proper dataclass field with a default, no BC story to preserve.
1 parent 3e060e1 commit d0ecda2

3 files changed

Lines changed: 8 additions & 9 deletions

File tree

src/fairseq2/assets/cards/models/gemma4.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,15 @@ tokenizer_family: gemma4
7979
name: gemma4_12b
8080
model_family: gemma4
8181
model_arch: 12b
82-
checkpoint: "file:///checkpoint/smallomnillm/shared/models/gemma-4-12B"
83-
tokenizer: "file:///checkpoint/smallomnillm/shared/models/gemma-4-12B"
82+
checkpoint: "hg://google/gemma-4-12B"
83+
tokenizer: "hg://google/gemma-4-12B"
8484
tokenizer_family: gemma4
8585

8686
---
8787

8888
name: gemma4_12b_it
8989
model_family: gemma4
9090
model_arch: 12b_it
91-
checkpoint: "file:///checkpoint/smallomnillm/shared/models/gemma-4-12B-it"
92-
tokenizer: "file:///checkpoint/smallomnillm/shared/models/gemma-4-12B-it"
91+
checkpoint: "hg://google/gemma-4-12B-it"
92+
tokenizer: "hg://google/gemma-4-12B-it"
9393
tokenizer_family: gemma4

src/fairseq2/models/gemma4/audio/config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from __future__ import annotations
88

99
from dataclasses import dataclass
10+
from typing import Literal
1011

1112

1213
@dataclass(kw_only=True)
@@ -29,7 +30,7 @@ class Gemma4AudioConfig:
2930
and ``rms_norm_eps`` are read.
3031
"""
3132

32-
audio_mode: str = "conformer"
33+
audio_mode: Literal["conformer", "linear"] = "conformer"
3334
"""Audio pipeline selector: ``"conformer"`` or ``"linear"``."""
3435

3536
hidden_size: int = 1024

src/fairseq2/models/gemma4/factory.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ def create_audio_tower(self) -> Module | None:
541541
return None
542542

543543
# Unified family: no tower; embedder consumes raw waveform frames.
544-
if getattr(config.audio_config, "audio_mode", "conformer") == "linear":
544+
if config.audio_config.audio_mode == "linear":
545545
return None
546546

547547
from fairseq2.models.gemma4.audio.tower import Gemma4AudioTower
@@ -571,9 +571,7 @@ def create_audio_embedder(self) -> Module | None:
571571
# behaviour where the embedder casts raw inputs to its weight dtype
572572
# before the norm. The classic conformer path does not need this
573573
# (its inputs come from the audio tower already in the right dtype).
574-
cast_input_dtype = (
575-
getattr(config.audio_config, "audio_mode", "conformer") == "linear"
576-
)
574+
cast_input_dtype = config.audio_config.audio_mode == "linear"
577575

578576
return Gemma4MultimodalAudioEmbedder(
579577
output_proj_dims=config.audio_config.output_proj_dims,

0 commit comments

Comments
 (0)