Skip to content

feat(file_processors): route docling VLM processing through stack inference API#6225

Open
alinaryan wants to merge 3 commits into
ogx-ai:mainfrom
alinaryan:feat/docling-vlm-inference
Open

feat(file_processors): route docling VLM processing through stack inference API#6225
alinaryan wants to merge 3 commits into
ogx-ai:mainfrom
alinaryan:feat/docling-vlm-inference

Conversation

@alinaryan

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds VLM-based document processing to the inline docling file processor provider. When vlm_model is configured and an inference provider is available, the provider uses docling's VlmPipeline for richer document understanding (layout analysis, OCR via vision models). Inference is routed through the stack's model-serving infrastructure in-process — no separate GPU resources or external HTTP calls are needed for document processing.

A custom BaseVlmEngine subclass (OgxInferenceVlmEngine) bridges docling's synchronous pipeline to the stack's async inference API using asyncio.run_coroutine_threadsafe(). The engine is injected into the docling pipeline at initialization time, replacing the default ApiVlmEngine.

When no VLM model is configured or no inference API is available, the provider gracefully degrades to the existing non-VLM pipeline with no behavior change.

file_processors:
- provider_id: docling
provider_type: inline::docling
config:
vlm_model: granite-docling-258M
vlm_preset: granite_docling

Test Plan

  • Unit tests pass: uv run pytest tests/unit/providers/file_processor/ -x --tb=short (68 tests)
  • mypy passes on all modified files
  • Pre-commit hooks pass (including provider codegen)
  • Integration test with a PDF file using vlm_model set to a registered vision model, confirming response metadata includes extraction_method: "docling-vlm"
  • Integration test without vlm_model set, confirming existing non-VLM behavior is unchanged
  • Integration test with vlm_model set but no inference provider available, confirming graceful degradation with warning log

…erence API

Add VLM-based document processing to the inline docling provider by
creating a custom VLM engine that calls the stack's inference API
in-process via dependency injection, avoiding external HTTP round-trips.

When vlm_model is configured and an inference provider is available, the
provider initializes docling's VlmPipeline and replaces the default API
engine with OgxInferenceVlmEngine, which bridges docling's synchronous
pipeline to the async inference API using asyncio.run_coroutine_threadsafe.
When no VLM model is configured or no inference API is available, the
provider gracefully degrades to the standard non-VLM pipeline.

Signed-off-by: Alina Ryan <aliryan@redhat.com>
@alinaryan alinaryan force-pushed the feat/docling-vlm-inference branch from 0672897 to de4c4d4 Compare June 30, 2026 19:31

@mattf mattf left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some inline comments.

which llm did you use for this?

Comment on lines +59 to +62
log.warning(
"VLM model configured but no inference API available, falling back to standard pipeline",
vlm_model=self.config.vlm_model,
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could be a startup error. the admin configured use of a vlm model and it's not being honored.

Comment on lines +68 to +72
from docling.datamodel.pipeline_options import VlmConvertOptions
from docling.datamodel.vlm_engine_options import ApiVlmEngineOptions, VlmEngineType
from docling.pipeline.vlm_pipeline import VlmPipeline

from .vlm_engine import OgxInferenceVlmEngine

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imports at top

self.config.vlm_preset,
engine_options=ApiVlmEngineOptions(engine_type=VlmEngineType.API_OPENAI),
)
except KeyError:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please me more specific. check for the expected values and error if they aren't present.

stream=False,
)
future = asyncio.run_coroutine_threadsafe(
self.inference_api.openai_chat_completion(request),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will this handle provider data credentials?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes the engine calls the stack's inference API in-process via the Python object (inference_api.openai_chat_completion()), not over HTTP. Auth credentials (API keys, tokens, etc.) are configured on the inference provider itself and are already resolved by the time the call reaches the provider implementation. This is the same dependency injection pattern used by the responses and file_search providers.

@mergify

mergify Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

This pull request has merge conflicts that must be resolved before it can be merged. @alinaryan please rebase it. https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify Bot added the needs-rebase label Jul 7, 2026
alinaryan added 2 commits July 7, 2026 16:11
Raise a startup error when vlm_model is configured but no inference
provider is available, instead of silently falling back. Validate
vlm_preset against docling's registered presets with a clear error
listing available values. Move VLM-related imports to module level.

Signed-off-by: Alina Ryan <aliryan@redhat.com>
Keep both the new supported_mime_types() method from upstream and the
VLM pipeline methods from this branch.

Signed-off-by: Alina Ryan <aliryan@redhat.com>
@mergify mergify Bot removed the needs-rebase label Jul 7, 2026
@alinaryan

Copy link
Copy Markdown
Contributor Author

some inline comments.

which llm did you use for this?

@mattf I used Claude Opus 4.6

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.

3 participants