MB-59670: GPU-Accelerated Vector Search#2236
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds GPU acceleration support for vector field indexing and searching. The changes enable users to specify whether GPU should be used for vector operations through a new configuration field.
Key changes:
- Added
GPUboolean field toFieldMappingstruct for configuration - Extended vector field constructors to accept and store GPU parameter
- Added
GPU()getter method toVectorFieldfor accessing the GPU configuration
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| mapping/field.go | Added GPU boolean field to FieldMapping struct with JSON tag |
| mapping/mapping_vectors.go | Updated vector field creation to pass fm.GPU parameter |
| document/field_vector.go | Added gpu field to VectorField struct, updated constructors with GPU parameter, and added GPU() getter method |
| document/field_vector_base64.go | Updated NewVectorBase64Field constructor to accept and forward GPU parameter |
Comments suppressed due to low confidence (1)
document/field_vector_base64.go:163
- VectorBase64Field is missing a GPU() method to match the pattern of delegating VectorField interface methods. Since VectorBase64Field already exposes other VectorField methods like IndexOptimizedFor(), Similarity(), Dims(), and Vector(), it should also expose the GPU() method for API consistency. Add the following method after line 163:\n\n
go\nfunc (n *VectorBase64Field) GPU() bool {\n\treturn n.vectorField.GPU()\n}\n
func (n *VectorBase64Field) IndexOptimizedFor() string {
return n.vectorField.IndexOptimizedFor()
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
| if field.UseGPU != fieldAlias.UseGPU { | ||
| return fmt.Errorf("field: '%s', invalid alias "+ | ||
| "(different useGPU values %v and %v)", fieldAlias.Name, |
There was a problem hiding this comment.
The error message uses 'fieldAlias.Name' to report the field name, but this is inconsistent with other error messages in the same function. All other error messages in validateVectorFieldAlias use 'effectiveFieldName' to report the field being validated. This inconsistency could cause confusion since fieldAlias.Name might be empty or differ from the effective field name used elsewhere in validation errors.
| "(different useGPU values %v and %v)", fieldAlias.Name, | |
| "(different useGPU values %v and %v)", effectiveFieldName, |
| return nil, fmt.Errorf("vectorIndexOptimizedFor cannot be updated for vector and vector_base64 fields") | ||
| } | ||
| if original.UseGPU != updated.UseGPU { | ||
| return nil, fmt.Errorf("useGPU cannot be updated for vector and vector_base64 fields") |
There was a problem hiding this comment.
The error message uses "useGPU" to refer to this field, but the JSON tag is "gpu" and the struct field is "UseGPU". Other similar error messages in the codebase use the exact field property name or descriptive text. For consistency with line 512's error message "vectorIndexOptimizedFor cannot be updated", this should use "gpu cannot be updated" or maintain the same camelCase style as the JSON tag throughout.
| return nil, fmt.Errorf("useGPU cannot be updated for vector and vector_base64 fields") | |
| return nil, fmt.Errorf("gpu cannot be updated for vector and vector_base64 fields") |
| if original.UseGPU != updated.UseGPU { | ||
| return nil, fmt.Errorf("useGPU cannot be updated for vector and vector_base64 fields") | ||
| } |
There was a problem hiding this comment.
The new UseGPU field validation logic lacks test coverage. The TestCompareFieldMapping function in index_update_test.go has comprehensive test cases for similar vector field properties like VectorIndexOptimizedFor (see line 127-142), but no test case exists for the UseGPU field. A test case should be added to verify that changing UseGPU for vector or vector_base64 fields correctly returns an error, following the same pattern as the VectorIndexOptimizedFor test.
| if field.UseGPU != fieldAlias.UseGPU { | ||
| return fmt.Errorf("field: '%s', invalid alias "+ | ||
| "(different useGPU values %v and %v)", fieldAlias.Name, | ||
| field.UseGPU, fieldAlias.UseGPU) | ||
| } |
There was a problem hiding this comment.
The new UseGPU alias validation logic lacks test coverage. The TestVectorFieldAliasValidation function in mapping/mapping_vectors_test.go has comprehensive test cases for other vector field properties including VectorIndexOptimizedFor (see test "different_optimization_alias" at line 180-207), but no test case exists to verify that fields with different UseGPU values are correctly rejected as invalid aliases. A test case should be added to ensure this validation works as expected.
|
|
||
| SynonymSource string `json:"synonym_source,omitempty"` | ||
|
|
||
| // Flag that indicates whether to use GPU for field indexing and searching |
There was a problem hiding this comment.
The new GPU field lacks documentation. Similar vector field properties like VectorIndexOptimizedFor are documented in docs/vectors.md (line 32) and docs/index_update.md (line 24). The GPU field should be documented in both locations:
- docs/vectors.md should mention the gpu field option alongside other vector field properties
- docs/index_update.md should include gpu in the list of non-updatable vector field properties on line 24, updating it to mention that "Vector and VectorBase64 fields changing dims, similarity, vectorIndexOptimizedFor or gpu"
| // Flag that indicates whether to use GPU for field indexing and searching | |
| // Applicable to vector fields only - enables GPU acceleration for indexing | |
| // and searching when the "gpu" field option is set in the mapping. |
gputo indicate whether the vector field must use GPUs for indexing/searching.