docling-project / docling-project/docling

Docling and llm granite-docling 258m (RockMan256) with LM Studio-0.4.20

Open
#3,910 53 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
66.4k
Forks
4.8k
Avg merge
2d 21h
Merged PRs (30d)
84

Description

### Bug
Malheureusement, je ne suis pas en mesure de créer des issues GitHub directement. Mais voici une description de ticket prête à copier-coller pour ouvrir une issue sur le repo [docling](https://github.com/docling-project/docling/issues/new) :

***

**Titre :** `AttributeError: 'NoneType' object has no attribute 'info'` during engine cleanup at interpreter shutdown

**Description :**

**Bug**

During Python interpreter shutdown, the error `Error cleaning up engine: 'NoneType' object has no attribute 'info'` is raised. This occurs on Docling v2.115.0.

**Root Cause**

PR #3534 added a `if _log is not None` guard in `CodeFormulaVlmModel.__del__()` for the `_log.warning()` call, but the underlying issue remains: the VLM engine `cleanup()` methods call `_log.info()` without checking if `_log` is `None`. During interpreter shutdown, module-level globals (including loggers) are set to `None` before `__del__` is invoked.

**Affected files**

Engine `cleanup()` methods with unguarded `_log.info()`:

- `docling/models/inference_engines/vlm/mlx_vlm_engine.py`
- `docling/models/inference_engines/vlm/vllm_engine.py`
- `docling/models/inference_engines/vlm/transformers_vlm_engine.py`
- `docling/models/inference_engines/vlm/auto_inline_engine.py`
- `docling/models/inference_engines/vlm/api_openai_engine.py`

Model `__del__` methods missing `if _log is not None` guard:

- `VlmConvertModel` (in `docling/models/vlm_convert_model.py`)
- `PictureDescriptionVlmEngineModel` (in `docling/models/picture_description_vlm_engine_model.py`)

**Proposed Fix**

Add `if _log is not None:` guard before all `_log.info()` calls in engine `cleanup()` methods and before `_log.warning()` calls in the two unguarded model `__del__` methods, consistent with the existing fix in `CodeFormulaVlmModel`.

***

L'erreur est cosmétique (elle ne bloque pas le traitement des documents), mais elle génère du bruit inutile dans les logs. N'hésitez pas à adapter le texte selon vos besoins !
...

### Steps to reproduce
programme python utilisé :
import logging
import os
from pathlib import Path

import requests
from dotenv import load_dotenv

from docling.datamodel.pipeline_options_vlm_model import ApiVlmOptions, ResponseFormat

from docling.pipeline.vlm_pipeline import VlmPipeline
from docling.document_converter import DocumentConverter, PdfFormatOption
from docling.datamodel.base_models import InputFormat
from docling.datamodel.pipeline_options import (
VlmConvertOptions,
VlmPipelineOptions,
)
from docling.datamodel.vlm_engine_options import (
ApiVlmEngineOptions,
VlmEngineType,
)

source = "c:/debuts-docling/dureecontrat.pdf"

import lmstudio as lms
SERVER_API_HOST = "10.241.254.145:1234"
lms.configure_default_client(SERVER_API_HOST)

vlm_options = VlmConvertOptions.from_preset(
"granite_docling",
engine_options=ApiVlmEngineOptions(
url="http://10.130.203.145:1234/v1/chat/completions", # the default Ollama endpoint
params={
"model": "granite-docling-258m",
"temperature": 0.0,
"max_tokens": 8192,
"skip_special_tokens": False,
},
#prompt="Convertir cette page en markdown. Ne pas oublier de texte. Mettre les formules de calcul en latex.",
timeout=90,
scale=1.0,
response_format=ResponseFormat.MARKDOWN,
)
)

pipeline_options = VlmPipelineOptions(
vlm_options=vlm_options,
enable_remote_services=True,
)

# Point to your local file or web path
#converter = DocumentConverter()
#result = converter.convert(source)
doc_converter = DocumentConverter(
format_options={
InputFormat.PDF: PdfFormatOption(
pipeline_options=pipeline_options,
pipeline_cls=VlmPipeline,
)
}
)

result = doc_converter.convert(source)
# Export to clean Markdown format
print(result.document.export_to_markdown())

### Docling version
Docling version: 2.115.0
Docling Core version : 2.88.0
Docling IBM Models version : 3.13.3
Docling Parse version : 7.8.1
Python : cpython-313 (3.13.14)
Plateform windows-11-10.0.26200-SP0

### Python version
Python 3.13.14

Contributor guide

Open the contributing guide

Research direction

Inspect the cleanup() methods in docling/models/inference_engines/vlm/mlx_vlm_engine.py, vllm_engine.py, transformers_vlm_engine.py, auto_inline_engine.py, and api_openai_engine.py, along with the __del__ methods in docling/models/vlm_convert_model.py and picture_description_vlm_engine_model.py. Compare them with the guarded cleanup in CodeFormulaVlmModel, then run the supplied VLM reproduction and confirm interpreter shutdown produces no cleanup logging error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.