Repository navigation
Nemotron 3.5 vLLM embed: AsyncLLM with four UDF threads per actor - #2837
Conversation
…flash attention The HF Pixtral vision tower concatenates every image in a vLLM multimodal batch into one sequence and runs SDPA with a dense block-diagonal mask. Run the tower once per image and drop the mask for a single image so SDPA can select flash attention. Per-image outputs keep the stock order and shape. Text+image admission now counts expanded prompt tokens from the image size and the tokenizer instead of running the processor's pixel preprocessing a second time before vLLM. Images smaller than one merged patch still use the processor so its resize and error behavior is unchanged. Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
… with two UDF threads The synchronous LLM.embed loop idles the GPU while an actor prepares its next batch. AsyncEmbedEngine wraps vLLM AsyncLLM on a private event loop, submits each prompt as its own request, and keeps LLM.embed's call shape. The GPU embed actor runs two Ray UDF threads on a true multithreaded actor pool, so one batch prepares while the other waits on the engine. Models that do not support concurrent calls stay serialized per actor, and the shared fast tokenizer is guarded because mixed truncation settings mutate it. CUDA graphs stay enabled. Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
…on test Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
There was a problem hiding this comment.
Note
Newer findings are available below. Devin Review posted a newer report on this PR, in addition to the findings presented here.
Devin Review found 1 finding. It is left for you to triage below.
…readed operators Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
… array Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
…-async-vllm Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
…-async-vllm Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
[Medium impact] The PR changes concurrency within the GPU embedding ingest workflow. The exception block in the new concurrency test must satisfy the explicit repository rule before merging. Findings
Fix with agent prompt### Issue 1
nemo_retriever/tests/test_operator_flags_and_cpu_actors.py:405-406
The new test catches `threading.BrokenBarrierError` and does nothing. This violates the repository directive forbidding exception blocks that use `pass`, which also applies to tests. Record and assert the expected timeout for serial calls rather than silently ignoring it.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.SummaryThe PR lets Nemotron 3.5 embedding run through
|
Run each prompt in an asyncio.TaskGroup so a failing prompt cancels the rest of the call before its error propagates, and document the AsyncEmbedEngine, create_vllm_llm and supports_concurrent_calls APIs. Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
| """Graph embedding actor that loads a local embedder or calls a remote endpoint.""" | ||
|
|
||
| # Ray UDF threads per actor, so batches prepare on the CPU while others wait on the engine. | ||
| UDF_THREADS = 4 |
There was a problem hiding this comment.
[P3] Scope the Ray scheduling opt-in and reuse its serialization
Nonblocking design/scope suggestion: this class-level constant enables a four-thread, true-multithreaded Ray pool for every GPU embedding actor, including HF, other local models, and remote endpoints. The new _serial lock serializes their inference, but their Ray batching/prefetch and thread scheduling still change. That is broader than the description's 'Only the Nemotron 3.5 vLLM embedder opts in' claim. Could the executor select this strategy only for the supported resolved model/backend and retain Ray's existing serialized-UDF path for the others? Ray already provides the serialization when enable_true_multi_threading is false, so this could also remove the extra per-actor lock/nullcontext dispatch. If the broader scheduling change is intentional, please describe and validate its effects on those other embedders.
There was a problem hiding this comment.
Agreed, the pool is wider than the description's wording. Every embed actor gets four Ray UDF threads. For models without supports_concurrent_calls, which is everything except the Nemotron 3.5 vLLM backend, _serial still runs inference one batch at a time. HF and remote actors can therefore hold up to four batches while they wait, but they never run them concurrently, so results are unaffected. I've left the code as is to keep this PR small. Scoping UDF_THREADS to the vLLM backend can be a follow-up if you'd like it.
Signed-off-by: Jacob Ioffe <jioffe@nvidia.com> # Conflicts: # nemo_retriever/src/nemo_retriever/models/local/nemotron35_embedder.py
AsyncEmbedEngine keeps its loop thread; shutdown() and garbage collection stop the loop, join the thread and close the loop. Nemotron35Embedder loads the model under a lock, so concurrent first calls build one engine. Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
| except threading.BrokenBarrierError: | ||
| pass |
There was a problem hiding this comment.
The new test catches threading.BrokenBarrierError and does nothing. This violates the repository directive forbidding exception blocks that use pass, which also applies to tests. Record and assert the expected timeout for serial calls rather than silently ignoring it.
Rule Used: Never use bare 'except:' that silently swallows errors. Always catch specific exceptions where possible. Catching 'except Exception as e:' is acceptable ONLY at defined boundaries -- FastAPI endpoint handlers, CLI entry points (typer/click commands),... (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: nemo_retriever/tests/test_operator_flags_and_cpu_actors.py
Line: 405-406
Comment:
**Barrier errors are ignored**
The new test catches `threading.BrokenBarrierError` and does nothing. This violates the repository directive forbidding exception blocks that use `pass`, which also applies to tests. Record and assert the expected timeout for serial calls rather than silently ignoring it.
**Rule Used:** Never use bare 'except:' that silently swallows errors. Always catch specific exceptions where possible. Catching 'except Exception as e:' is acceptable ONLY at defined boundaries -- FastAPI endpoint handlers, CLI entry points (typer/click commands),... ([source](https://github.com/nvidia/nemo-retriever/blob/e20f2abff67851062d46d70d94488a2d4af06792/.greptile/config.json))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Description
Runs Nemotron 3.5 embedding through vLLM's async engine in its own process, and lets each embed actor keep 4 batches in flight. Stacked on #2836.
On
main, the GPU sits idle while vLLM preprocesses images on the CPU. With this PR, the CPU prepares the next batches while the GPU runs the current one, so the GPU stays busy: embed GPU busy goes from 63% to 92% in an nsys trace.The same thing in a real nsys trace (ViDoRe, 8 GPUs, GPU 7, a 10 s steady-state window). Red marks GPU idle time.
Image-heavy ingest (ViDoRe) is ~2× faster than
main; PDF/text is unchanged.Every ViDoRe subset gets faster when ingested on its own. Smaller subsets gain less because model start-up is a fixed cost. Recall is unchanged on every subset.
Confidence
main(cosine ≥ 0.9997), and recall is unchanged everywhere.What changed
AsyncEmbedEngine(models/inference/vllm.py) has the same call shape asLLM.embed, but runs over vLLMAsyncLLMand returns results in prompt order._BatchEmbedActor.UDF_THREADS = 4. The executor turns it into a multithreaded Ray actor pool; an explicitmax_concurrencyoverride still wins. Pool sizes and CPU/GPU reservations are unchanged.Checklist
Link to Devin session: https://nvidia-cloud.devinenterprise.com/sessions/bad125a41197410993e49df9e8ca2f37
Open in Devin Desktop: https://nvidia-cloud.devinenterprise.com/desktop/session/bad125a41197410993e49df9e8ca2f37?variant=devin
Requested by: @jioffe502
🟢 Devin Review found nothing to fix · View findings · Follow Devin's work