Restore is_torch_fx_available for trust_remote_code backwards compatibility - #44615
Restore is_torch_fx_available for trust_remote_code backwards compatibility#44615MaybeSam05 wants to merge 1 commit into
Conversation
|
cc @ArthurZucker wdyt? We could consider reintroducing, but IMO a bit pointless as again we cannot guarantee BC for remote models, and it's bound to broke in another way soon (if it's not already broken in another fashion already) |
|
This is a real, currently-occurring issue outside just the specific example in the PR description — hit it independently while testing vLLM's Transformers backend ( Repro: pip install "transformers==5.13.0" "vllm>=0.25.0"
vllm serve deepseek-ai/DeepSeek-V2-Lite --model-impl transformers --trust-remote-codeError:
Re: @Cyrilvallez's point that this is "bound to break in another way soon" — that's a fair concern in general, but for this specific symbol it's a real, present blocker for at least one actively-used model family (DeepSeek-V2/V2-Lite's remote code, which is still widely referenced from the Hub). Happy to help test this patch against our repro if that's useful signal for reconsidering. |
What does this PR do?
Restores
is_torch_fx_availableintransformers.utils.import_utilsas a backwards-compatibility shim so that Hub models loaded withtrust_remote_code=Truethat still import this symbol no longer raiseImportErroron Transformers v5+.Context: In v5,
is_torch_fx_availablewas removed fromimport_utils. Many community models (e.g.deepseek-ai/deepseek-moe-16b-base) ship their ownmodeling_*.pyand still dofrom transformers.utils.import_utils import is_torch_fx_available, which breaks at import time when using v5.Changes:
is_torch_fx_available()insrc/transformers/utils/import_utils.py.DeprecationWarning(via@lru_cache), returnsFalseif PyTorch is not available, and otherwise checks thattorch.fxcan be imported and returnsTrue/False.torch.fxis always available, so behavior for existing callers is unchanged.Fixes #44561
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
@ArthurZucker @Rocketknight1 — this restores a symbol removed in v5 that breaks
trust_remote_codemodels (see #44561). Optional: @Cyrilvallez for model-loading/import-utils context.