Skip to content

Using fork in OSX now breaks - #577

Merged
ppinchuk merged 2 commits into
mainfrom
fix/OSX_fork
Oct 21, 2026
Merged

ppinchuk merged 2 commits into
mainfrom
fix/OSX_fork

Conversation

@castelao

Copy link
Copy Markdown
Member

Because docling uses PyTorch, which on OSX uses MPS, it silently crashes the subprocess resulting in like a no text found.

It is interesting that this is a new error. That didn't happen before. Since this is an OSX only change, it shouldn't affect our production runs.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused platform check addresses the macOS crash while preserving existing behavior elsewhere.

0 open findings

What changed in this PR

Updates Docling subprocess creation to avoid PyTorch/MPS crashes on macOS.

Changes:

  • Uses spawn on macOS or when fork is unavailable.
  • Retains fork on supported non-macOS platforms.
File Description
compass/​services/​cpu.py Selects a platform-safe multiprocessing start method for Docling.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@codecov-commenter

codecov-commenter commented Oct 11, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.56%. Comparing base (7f617a8) to head (e3e2ee8).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #577      +/-   ##
==========================================
+ Coverage   71.55%   71.56%   +0.01%     
==========================================
  Files          81       81              
  Lines        8429     8433       +4     
  Branches      909      910       +1     
==========================================
+ Hits         6031     6035       +4     
  Misses       2225     2225              
  Partials      173      173              
Flag Coverage Δ
unittests 71.56% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ppinchuk ppinchuk 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.

Is there any way we can add a test for this?

Bonus points if we can show that a test fails in CI for this particular case

Forking after PyTorch/MPS (Metal) init silently crashes the Docling
child process on macOS, surfacing as a misleading no-text-found result.
Add a Darwin-only test asserting _run_docling_in_subprocess selects the
spawn start method instead of fork.
Because docling uses PyTorch, which on OSX uses MPS, it silently crashes
the subprocess resulting in like a no text found.

It is interesting that this is a new error. That didn't happen before.
Since this is an OSX only change, it shouldn't affect our production runs.
@castelao

Copy link
Copy Markdown
Member Author

@ppinchuk , new test confirmed to crash in GitHub actions.

@castelao

Copy link
Copy Markdown
Member Author

@ppinchuk , feel free to merge it yourself if you approve it.

@ppinchuk

Copy link
Copy Markdown
Collaborator

Amazing, thank you!!!

@ppinchuk
ppinchuk merged commit 1133386 into main Oct 21, 2026
22 checks passed
@ppinchuk
ppinchuk deleted the fix/OSX_fork branch October 21, 2026 19:39

This branch was successfully deployed

2 active deployments
codecov — e3e2ee8e Deployed Oct 21, 2026 by castelao via Codecov #559
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Fixed a known bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants