Repository navigation
fix: Preserve global embedding order across bounded batches - #811
Draft
buildingjoshbetter wants to merge 3 commits into
Draft
buildingjoshbetter wants to merge 3 commits into
buildingjoshbetter wants to merge 3 commits into
Conversation
This was referenced Oct 8, 2026
This branch has not been deployed
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.
Scope
Narrow Qwen embedding-order correction for #735, stacked on #804. The earlier native diagnostic established default embedding parity and exposed additional explicit-eight regressions. The current follow-up limits global ordering to an effective bound of 32; its native reconfirmation is pending. This draft does not close the numerical/performance release gates.
Reproduced problem
SentenceTransformers orders a complete request by input length before making its own batches. The earlier bounded wrapper split caller order first, then each encode call sorted only its slice. Default mixed requests of 33 and 100 rows therefore changed native batch membership and padding. All six large-request default comparisons failed the frozen numerical tolerance in the prior native diagnostic; the mixed 100 default median was 1000.544282 ms versus 390.950397 ms for the full-list native reference, a ratio of 2.559261. Those failed receipts remain evidence, not acceptance.
Correction
Compatibility follow-up
Current head
a01579868c36df9c2ba93f603dfe248d14c0cd7dretains the earlier contiguous slice membership whenever the resolved bound is below 32, including explicit-eight and adaptive reductions. Omitted or oversized requests use global order only when their effective bound is 32. This avoids adding the measured global-eight regression while preserving all actual request caps. It does not resolve or waive the earlier contiguous-eight numerical failure.Root independently ran 15 focused production-AST tests with no native imports. Removing the effective-limit guard makes the lower-bound membership and adaptive tests fail. Cyclic inverse, occurrence coverage, output preflight, expiry and OOM ownership remain tested at the applicable bounds. The exact updated publication branch passed 2,197 tests and 513 subtests, with 22 skips, 3 deselections and actual sqlite-vec enabled. Log SHA256:
0217353d4bafefb23ea9d12f7c83e50f1e832763549d6ff3afc6af9bafb61f37. Configured Ruff, Python3.10 syntax and scoped privacy/commit-identity checks passed. Hosted checks for this new head are pending.Earlier validation
6d49be4e1f7dc4925f00451277c967401640a4c2f7a78a0b54675ff5418b5975.a62cabdfba1480ffe8f819548b59b24bcd1c50117fbd12abd74a55b8a77874e0. This branch excludes the unrelated scheduler fixture follow-up.301089dab0102f2608cb91ba6e831d88bac148ec557cacf5dee5e06dc02c00bb.e4371cc1d581a19d784aea2e7dc46fa92d198e37.Earlier native diagnostic results
These measurements apply to source
2844072af8857a903ac9750a0f54026f9a33a51c, before the effective-limit compatibility guard. Preserve the failed findings; do not attribute these native receipts to the current head. The next combined-source diagnostic will recheck defaults and prior explicit-eight compatibility.Draft #811 preserves the native Qwen request order across bounded calls. Source
2844072af8857a903ac9750a0f54026f9a33a51ckeeps models, model revisions, dtype, dimensions, defaults and result caps unchanged. Actual ModelServer handlers run in process; this is a direct serial CUDA diagnostic, without socket/RPC timing.Three separately bounded cells completed 90 timed records, three warmups, 3,741 input rows and 267 native forwards. Each loaded one model. Controller durations were 12.087, 15.176 and 11.695 seconds. Cleanup was verified for every owned container, with no timeout or OOM. Root and an independent reviewer recomputed the raw comparisons, work counts, repeatability and timing summaries.
Default passes 30/30 comparisons; explicit-eight still passes 21/30. All 24 default embedding comparisons are exact, and their ordered native feature records match the same-repeat reference: input IDs, attention masks, position IDs or explicit absence, shapes, dtypes and observed options. These recorded digests were compared; tokens were not independently regenerated. Every mode's outputs and feature records repeated exactly across its three repetitions. Reranker scores pass tolerance but are not exact; maximum difference is
4.172325134277344e-7. Its feature-parity gate is not applicable.The unchanged reference-first tolerance is
abs(candidate-reference) <= 0.0001 + 0.001 * abs(reference). Default improvement does not override explicit-eight failures.Instrumented timings
Medians of three operations, including synchronized CUDA work and CPU feature-observation overhead:
For 100 mixed embeddings, default/reference is
403.471858 / 397.146104 = 1.015928027. Both now use native shapes[32x778,32x70,32x70,4x70]. The earlier wrapper measured 1000.544282 ms against its 390.950397 ms reference in a separate diagnostic. This is evidence of the corrected grouping and measured diagnostic timing, not a controlled production p95 comparison.Mixed reranking still has default/reference
631.852592 / 424.322110 = 1.489087128. Its shapes remain[64x779,36x779]versus reference[64x779,36x72]; that performance gap remains open.Explicit-eight regression detail
Old and new native reference arrays are exact. Each finding below repeats identically three times:
The correction worsens mixed32/33 under explicit-eight, and mixed100 has a larger worst error despite fewer failed rows. Faster failed cases are not accepted as improvements. Prior padded-eight evidence already showed differences with matching token IDs, masks and effective positions, so padding alone is not established as the remedy. The specific numerical mechanism remains unproven.
Evidence and limits
9822e3503158b36043c8fa6f111d903c1f2e1b9746fbd49bedffc22d666a5d5e22451e02d3047ddd65aec9b6fbdee6021ba257415220a0cef5da5a17a4518842f923d1c44f9267f216c39bd2b1618e56b20c32cd1bbd44c9da9df8bd97c78f909d9902987844797b2dfb4950081560499d6f041205865af3bebb9c7eea1bf773a035139b3400af0e4dd18aaad4f2c1824dcfebb26a696f865c7cb82312e4af5926ec9c8ec6554a59a9de759a60beb064c226b104e25476f99ecbdda0ac73fa85Combined acceptance remains false. Retrieval rankings, concurrent traffic, production p95, whole-process memory drift, final soak, MPS and thermal behavior remain unvalidated by this diagnostic. Only public model artifacts and generated synthetic inputs were used. No personal memories, transcripts or credentials were included. No issue is closed, main merge performed or release approved.