Skip to content

fix(docling): reserve the GPU from Ray cluster resources, not local CUDA (#580) - #584

Merged
hedhoud merged 1 commit into
refactor/hexagonalfrom
fix/docling-gpu-allocation
Jun 29, 2026
Merged

fix(docling): reserve the GPU from Ray cluster resources, not local CUDA (#580)#584
hedhoud merged 1 commit into
refactor/hexagonalfrom
fix/docling-gpu-allocation

Conversation

@andyne13

Copy link
Copy Markdown
Contributor

Docling parsed entirely on CPU (~5-10x slower than marker; no DoclingWorker on nvidia-smi). _docling_num_gpus() ran inside the DoclingPool actor — scheduled with no GPU, so torch.cuda.is_available() was False there and it reserved 0 GPUs for the worker, leaving Docling's AcceleratorDevice.AUTO on CPU.

Mirror _marker_num_gpus(): query the Ray cluster for GPU capacity, with local CUDA only as a startup fallback. (Marker got this fix earlier; Docling never did.)

Validated: with the fix, DoclingWorker shows on the GPU and per-doc parse dropped from ~123s to ~10s (on par with marker). Tests cover cluster-has-GPU/CUDA-hidden → reserves, no cluster GPU → 0, not requested → 0. Refs #580.

…UDA (#580)

_docling_num_gpus ran inside the DoclingPool actor (scheduled with no GPU),
so torch.cuda.is_available() was False there, it reserved 0 GPUs for the
worker, and Docling silently parsed on CPU (~5-10x slower than marker; no
DoclingWorker on nvidia-smi). Mirror _marker_num_gpus: query the Ray
cluster for GPU capacity, with local CUDA only as a startup fallback.

Tests cover cluster-has-GPU/CUDA-hidden -> reserves, no cluster GPU -> 0,
and not-requested -> 0.
@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@andyne13, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 59 minutes and 58 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 51dba988-d732-4854-b3e2-71c882ff1408

📥 Commits

Reviewing files that changed from the base of the PR and between 3cd9957 and f732e77.

📒 Files selected for processing (2)
  • openrag/services/workers/parsers/docling_workers.py
  • tests/unit/services/workers/parsers/test_docling_workers.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/docling-gpu-allocation

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@andyne13

Copy link
Copy Markdown
Contributor Author

Testing independently (no other PR needed)

Unit: uv run pytest tests/unit/services/workers/parsers/test_docling_workers.py

Functional standalone — set docling as the global backend (PDFLoader=DoclingLoader), so you don't need #582:

  • Index a PDF; during the parse run nvidia-smi → a ray::DoclingWorker process now holds VRAM (it was absent/CPU-only before this fix).
  • Per-doc ms_parse drops sharply (observed ~123s → ~10s, on par with marker).
    Before-fix signature: no DoclingWorker on nvidia-smi, docling parse 5–10× slower than marker.

if requested_gpus <= 0:
return 0
try:
return requested_gpus if ray.cluster_resources().get("GPU", 0) > 0 else 0

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 fixes fresh DoclingPool creation, but it may not take effect during a live upgrade. Startup uses get_or_create_actor("DoclingPool", ...), so if the old detached actor is still alive, it will keep its existing workers that were created with num_gpus=0. The deployment would still parse on CPU until someone manually restarts DoclingPool.

For this PR, it would be good to either add a small migration/restart guard for the existing actor, or call out clearly that DoclingPool must be restarted after deploying the fix.

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.

I re-checked this. The code fix is already enough for any newly created DoclingPool. The only remaining case is a live upgrade with an old detached pool still running, and we can handle that by restarting DoclingPool after deployment. So I don’t think we need an extra code change here.

@hedhoud
hedhoud merged commit 4db200a into refactor/hexagonal Jun 29, 2026
6 checks passed
@hedhoud
hedhoud deleted the fix/docling-gpu-allocation branch June 29, 2026 08:59
@Ahmath-Gadji Ahmath-Gadji added the fix Fix issue label Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Fix issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants