-
Notifications
You must be signed in to change notification settings - Fork 951
Add Float 16 Datatype Support #25707
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
… tvaron3/vs16Datatype
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request adds support for the Float16 datatype in the vector embedding policy for Azure Cosmos DB containers.
Key Changes:
- Added
VectorDataTypeFloat16constant for 16-bit floating point vector embeddings - Added comprehensive test coverage for all vector data types (float32, float16, int8, uint8)
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| sdk/data/azcosmos/vector_embedding_policy.go | Adds the Float16 constant definition with appropriate documentation |
| sdk/data/azcosmos/emulator_cosmos_container_test.go | Adds test function that validates container creation and property persistence for all vector data types including the new float16 type |
| createdResp, err := database.CreateContainer(context.TODO(), properties, nil) | ||
| if err != nil { | ||
| t.Fatalf("Failed to create container with %s data type: %v", dt.name, err) | ||
| } | ||
|
|
||
| container, _ := database.NewContainer(containerID) | ||
| readResp, err := container.Read(context.TODO(), nil) | ||
| if err != nil { | ||
| t.Fatalf("Failed to read container: %v", err) | ||
| } | ||
|
|
||
| readProperties := readResp.ContainerProperties | ||
| if readProperties.VectorEmbeddingPolicy == nil { | ||
| t.Fatalf("Expected VectorEmbeddingPolicy to be set") | ||
| } | ||
|
|
||
| if len(readProperties.VectorEmbeddingPolicy.VectorEmbeddings) != 1 { | ||
| t.Fatalf("Expected 1 vector embedding, got %d", len(readProperties.VectorEmbeddingPolicy.VectorEmbeddings)) | ||
| } | ||
|
|
||
| embedding := readProperties.VectorEmbeddingPolicy.VectorEmbeddings[0] | ||
| if embedding.DataType != dt.dataType { | ||
| t.Errorf("Expected data type %s, got %s", dt.dataType, embedding.DataType) | ||
| } | ||
|
|
||
| if embedding.Path != "/vector1" { | ||
| t.Errorf("Expected path /vector1, got %s", embedding.Path) | ||
| } | ||
|
|
||
| if embedding.Dimensions != 256 { | ||
| t.Errorf("Expected dimensions 256, got %d", embedding.Dimensions) | ||
| } | ||
|
|
||
| if embedding.DistanceFunction != VectorDistanceFunctionEuclidean { | ||
| t.Errorf("Expected distance function euclidean, got %s", embedding.DistanceFunction) | ||
| } | ||
|
|
||
| // Clean up | ||
| _, err = container.Delete(context.TODO(), nil) | ||
| if err != nil { | ||
| t.Fatalf("Failed to delete container %s: %v", containerID, err) | ||
| } | ||
|
|
||
| _ = createdResp // Avoid unused variable warning |
Copilot
AI
Dec 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable createdResp is assigned but never used meaningfully. The comment // Avoid unused variable warning suggests this was done intentionally, but it would be cleaner to use the blank identifier _ at assignment: _, err := database.CreateContainer(...) instead of assigning to createdResp and then discarding it later.
API Change CheckAPIView identified API level changes in this PR and created the following API reviews |
Description
Adds the float16 datatype for the vector embedding policy and adds a test creating a policy for each data type