fix: transformers warnings - #4014
Merged
Merged
Conversation
Signed-off-by: Peter Staar <taa@zurich.ibm.com>
Contributor
|
✅ DCO Check Passed Thanks @PeterStaar-IBM, all your commits are properly signed off. 🎉 |
Contributor
Merge Protections🟢 Merge protection satisfied — ready to merge. Show 1 satisfied protection🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
cau-git
approved these changes
Aug 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix: avoid deprecated
torch_dtypewarnings on transformers 5.xDescription
transformers5.x renamed thefrom_pretrainedkeywordtorch_dtypetodtype.Both Transformers-backed inference engines still passed
torch_dtype=torch_dtypeunconditionally, including when the dtype resolved to
None.That is not a no-op on transformers 5.x: the
Nonevalue is forwarded into theconfig kwargs and reaches the deprecated
PretrainedConfig.torch_dtypesetter,which emits a deprecation warning on every model load. Users converting documents
with the layout / image-classification stages saw this warning repeatedly in
otherwise clean output.
This PR:
torch_dtype is not None),so the default path no longer touches the deprecated setter at all.
transformersmajor version (
dtypefor >= 5,torch_dtypeotherwise), keeping bothtransformers 4.x and 5.x working from the same code path.
transformers 5.x validates encoder spatial shapes with a tensor condition, which
causes a
torch.compilegraph break ("Graph break fromTensor.item()") once percompiled region. It is noisy but harmless, and can be silenced with
TRANSFORMERS_DISABLE_TORCH_CHECK=1— safe for our fixed-resolution exports.Files touched:
docling/models/inference_engines/image_classification/transformers_engine.pydocling/models/inference_engines/object_detection/transformers_engine.pyNo behavior change for users on transformers 4.x, and no change to the resolved
dtype in any case — only how (and whether) it is handed to
from_pretrained.