Skip to content

Python: handle empty NVIDIA embedding batches - #14859

Open
Twiink wants to merge 1 commit into
microsoft:mainfrom
Twiink:fix/nvidia-empty-embeddings-20261122
Open

Twiink wants to merge 1 commit into
microsoft:mainfrom
Twiink:fix/nvidia-empty-embeddings-20261122

Conversation

@Twiink

@Twiink Twiink commented Nov 22, 2026

Copy link
Copy Markdown

Motivation and Context

An empty document batch sent to NVIDIA embeddings with the default batch size raises ValueError: range() arg 3 must not be zero. The same empty input already returns no vectors when a positive batch size is provided. Keep the loop step positive for the default empty case, producing the same empty result without a provider request.

Description

Regression coverage checks both the raw and numpy APIs with default and explicit batch sizes. Two default-size cases fail on unchanged source, while the explicit-size controls pass.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the SK Contribution Guidelines and applicable formatting checks
  • Relevant unit tests pass, with new regression coverage
  • Existing non-empty batching behavior is preserved

All 40 NVIDIA connector tests, Ruff lint/format, and git diff --check pass locally. No live provider call was made.

Prepared with AI assistance and verified locally.

@Twiink
Twiink requested a review from a team as a code owner November 22, 2026 06:47
Copilot AI balanced review requested due to automatic review settings November 22, 2026 06:47
@Twiink
Twiink temporarily deployed to github-app-auth November 22, 2026 06:47 — with GitHub Actions Inactive

Copilot AI 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.

🟢 Approval recommended

There are no active review issues for the NVIDIA embedding connector’s empty-batch handling change.

No open issues 🎉

What changed in this PR

Fixes empty-batch handling in the Python NVIDIA embedding connector so the default batch size returns no vectors without raising an error or making a provider request.

Changes:

  • Adds a positive fallback loop step while preserving non-empty batching behavior.
  • Adds regression tests for raw and NumPy APIs with default and explicit batch sizes, including checks that no provider request occurs.
File Description
python/​tests/​unit/​connectors/​ai/​nvidia/​services/​test_nvidia_text_embedding.py Tests empty results and absence of provider calls across both APIs and batch-size options.
python/​semantic_kernel/​connectors/​ai/​nvidia/​services/​nvidia_text_embedding.py Prevents a zero loop step for empty input with the default batch size.

Review effort: Balanced

This branch was previously deployed

1 inactive deployment
github-app-auth — d73c863e Deployed Nov 22, 2026 by Twiink via add_label #29795
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.

2 participants