Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/transformers/quantizers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ def get_keys_to_not_convert(model) -> list:
}
modules_to_not_convert = tied_keys | last_module_key | output_emb_keys

# remove audio modules for multimodal models to prevent uint8 crash

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update the comment, this is not only for unint8 crash but just not worth quantizing it as it is quite small already

for name, _ in model.named_modules():
if "audio_tower" in name or "embed_audio" in name:
modules_to_not_convert.add(name)
Comment on lines +63 to +65

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a better way to check if we have an audio module. also i don't want to add all modules in it, only the top should be added. Make sure you add some tests also for bnb for example

Comment on lines +60 to +65

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm i don't think this is robust enough. Will the audio_tower always be in named_children and not in another children's child ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right — audio_tower sits under model in Gemma4ForConditionalGeneration, so named_children() on the top-level model wouldn't find it.

I've switched to named_modules() with endswith() check, so it finds audio modules regardless of nesting depth while still only adding the top-level audio module name (e.g. model.audio_tower) not its internal sub-layers. Updated the test to verify nested structure detection as well.



modules_to_not_convert = list({k.removesuffix(".weight") for k in modules_to_not_convert})

return list(modules_to_not_convert)
Expand Down
Loading