Skip to content

feat(models): register gemma4_unified_text text-only GPTQ definition#2925

Merged
Qubitium merged 1 commit into
ModelCloud:mainfrom
Anai-Guo:feat/gemma4-unified-text-support
Jun 19, 2026
Merged

feat(models): register gemma4_unified_text text-only GPTQ definition#2925
Qubitium merged 1 commit into
ModelCloud:mainfrom
Anai-Guo:feat/gemma4-unified-text-support

Conversation

@Anai-Guo

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #2921 (which added the composite gemma4_unified). The gemma4_unified family also exposes a standalone text stackmodel_type = "gemma4_unified_text" (Gemma4UnifiedTextModel), registered in transformers (src/transformers/models/auto/auto_mappings.py / modeling_auto.py) — exactly mirroring how gemma4_text parallels gemma4.

MODEL_MAP currently has gemma4_text, gemma4, and gemma4_unified but not gemma4_unified_text, so a text-only unified checkpoint still fails with:

ValueError: Unsupport model_type gemma4_unified_text, and failed to auto-detect module tree for model

What this does

  • Extracts the shared Gemma 4 unified decoder layout into _GEMMA4_UNIFIED_DECODER (no behavior change for the composite definition).
  • Adds Gemma4UnifiedTextQModel, rooted at model.layers with model.norm / model.rotary_emb (the standalone text-model layout, no language_model nesting), reusing the same per-layer-type rope replay helper as the composite variant.
  • Registers "gemma4_unified_text" in MODEL_MAP.

The quantizable layout is identical to the composite (q/k/v/o_proj + gate/up/down_proj, with q/k/v_norm and the four sandwich norms non-quantized); only the module-tree root and norm/rotary paths differ, just as Gemma4TextQModel differs from Gemma4ForConditionalGenerationGPTQ.

Test plan

  • auto.check_and_get_model_definition(<gemma4_unified_text ckpt>) returns Gemma4UnifiedTextQModel.
  • End-to-end 4-bit quantization of a text-only gemma4_unified_text checkpoint.

I don't have local access to a gemma4_unified_text checkpoint to run the full quantization, so maintainer validation on real hardware is appreciated. The definition deliberately mirrors the merged (tested) composite gemma4_unified pattern.

cc @Qubitium — this is the "additional patching" for the text-only variant you asked about in #2922.

🤖 Generated with Claude Code

The gemma4_unified family also has a standalone text stack (model_type
"gemma4_unified_text", Gemma4UnifiedTextModel) registered in transformers,
mirroring how gemma4_text parallels gemma4. ModelCloud#2921 added the composite
gemma4_unified but not the text-only variant, so a text-only checkpoint
still fails with "Unsupport model_type gemma4_unified_text".

This extracts the shared decoder layout into a constant and adds
Gemma4UnifiedTextQModel rooted at model.layers (model.norm /
model.rotary_emb), reusing the same per-layer rope replay helper.
@Qubitium Qubitium merged commit 7c5724c into ModelCloud:main Jun 19, 2026
@Qubitium

Copy link
Copy Markdown
Collaborator

@Anai-Guo LGTM. Thank you!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants