Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions gptqmodel/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ class BaseQModel(nn.Module):

support_batch_quantize = True

support_offload_to_disk = True

ATTENTION_MASKS_DTYPE = torch.bool # default to bool

ATTENTION_MASKS_REQUIRED_FOR_INPUT: bool = False
Expand Down
2 changes: 2 additions & 0 deletions gptqmodel/models/definitions/gpt_oss.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ def forward(self, hidden_states):
return router_scores, router_indices

class GPTOSSGPTQ(BaseQModel):
support_offload_to_disk = False

dynamic_expert_index = "num_local_experts"

pre_lm_head_norm_module = "model.norm"
Expand Down
1 change: 1 addition & 0 deletions gptqmodel/models/definitions/llama4.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Llama4QModel(BaseQModel):
# some bug in the attention_mask of transformers.modeling_llama4,
# so batch quantization for Llama4 is temporarily not supported.
support_batch_quantize = False
support_offload_to_disk = False
loader = AutoModelForImageTextToText

pre_lm_head_norm_module = "language_model.model.norm"
Expand Down
6 changes: 6 additions & 0 deletions gptqmodel/models/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,12 @@ def skip(*args, **kwargs):
if hasattr(config, "hidden_act") and config.hidden_act == "xielu":
quantize_config.offload_to_disk = False

# some models need convert moe-experts after model loaded, like GPTOSS and Llama4
# so offload_to_disk is not supported for them.
if not cls.support_offload_to_disk:
quantize_config.offload_to_disk = False
log.warn(f"{cls} doesn't support offload_to_disk, set quantize_config.offload_to_disk to False.")

if quantize_config.offload_to_disk:
model = build_shell_model(cls.loader, config=config, **model_init_kwargs)
model._model_init_kwargs = model_init_kwargs
Expand Down