Skip to content

fix: preserve explicit cuda selection in parallel workers - #770

Merged
joein merged 2 commits into
qdrant:mainfrom
RAMZI0TO99:fix/parallel-cuda-forwarding-split
Oct 5, 2026
Merged

joein merged 2 commits into
qdrant:mainfrom
RAMZI0TO99:fix/parallel-cuda-forwarding-split

Conversation

@RAMZI0TO99

Copy link
Copy Markdown
Contributor

When device_ids is absent or empty, ParallelWorkerPool.start() omits its cuda setting from worker options. An explicit cuda=False CPU request can therefore be lost when the worker reconstructs its model with an automatic default.

This always forwards the pool's cuda setting, while retaining round-robin device assignment. Tests run real child processes and reporting workers without a GPU or model download. They cover Boolean and Device enum selections, absent/empty/explicit device IDs, ordering, other options, and the pool option's precedence over conflicting worker kwargs. GPU inference was not tested.

Validation on Windows 11, Python 3.13.5, NumPy 2.3.5, FastEmbed 0.8.1:

  • 21 selected tests passed: python -m pytest -q tests/test_parallel_cuda_forwarding.py tests/test_parallel_processor.py.
  • Local diff-scoped AST docstring coverage: 8/8 functions (100%, above the reported 80% threshold). CodeRabbit's own result is separate.
  • Ruff 0.3.4 lint/format and staged whitespace checks passed.
  • Repository mypy and pyright checks passed on Python 3.13.5.

The full model/OS/Python CI matrix was not run locally.

Split from #766 following the maintainer's request for one PR per problem. This branch is based directly on current main and contains only this problem's production change and regression module.

@RAMZI0TO99
RAMZI0TO99 requested a review from joein as a code owner October 4, 2026 13:12
@coderabbitai

coderabbitai Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4f979b84-1b1d-4041-ac36-001f27830e37
📥 Commits

Reviewing files that changed from the base of the PR and between 3d29818 and c81b6ca.

📒 Files selected for processing (1)
  • fastembed/parallel_processor.py
💤 Files with no reviewable changes (1)
  • fastembed/parallel_processor.py

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

ParallelWorkerPool.start now passes the configured cuda value to every worker. When device_ids are configured, the pool continues to assign each worker an ID by cycling through the list.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to c81b6

This change makes parallel workers respect an explicit cuda selection, including CPU-only requests, while still assigning device IDs round-robin. No merge-blocking risk was identified.

Security Architecture Review

Security architecture risk: ⚪ Minimal · up to 3d298

The change consistently preserves the pool’s device selection without introducing a new privilege boundary or weakening existing provider checks. No material security risk was identified in the reviewed change.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The changed behavior affects device selection in child workers created through the existing pool entrypoint. The reviewed path propagates an existing caller-supplied configuration value rather than adding an independently reachable privileged operation; deployment-specific device isolation was not established.

Trust Boundaries and Controls

  • observed — Forwarded CUDA selection does not override explicit ONNX providers. The loader selects supplied providers first and rejects requested providers that are unavailable; these existing checks remain downstream of worker model reconstruction.

Resilience and Maintainability Implications

  • observed — The diff leaves lifecycle handling unchanged. Child startup exceptions still signal an error and finalize queues before decrementing the active-worker counter; parent completion and interruption retain join or termination paths. Partial-startup and concurrent-use limitations are not newly addressed by this change.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the change: preserving the configured CUDA selection in parallel workers.
Description check ✅ Passed The description explains the CUDA forwarding change and its regression tests, so it is directly related to the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 87.50% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 2 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@joein joein left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

thanks for addressing this!

@joein
joein merged commit 5d95ac3 into qdrant:main Oct 5, 2026
12 checks passed
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.

2 participants