Note on routing: I believe this is service-side (query engine / DiskANN traversal) rather than SDK behavior — the SDK faithfully returns what the service sends, and plan-level telemetry is identical across differing executions. Filing here as the nearest active public channel for the Python SDK; happy to be redirected, and happy to share a subscription ID privately for backend telemetry correlation.
Summary
The same vector query, issued repeatedly against the same unchanged container in immediate succession, sometimes returns a high-similarity document in its top-10 and sometimes does not. This occurs with the product quantizer at quantizationByteSize=256. Three containers built identically from identical data all show it. Three containers differing only by using the spherical quantizer show none of it across the same test.
Environment
- Azure Cosmos DB for NoSQL, serverless account, East US 2
- Container API version 2024-05-15; Python SDK
azure-cosmos, AAD auth (AzureCliCredential)
- Six validation containers: three product-quantizer, three spherical, otherwise identical
Configuration (product arm)
DiskANN index; quantizerType: product; quantizationByteSize: 256; indexingSearchListSize: 100; vectorIndexShardKey on a string property; embedding dataType: float32, 3072 dimensions, cosine. Spherical arm identical except quantizerType: spherical (no byte-size property, per documented mutual exclusivity). Hierarchical partition key (MultiHash, 3 levels).
Data
112,000 synthetic documents per container; each embedding is a random unit vector in 3072 dims. 30 documents overwritten with vectors constructed at cosine similarity 0.92–0.98 to corresponding query vectors — one known high-similarity answer per test query over a near-orthogonal noise floor (~0.07). All six containers loaded from a byte-identical SHA-256-verified artifact, single-threaded, same order. Every load: 112,000/112,000 written, zero failures, zero 429s, identical total RU to the decimal.
Query
SELECT TOP 10 c.chunkId, c.representationClass,
VectorDistance(c.embedding, @q, false, {'dataType':'float32'}) AS score
FROM c
WHERE c.tenantId = @tenant AND c.representationClass = @class
ORDER BY VectorDistance(c.embedding, @q, false, {'dataType':'float32'})
Identical query text and parameter values for every execution below.
Method
For each of the 30 seeded queries: the identical query issued 5 times back-to-back, single-threaded, one session (~7 minutes across all six containers). Index build confirmed complete first — x-ms-documentdb-collection-index-transformation-progress read 100 on all six before any query.
Results
| Container |
Quantizer |
Queries identical across all 5 repeats |
Queries where the answer appeared in only some repeats |
| Build A |
product/256 |
2/30 |
2 (answer present 2/5 and 3/5) |
| Build B |
product/256 |
5/30 |
4 (4/5, 3/5, 2/5, 3/5) |
| Build C |
product/256 |
1/30 |
4 (2/5, 2/5, 3/5, 3/5) |
| Build A |
spherical |
30/30 |
0 |
| Build B |
spherical |
8/30 |
0 |
| Build C |
spherical |
30/30 |
0 |
Most set variation everywhere is reordering among documents scoring 0.04–0.08 (expected — near-orthogonal random vectors). The concerning cases are the last column: a document scoring ~0.95 against the query absent from the top-10 on some executions and present on others, same query, same container, minutes apart.
Supporting observations
- An unscoped exhaustive scan (no shard-key predicate;
retrievedDocumentCount = 112,000) returned all 30 planted answers on every container on every run — the documents are present, correctly stored, and in the true exact top-10, including on executions where the indexed query missed them.
- On differing executions of the same query,
retrievedDocumentCount and indexUtilizationRatio (0.02) were identical. The plan appears stable; the traversal result varies.
Questions
- Is per-execution variation in DiskANN results expected for a static container — and is this magnitude (a ~0.95 document dropping from top-10 on ~1/3 of executions) within expected bounds?
- Does anything in the environment plausibly explain it — background index maintenance on serverless, partition-level behavior, or an interaction between
vectorIndexShardKey and product quantization at 256 bytes?
- Is the product/spherical difference here consistent with their documented characteristics?
Available on request
Full per-execution logs (returned document IDs + scores), a ~200-line standalone reproduction script, and the preserved unmodified containers. Planning to write this up publicly; would rather do so with an accurate account of the cause — any correction welcome.
Note on routing: I believe this is service-side (query engine / DiskANN traversal) rather than SDK behavior — the SDK faithfully returns what the service sends, and plan-level telemetry is identical across differing executions. Filing here as the nearest active public channel for the Python SDK; happy to be redirected, and happy to share a subscription ID privately for backend telemetry correlation.
Summary
The same vector query, issued repeatedly against the same unchanged container in immediate succession, sometimes returns a high-similarity document in its top-10 and sometimes does not. This occurs with the
productquantizer atquantizationByteSize=256. Three containers built identically from identical data all show it. Three containers differing only by using thesphericalquantizer show none of it across the same test.Environment
azure-cosmos, AAD auth (AzureCliCredential)Configuration (product arm)
DiskANN index;
quantizerType: product;quantizationByteSize: 256;indexingSearchListSize: 100;vectorIndexShardKeyon a string property; embeddingdataType: float32, 3072 dimensions, cosine. Spherical arm identical exceptquantizerType: spherical(no byte-size property, per documented mutual exclusivity). Hierarchical partition key (MultiHash, 3 levels).Data
112,000 synthetic documents per container; each embedding is a random unit vector in 3072 dims. 30 documents overwritten with vectors constructed at cosine similarity 0.92–0.98 to corresponding query vectors — one known high-similarity answer per test query over a near-orthogonal noise floor (~0.07). All six containers loaded from a byte-identical SHA-256-verified artifact, single-threaded, same order. Every load: 112,000/112,000 written, zero failures, zero 429s, identical total RU to the decimal.
Query
Identical query text and parameter values for every execution below.
Method
For each of the 30 seeded queries: the identical query issued 5 times back-to-back, single-threaded, one session (~7 minutes across all six containers). Index build confirmed complete first —
x-ms-documentdb-collection-index-transformation-progressread 100 on all six before any query.Results
Most set variation everywhere is reordering among documents scoring 0.04–0.08 (expected — near-orthogonal random vectors). The concerning cases are the last column: a document scoring ~0.95 against the query absent from the top-10 on some executions and present on others, same query, same container, minutes apart.
Supporting observations
retrievedDocumentCount= 112,000) returned all 30 planted answers on every container on every run — the documents are present, correctly stored, and in the true exact top-10, including on executions where the indexed query missed them.retrievedDocumentCountandindexUtilizationRatio(0.02) were identical. The plan appears stable; the traversal result varies.Questions
vectorIndexShardKeyand product quantization at 256 bytes?Available on request
Full per-execution logs (returned document IDs + scores), a ~200-line standalone reproduction script, and the preserved unmodified containers. Planning to write this up publicly; would rather do so with an accurate account of the cause — any correction welcome.