Skip to content

[Cosmos] DiskANN vector query returns nondeterministic top-K on unchanged container (product quantizer; spherical unaffected) — likely service-side, filing for routing #48414

Description

@ASeabrook36

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

  1. 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.
  2. On differing executions of the same query, retrievedDocumentCount and indexUtilizationRatio (0.02) were identical. The plan appears stable; the traversal result varies.

Questions

  1. 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?
  2. 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?
  3. 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.

Metadata

Metadata

Labels

ClientThis issue points to a problem in the data-plane of the library.CosmosService AttentionWorkflow: This issue is responsible by Azure service team.customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions