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
8 changes: 4 additions & 4 deletions defuser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
# SPDX-License-Identifier: Apache-2.0
# Contact: qubitium@modelcloud.ai, x.com/qubitium

def convert_hf_model(*args, **kwargs):
def convert_model(*args, **kwargs):
"""Lazily import conversion entrypoint to avoid import-time cycles."""
from .defuser import convert_hf_model as _convert_hf_model
from .defuser import convert_model as _convert_model

return _convert_hf_model(*args, **kwargs)
return _convert_model(*args, **kwargs)


__all__ = ["convert_hf_model"]
__all__ = ["convert_model"]
7 changes: 4 additions & 3 deletions defuser/defuser.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def check_model_compatibility(model: nn.Module) -> bool:
config = getattr(model, "config", None)
model_type = getattr(config, "model_type", None)
if model_type not in MODEL_CONFIG:
raise ValueError(f"Unsupported model_type: {model_type}")
return False

min_ver = MODEL_CONFIG[model_type].get("min_transformers_version")
current_ver = version.parse(transformers.__version__)
Expand Down Expand Up @@ -112,12 +112,13 @@ def convert_model(
# This ensures compatibility between the Qwen3.5 fused checkpoint format
# and the runtime model implementation that operates on defused weights.

check_model_compatibility(model)
if not check_model_compatibility(model):
return model

return update_module(
model,
cleanup_original=cleanup_original,
max_layers=max_layers,
)

__all__ = ["convert_hf_model"]
__all__ = ["convert_model"]