Bug
Docling fails to convert a PDF on Apple Silicon macOS when Torch model compilation is enabled by default.
The conversion reaches the layout-detection stage, then fails inside PyTorch TorchInductor with:
torch._inductor.exc.InductorError:
TypeError: BooleanAtom not allowed in this context.
Relevant traceback path:
Docling layout model
-> Transformers object-detection engine
-> torch.compile()
-> TorchDynamo/TorchInductor
-> SymPy symbolic shape handling
-> BooleanAtom not allowed in this context
Disabling Docling’s Torch compilation allows the same PDF to convert successfully:
DOCLING_INFERENCE_COMPILE_TORCH_MODELS=false \
uvx --native-tls docling \
--to md \
-v \
--image-export-mode referenced \
<mypdf>.pdf
The workaround produced valid Markdown output and referenced image artifacts. Therefore, the failure appears limited to the compiled inference path rather than PDF parsing or the conversion pipeline itself.
It would be useful if Docling either:
- Automatically fell back to eager inference when torch.compile()/TorchInductor fails; or
- Disabled model compilation by default for unsupported or unstable platform/backend combinations.
Steps to reproduce
- Use an Apple Silicon Mac.
- Obtain a PDF with the relevant characteristics. The original test file was a 64-page encrypted PDF.
- Run:
uvx --native-tls docling \
--to md \
-v \
--image-export-mode referenced \
<mypdf>.pdf
- Observe that Docling selects the MPS accelerator:
Accelerator device: 'mps'
- Observe that it initializes the Transformers object-detection layout engine.
- Observe conversion failure during layout processing:
Stage layout failed
TypeError: BooleanAtom not allowed in this context.
- Run the same conversion with model compilation disabled:
DOCLING_INFERENCE_COMPILE_TORCH_MODELS=false \
uvx --native-tls docling \
--to md \
-v \
--image-export-mode referenced \
<mypdf>pdf
- Observe that conversion succeeds.
Docling version
Docling version: 2.119.0
Docling Core version: 2.91.0
Docling IBM Models version: 3.14.0
Docling Parse version: 7.12.1
Python: cpython-312 (3.12.11)
Platform: macOS-26.5.2-arm64-arm-64bit
Python version
Additional environment information:
PyTorch: 2.13.0
Device selected by Docling: mps
OS: macOS arm64
The exact error is:
torch._inductor.exc.InductorError: TypeError: BooleanAtom not allowed in this context.
Bug
Docling fails to convert a PDF on Apple Silicon macOS when Torch model compilation is enabled by default.
The conversion reaches the layout-detection stage, then fails inside PyTorch TorchInductor with:
Relevant traceback path:
Disabling Docling’s Torch compilation allows the same PDF to convert successfully:
DOCLING_INFERENCE_COMPILE_TORCH_MODELS=false \ uvx --native-tls docling \ --to md \ -v \ --image-export-mode referenced \ <mypdf>.pdfThe workaround produced valid Markdown output and referenced image artifacts. Therefore, the failure appears limited to the compiled inference path rather than PDF parsing or the conversion pipeline itself.
It would be useful if Docling either:
Steps to reproduce
uvx --native-tls docling \ --to md \ -v \ --image-export-mode referenced \ <mypdf>.pdfDOCLING_INFERENCE_COMPILE_TORCH_MODELS=false \ uvx --native-tls docling \ --to md \ -v \ --image-export-mode referenced \ <mypdf>pdfDocling version
Python version
Additional environment information:
The exact error is: