Skip to content

Fail to compile Gemma3n model #518

@lehuudoUIT

Description

@lehuudoUIT

Describe the bug:
When attempting to compile Google's Gemma3n model using QEfficient for Qualcomm Cloud AI deployment, I encounter Transformers Version Conflict issue:

  • Gemma3n requires transformers >=4.53.0 (source)
  • QEfficient currently only supports transformers==4.51.3 (as per pyproject.toml)

Steps to Reproduce:

  1. Install QEfficient
  2. Attempt to load Gemma3n model (requires transformers>=4.53.0)
  3. Run compilation:
from QEfficient import QEFFAutoModelForImageTextToText

model_name = "google/gemma-3n-E2B-it"
model = QEFFAutoModelForImageTextToText.from_pretrained(model_name)
model.compile(prefill_seq_len=1024, ctx_len=16384, num_cores=16, num_devices=1, compile_dir ="./qpc_gemma-3n-E2B-it")

Error Logs

Traceback (most recent call last):
  File "/home/user/gemma3n/qefficient/qeff_env/lib/python3.10/site-packages/transformers/models/auto/configuration_auto.py", line 1131, in from_pretrained
    config_class = CONFIG_MAPPING[config_dict["model_type"]]
  File "/home/user/gemma3n/qefficient/qeff_env/lib/python3.10/site-packages/transformers/models/auto/configuration_auto.py", line 833, in __getitem__
    raise KeyError(key)
KeyError: 'gemma3n'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/gemma3n/qefficient/compile-qeff.py", line 4, in <module>
    model = QEFFAutoModelForImageTextToText.from_pretrained(model_name)
  File "/home/user/gemma3n/qefficient/qeff_env/lib/python3.10/site-packages/QEfficient/transformers/quantizers/auto.py", line 64, in wrapper
    out = func(*args, **kwargs)
  File "/home/user/gemma3n/qefficient/qeff_env/lib/python3.10/site-packages/QEfficient/transformers/models/modeling_auto.py", line 1336, in from_pretrained
    model = cls._hf_auto_class.from_pretrained(pretrained_model_name_or_path, **kwargs)
  File "/home/user/gemma3n/qefficient/qeff_env/lib/python3.10/site-packages/transformers/models/auto/auto_factory.py", line 531, in from_pretrained
    config, kwargs = AutoConfig.from_pretrained(
  File "/home/user/gemma3n/qefficient/qeff_env/lib/python3.10/site-packages/transformers/models/auto/configuration_auto.py", line 1133, in from_pretrained
    raise ValueError(
ValueError: The checkpoint you are trying to load has model type `gemma3n` but Transformers does not recognize this architecture. This could be because of an issue with the checkpoint, or because your version of Transformers is out of date.

You can update Transformers with the command `pip install --upgrade transformers`. If this does not work, and the checkpoint is very new, then there may not be a release version that supports this model yet. In this case, you can get the most up-to-date code by installing Transformers from source with the command `pip install git+https://github.com/huggingface/transformers.git`
  1. I try upgrade transformers using command pip install --upgrade transformers and recompile but come into this error:
/home/user/gemma3n/qefficient/qeff_env/lib/python3.10/site-packages/onnxscript/converter.py:816: FutureWarning: 'onnxscript.values.Op.param_schemas' is deprecated in version 0.1 and will be removed in the future. Please use '.op_signature' instead.
  param_schemas = callee.param_schemas()
Loading checkpoint shards: 100%|██████████████████████████████████████| 3/3 [00:03<00:00,  1.00s/it]
[Warning]: No transforms applied to model: Gemma3nForConditionalGeneration. It may be an unsupported model!
Traceback (most recent call last):
  File "/home/user/gemma3n/qefficient/compile-qeff.py", line 5, in <module>
    model.compile(prefill_seq_len=1024, ctx_len=16384, num_cores=16, num_devices=1, compile_dir ="./qpc_gemma-3n-E2B-it")
  File "/home/user/gemma3n/qefficient/qeff_env/lib/python3.10/site-packages/QEfficient/transformers/models/modeling_auto.py", line 1021, in compile
    output_names = self.model.get_output_names()
  File "/home/user/gemma3n/qefficient/qeff_env/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1940, in __getattr__
    raise AttributeError(
AttributeError: 'Gemma3nForConditionalGeneration' object has no attribute 'get_output_names'

Expected behavior
Command completes execution and model is compiled to .bin file

Environment:

  • OS: Ubuntu 22.04.5 LTS (GNU/Linux 6.8.0-1030-azure x86_64)
  • Branch: main

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions