Skip to content

feat: optional deps handling for ONNX runtime#3792

Open
aminya wants to merge 3 commits into
docling-project:mainfrom
aminya:onnx-pytorch
Open

feat: optional deps handling for ONNX runtime#3792
aminya wants to merge 3 commits into
docling-project:mainfrom
aminya:onnx-pytorch

Conversation

@aminya

@aminya aminya commented Jul 11, 2026

Copy link
Copy Markdown

This makes it possible to load docling with ONNX without needing torch/transformer deps:

  • Moved the module-level torch and transformers imports down into the load methods.
  • Fixed device selection to gracefully fall back to CPU when torch isn't around
  • Wrapped engine registration in a guarded loader. If an optional backend (like TableFormer v2) is missing, we just skip it now instead of crashing the factory setup.
  • Added a numpy image processor fallback for ONNX. This handles the RT-DETR layout presets without needing torch. Output is identical to the transformers version.

Checklist:

  • Documentation has been updated, if necessary. N/A
  • Examples have been added, if necessary. N/A
  • Tests have been added, if necessary.

@github-actions

github-actions Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

DCO Check Passed

Thanks @aminya, all your commits are properly signed off. 🎉

@mergify

mergify Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🟢 Merge protection satisfied — ready to merge.

Show 1 satisfied protection

🟢 Enforce conventional commit

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\(.+\))?(!)?:

@aminya aminya force-pushed the onnx-pytorch branch 2 times, most recently from fd83991 to 4f5c268 Compare July 11, 2026 12:07
@codecov

codecov Bot commented Jul 11, 2026

Copy link
Copy Markdown

@aminya aminya force-pushed the onnx-pytorch branch 2 times, most recently from 069d628 to 374fa27 Compare July 11, 2026 12:17
aminya added 2 commits July 11, 2026 05:18
This makes it possible to load docling with ONNX without needing torch/transformer deps:

- Moved the module-level torch and transformers imports down into the load methods.
- Fixed device selection to gracefully fall back to CPU when torch isn't around
- Wrapped engine registration in a guarded loader. If an optional backend (like TableFormer v2) is missing, we just skip it now instead of crashing the factory setup.
- Added a numpy image processor fallback for ONNX. This handles the RT-DETR layout presets without needing torch. Output is identical to the transformers version.

Signed-off-by: Amin Ya <aminyahyaabadi74@gmail.com>
Signed-off-by: Amin Ya <aminyahyaabadi74@gmail.com>
@aminya

aminya commented Jul 11, 2026

Copy link
Copy Markdown
Author

❌ Patch coverage is 20.93023% with 102 lines in your changes missing coverage. Please review.

Added the unit test

docling-ibm-models imports torch/torchvision

Signed-off-by: Amin Ya <aminyahyaabadi74@gmail.com>
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