Skip to content

google/gemma-4-26B-A4B-it fails to load: layer-prefix parsing breaks on nested "language_model" submodule #345

Description

@nureliosman

Hello,

AirLLM fails to load google/gemma-4-26B-A4B-it (a VLM: vision tower + nested language_model + MoE experts).

Command:
model = AutoModel.from_pretrained("google/gemma-4-26B-A4B-it", compression="4bit")

Output:
using generic AirLLM streaming model for architecture: Gemma4ForConditionalGeneration
ValueError: invalid literal for int() with base 10: 'layers'

Root cause: the model's safetensors index uses nested keys like:
model.language_model.layers.0.experts.down_proj
model.language_model.layers.0.experts.gate_up_proj
model.vision_tower.encoder.layers...

instead of the flat model.layers.N... naming the generic streaming path (airllm/utils.py, split_and_save_layers, line ~284) assumes:
n_layers = len(set([int(k[len(layer_names['layer_prefix']):].split('.')[1]) for k in index.keys() if layer_names['layer_prefix'] in k]))

This regex/parsing logic breaks for any architecture with a nested language_model submodule (VLM-style models) and doesn't handle fused MoE expert tensors (experts.down_proj, experts.gate_up_proj).

Environment: airllm (latest via pip), Windows, Python 3.14, bitsandbytes 0.50.1

BR!

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions