transformers - ✅(Solved) Fix Cannot load `microsoft/Phi-4-multimodal-instruct` model with latest transformers. [1 pull requests, 3 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
huggingface/transformers#44964Fetched 2026-04-08 01:21:23
View on GitHub
Comments
3
Participants
2
Timeline
10
Reactions
0
Timeline (top)
commented ×3mentioned ×2subscribed ×2closed ×1

Error Message

As commented in L284-L285, we use revision = "refs/pr/70" for model microsoft/Phi-4-multimodal-instruct, but with latest transformers, it returns error ImportError: cannot import name 'CommonKwargs' from 'transformers.processing_utils after we add trust_remote_code=True. So do we have plan to fix this bug, or just skip related test case?

Fix Action

Fixed

PR fix notes

PR #44966: Fix backward compatibility for CommonKwargs in processing_utils (brea…

Description (problem / solution / changelog)

Fixes #44964

Summary

This PR restores backward compatibility for CommonKwargs in transformers.processing_utils, which is still referenced by some remote processor implementations.

Problem

After the typed-dict cleanup (commit 5339f72b9b), CommonKwargs is no longer exposed from transformers.processing_utils.

However, some remote code, for example microsoft/Phi-4-multimodal-instruct at refs/pr/70, still imports it:

from transformers.processing_utils import CommonKwargs

This results in:

ImportError: cannot import name 'CommonKwargs'

Reproduction

from transformers import AutoProcessor

AutoProcessor.from_pretrained(
    "microsoft/Phi-4-multimodal-instruct",
    revision="refs/pr/70",
    trust_remote_code=True,
)
  • Before: ImportError
  • After: loads successfully (Phi4MultimodalProcessor)

Solution

Restore a minimal compatibility export for CommonKwargs in processing_utils.py.

This preserves existing remote code behavior without modifying core logic.

Notes

  • This is a backward compatibility fix for trust_remote_code workflows
  • No changes to internal functionality
  • Full integration test requires torchcodec + FFmpeg, which is unrelated to this issue
  • AI assistance was used for diagnosis and drafting, but the change was reviewed and verified locally

Changed files

  • src/transformers/processing_utils.py (modified, +8/-0)
RAW_BUFFERClick to expand / collapse

System Info

  • transformers version: 5.3.0.dev0
  • Platform: Linux-5.4.292-1.el8.elrepo.x86_64-x86_64-with-glibc2.35
  • Python version: 3.10.12
  • Huggingface_hub version: 1.7.1
  • Safetensors version: 0.5.3
  • Accelerate version: 1.12.0
  • Accelerate config: not found
  • DeepSpeed version: not installed
  • PyTorch version (accelerator?): 2.10.0+cu128 (CUDA)
  • Using distributed or parallel set-up in script?: <fill in>
  • Using GPU in script?: <fill in>
  • GPU type: NVIDIA A100 80GB PCIe

Who can help?

@yonigozlan

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

git clone https://github.com/huggingface/transformers.git cd transformers pip install -e . export RUN_SLOW=1 pytest -rA tests/models/phi4_multimodal/test_modeling_phi4_multimodal.py::Phi4MultimodalIntegrationTest::test_audio_text_generation

Expected behavior

As commented in L284-L285, we use revision = "refs/pr/70" for model microsoft/Phi-4-multimodal-instruct, but with latest transformers, it returns error ImportError: cannot import name 'CommonKwargs' from 'transformers.processing_utils after we add trust_remote_code=True. So do we have plan to fix this bug, or just skip related test case?

extent analysis

Fix Plan

The fix involves updating the import statement to match the changes in the transformers library.

  • Update the import statement in the test file to import CommonKwargs from the correct module.
  • Since CommonKwargs is not available in transformers.processing_utils, we need to find the correct location of this class.

Example code:

# Replace the following line
from transformers.processing_utils import CommonKwargs

# With the correct import statement
from transformers.generation import CommonKwargs

Alternatively, if CommonKwargs is not available in transformers.generation, you may need to update your transformers version or check the documentation for the correct import statement.

Verification

To verify the fix, run the test case again using the following command:

pytest -rA tests/models/phi4_multimodal/test_modeling_phi4_multimodal.py::Phi4MultimodalIntegrationTest::test_audio_text_generation

If the test passes without any errors, the fix is successful.

Extra Tips

  • Make sure to update your transformers version to the latest one to avoid any compatibility issues.
  • Check the documentation for any changes in the import statements or class locations.
  • If you are still facing issues, try to debug the code by printing the available modules and classes in the transformers library.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

As commented in L284-L285, we use revision = "refs/pr/70" for model microsoft/Phi-4-multimodal-instruct, but with latest transformers, it returns error ImportError: cannot import name 'CommonKwargs' from 'transformers.processing_utils after we add trust_remote_code=True. So do we have plan to fix this bug, or just skip related test case?

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

transformers - ✅(Solved) Fix Cannot load `microsoft/Phi-4-multimodal-instruct` model with latest transformers. [1 pull requests, 3 comments, 2 participants]