Skip to content

fix(modules): guard HF modeling patches behind torch availability#261

Open
Gpgabriel25 wants to merge 1 commit into
erfanzar:mainfrom
Gpgabriel25:pr/hf-torch-availability-guards
Open

fix(modules): guard HF modeling patches behind torch availability#261
Gpgabriel25 wants to merge 1 commit into
erfanzar:mainfrom
Gpgabriel25:pr/hf-torch-availability-guards

Conversation

@Gpgabriel25
Copy link
Copy Markdown

Problem

Five model configuration modules unconditionally call
AutoModel.register / AutoConfig.register at import time, requiring
PyTorch to be installed even in pure-JAX environments. In any torch-free
deployment (TPU pods, CI without torch, EasyDeL-as-library):

ImportError: modeling_glm4v_moe requires the PyTorch library but it was
not found in your environment.

All five modules fail immediately on import:

  • glm4v_moe_configuration
  • llama4_configuration
  • phimoe_configuration
  • qwen3_5_moe_configuration
  • qwen3_next_configuration

Fix

Wrap the registration calls with HuggingFace's standard
if is_torch_available(): guard.

Evidence

Import probe, same torch-free venv, main vs this branch:

module main this PR
glm4v_moe_configuration ImportError ✅ OK
llama4_configuration ImportError ✅ OK
phimoe_configuration ImportError ✅ OK
qwen3_5_moe_configuration ImportError ✅ OK
qwen3_next_configuration ImportError ✅ OK

@Gpgabriel25 Gpgabriel25 changed the title Pr/hf torch availability guards fix(modules): guard HF modeling patches behind torch availability Apr 24, 2026
@Gpgabriel25 Gpgabriel25 force-pushed the pr/hf-torch-availability-guards branch from a38a5b9 to 4e70cc7 Compare April 24, 2026 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant