fix(rag): use floor division for vector embedding batch count - #39376
Open
sergioperezcheco wants to merge 1 commit into
Open
fix(rag): use floor division for vector embedding batch count#39376sergioperezcheco wants to merge 1 commit into
sergioperezcheco wants to merge 1 commit into
Conversation
The total_batches counter in Vector.create and Vector.create_multimodal was computed as len(texts) + batch_size - 1, which yields the item count plus an offset instead of the number of batches. The progress log lines therefore reported a wildly inflated denominator (e.g. 1001 texts with a batch size of 1000 printed 'Processing batch 1/2000'). Use ceiling division so the denominator reflects the actual batch count.
sergioperezcheco
requested review from
JohnJyong,
QuantumGhost and
laipz8200
as code owners
July 21, 2026 11:48
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-07-21 11:50:13.976564374 +0000
+++ /tmp/pyrefly_pr.txt 2026-07-21 11:49:59.520587863 +0000
@@ -4953,7 +4953,7 @@
ERROR Class member `_Expr.__eq__` overrides a member in a parent class but is missing an `@override` decorator [missing-override-decorator]
--> tests/unit_tests/core/rag/datasource/vdb/test_vector_factory.py:253:13
ERROR Class member `_Field.__eq__` overrides a member in a parent class but is missing an `@override` decorator [missing-override-decorator]
- --> tests/unit_tests/core/rag/datasource/vdb/test_vector_factory.py:355:13
+ --> tests/unit_tests/core/rag/datasource/vdb/test_vector_factory.py:378:13
ERROR Argument `list[str]` is not assignable to parameter `docs` with type `Sequence[Document]` in function `core.rag.docstore.dataset_docstore.DatasetDocumentStore.add_documents` [bad-argument-type]
--> tests/unit_tests/core/rag/docstore/test_dataset_docstore.py:297:33
ERROR Argument `None` is not assignable to parameter `orig` with type `BaseException` in function `sqlalchemy.exc.DBAPIError.__init__` [bad-argument-type]
|
Contributor
Pyrefly Type Coverage
|
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.
The total_batches counter in Vector.create and Vector.create_multimodal was computed as len(texts) + batch_size - 1, which is missing the floor-division step. With a batch size of 1000, embedding 1001 documents logged "Processing batch 1/2000" instead of "Processing batch 1/2", so the progress denominator was off by ~batch_size. This only affects the info-level progress logs (the actual batching loop uses the correct range step), but it makes the logs misleading when debugging long embedding runs.
Changed both the text and multimodal paths to use ceiling division: (len(items) + batch_size - 1) // batch_size. Added a regression test that embeds 1001 docs and asserts the logged batch denominator is 2, not 2000 (verified it fails on the old formula).