Skip to content

FIX #2562: send "dimensions" to Nvidia embedding NIM for variable-dimension models - #2561

Open
erichare wants to merge 5 commits into
mainfrom
fix/nvidia-embedding-dimensions
Open

FIX #2562: send "dimensions" to Nvidia embedding NIM for variable-dimension models#2561
erichare wants to merge 5 commits into
mainfrom
fix/nvidia-embedding-dimensions

Conversation

@erichare

@erichare erichare commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Summary

NvidiaEmbeddingRequest never carried dimensions, so the Collection/Table dimension never reached the NIM. For variable-dimension models (nvidia/llama-3.2-nv-embedqa-1b-v2: 384/512/768/1024/2048, default 2048) the NIM always returned 2048-dim vectors and vectorize failed:

EMBEDDING_PROVIDER_UNEXPECTED_RESPONSE: Embedding provider 'nvidia' did not return expected embedding length. Expect: '512'. Actual: '2048'.

Changes

  • NvidiaEmbeddingRequest.dimensions, serialized only when non-zero. The NIM rejects dimensions: 0 with HTTP 400, so it must be omitted (not zeroed) for fixed-dimension models.

Verification

  • Dev GPU-plane NIM, direct calls: no dimensions → 2048; 512 → 512; 384 → 384; 0 → HTTP 400.
  • ./mvnw test -Dtest=NvidiaEmbeddingClientTest,EmbeddingProviderErrorMessageTest,EmbeddingGatewayClientTest,OpenAiEmbeddingClientTest → 19 tests, 0 failures.

… models

NvidiaEmbeddingRequest never carried `dimensions`, so for
nvidia/llama-3.2-nv-embedqa-1b-v2 (384/512/768/1024/2048, default 2048)
the NIM always returned 2048-dim vectors and vectorize failed with
"did not return expected embedding length. Expect: '512'. Actual: '2048'".

- add `dimensions` to NvidiaEmbeddingRequest, omitted when 0 (NIM rejects 0)
- acceptsNvidiaDimensions(modelConfig): model has no fixed vector-dimension;
  fixed-dimension models (NV-Embed-QA, nv-embedqa-e5-v5) are unchanged
- NvidiaEmbeddingClientTest (WireMock) covers both cases
@github-actions

github-actions Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

📈 Unit Test Coverage Delta vs Main Branch

Metric Value
Main Branch 53.40%
This PR 53.44%
Delta 🟢 +0.04%
✅ Coverage improved!

@github-actions

github-actions Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Unit Test Coverage Report

Overall Project 53.44% 🍏
Files changed 100% 🍏

File Coverage
NvidiaEmbeddingProvider.java 95.31% 🍏
EmbeddingProvider.java 74.55% 🍏

@erichare erichare changed the title fix: send "dimensions" to Nvidia embedding NIM for variable-dimension models FIX #2562: send "dimensions" to Nvidia embedding NIM for variable-dimension models Aug 21, 2026
@erichare
erichare marked this pull request as ready for review August 21, 2026 17:50
@erichare
erichare requested a review from a team as a code owner August 21, 2026 17:50
@github-actions

github-actions Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

📉 Integration Test Coverage Delta vs Main Branch (dse69-it)

Metric Value
Main Branch 71.45%
This PR 71.44%
Delta 🔴 -0.01%
⚠️ Coverage decreased

@github-actions

github-actions Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Integration Test Coverage Report (dse69-it)

Overall Project 71.44% -0.03% 🍏
Files changed 25%

File Coverage
EmbeddingProvider.java 44.77% -1.14%
NvidiaEmbeddingProvider.java 15.63% -14.58%

@github-actions

github-actions Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

📉 Integration Test Coverage Delta vs Main Branch (hcd-it)

Metric Value
Main Branch 72.77%
This PR 72.76%
Delta 🔴 -0.01%
⚠️ Coverage decreased

@github-actions

github-actions Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Integration Test Coverage Report (hcd-it)

Overall Project 72.76% -0.03% 🍏
Files changed 25%

File Coverage
EmbeddingProvider.java 44.77% -1.14%
NvidiaEmbeddingProvider.java 15.63% -14.58%

@Hazel-Datastax Hazel-Datastax left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix is not generalized enough - it can only fix nvidia's problem but not others. I think the key problem is this line https://github.com/stargate/data-api/blob/main/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/VectorizeConfigValidator.java#L355 and specifically model.vectorDimension().get() != 0

it should't go inside this if block and the range dimension should be handled here: https://github.com/stargate/data-api/blob/main/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/VectorizeConfigValidator.java#L372 and add some tests here: https://github.com/stargate/data-api/blob/main/src/test/java/io/stargate/sgv2/jsonapi/api/v1/CreateCollectionIntegrationTest.java#L734

protected static boolean acceptsNvidiaDimensions(
EmbeddingProvidersConfig.EmbeddingProviderConfig.ModelConfig modelConfig) {
return modelConfig.parameters().stream()
.anyMatch(parameter -> parameter.name().equals("vectorDimension"));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we explain in java doc why parameter -> parameter.name().equals("vectorDimension") could decide whether models accept dimensions or not

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vectorize with nvidia/llama-3.2-nv-embedqa-1b-v2 returns 2048-dim vector when collection dimension is set (e.g. 512)

2 participants