fix(embedding): split overlength text before inference - #2599
Open
jioffe502 wants to merge 5 commits into
Open
Conversation
Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
Collaborator
Author
|
The remaining BO767 runtime gate has passed on the accuracy-first production stack containing this patch.
This closes the draft gate. Timing was considered only after exact identity and receipt parity passed; the result used to release this PR is correctness, not a speed claim. |
Contributor
Greptile SummaryThe PR adds tokenizer-exact admission and deterministic splitting for overlength embedding inputs while preserving provenance and failing closed at inference and VDB boundaries.
|
| Filename | Overview |
|---|---|
| nemo_retriever/src/nemo_retriever/models/inference/embedding_input.py | Implements pinned tokenizer admission, exact formatted-token counting, deterministic splitting, and child provenance. |
| nemo_retriever/src/nemo_retriever/models/inference/runtime.py | Applies admission before inference, disables remote truncation, and maps backend errors to batch-level failures with coverage telemetry. |
| nemo_retriever/src/nemo_retriever/common/vdb/records.py | Preserves embedding-child provenance and rejects mixed dense writes with missing searchable embeddings while excluding inherited page URIs. |
| nemo_retriever/src/nemo_retriever/models/embed_model_spec.py | Resolves checkpoint-declared input limits and exact prompt metadata from pinned or local model assets. |
| Dockerfile | Preloads the complete default embedding admission policy for offline service startup. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
Input[Embedding batch] --> Resolve[Resolve pinned model policy]
Resolve --> Admit[Count formatted tokenizer inputs]
Admit -->|Fits| Infer[Local or remote inference]
Admit -->|Overlength| Split[Create deterministic provenance-preserving children]
Split --> Infer
Infer -->|Success| Coverage[Validate searchable-row embedding coverage]
Infer -->|Backend rejection| Fail[Fail prepared batch]
Coverage -->|Complete| VDB[Write canonical VDB records]
Coverage -->|Incomplete| Reject[Raise VdbUploadError]
Reviews (4): Last reviewed commit: "fix(embedding): tighten overflow admissi..." | Re-trigger Greptile
jioffe502
force-pushed
the
jioffe502/fix-embedding-input-overflow-main-20260827
branch
from
August 27, 2026 19:44
7a4ca55 to
61781a0
Compare
Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
jioffe502
force-pushed
the
jioffe502/fix-embedding-input-overflow-main-20260827
branch
from
August 27, 2026 20:56
61781a0 to
8b22fdf
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The embedding stage currently submits a pandas batch directly to the model. If one text row exceeds the checkpoint-supported input limit, the local model rejects the request, the batch is returned without embeddings, and downstream VDB conversion can discard valid neighboring rows. Remote embedding can instead truncate, which changes indexed content silently.
This is an accuracy and coverage bug. Batch composition must not determine which valid documents reach the index.
Accuracy contract
This PR establishes one fail-closed contract for local and remote text embedding:
truncate="NONE"after client-side admission so a remote endpoint cannot silently override the decision;If exact splitting cannot preserve the original source text and token sequence, admission fails before inference.
What changes
metadata.tokenizer.json, so offline actor startup has the required config and prompt assets.Compatibility and deliberate behavior changes
Scope
This PR does not change Ray scheduling, batching, backpressure, LanceDB-specific row builders, index construction, or the bounded sink in #2567. The batch library path continues through
IngestVdbOperatorand the abstractVDBinterface. It can be reviewed and merged independently ahead of #2567.Validation
git diff --checkpass for the touched Python files.upstream/main; the pull-request CI matrix is the clean-environment full-suite gate.Suggested review order
truncate="NONE"behavior.