Skip to content

Commit bef04bf

Browse files
CascadingRadiumCopilotLikith101capemox
authored
MB-59670: GPU-Accelerated Vector Search (#77)
- Allow Fields to utilize GPU for indexing and querying by adding a GPU flag to the `FieldIndexingOptions` associated with a field. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Likith B <62029862+Likith101@users.noreply.github.com> Co-authored-by: Likith B <likith.b@couchbase.com> Co-authored-by: Gautham Krithiwas <gautham.k@couchbase.com>
1 parent c26154f commit bef04bf

3 files changed

Lines changed: 27 additions & 0 deletions

File tree

indexing_options.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const (
2424
SkipFreqNorm
2525
SkipDVCompression
2626
SkipDVChunking
27+
GPU
2728
)
2829

2930
const (
@@ -72,6 +73,10 @@ func (o FieldIndexingOptions) SkipDVChunking() bool {
7273
return o&SkipDVChunking != 0
7374
}
7475

76+
func (o FieldIndexingOptions) UseGPU() bool {
77+
return o&GPU != 0
78+
}
79+
7580
func (o FieldIndexingOptions) String() string {
7681
rv := ""
7782
if o.IsIndexed() {
@@ -113,5 +118,11 @@ func (o FieldIndexingOptions) String() string {
113118
}
114119
rv += "DV_CHUNKING"
115120
}
121+
if o.UseGPU() {
122+
if rv != "" {
123+
rv += ", "
124+
}
125+
rv += "GPU"
126+
}
116127
return rv
117128
}

indexing_options_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ func TestFieldIndexingOptions(t *testing.T) {
2626
includeTermVectors bool
2727
docValues bool
2828
skipFreqNorm bool
29+
useGPU bool
2930
}{
3031
{
3132
options: IndexField | StoreField | IncludeTermVectors,
@@ -88,6 +89,12 @@ func TestFieldIndexingOptions(t *testing.T) {
8889
docValues: true,
8990
includeTermVectors: false,
9091
},
92+
{
93+
options: IndexField | SkipFreqNorm | GPU,
94+
isIndexed: true,
95+
skipFreqNorm: true,
96+
useGPU: true,
97+
},
9198
}
9299

93100
for _, test := range tests {
@@ -112,5 +119,9 @@ func TestFieldIndexingOptions(t *testing.T) {
112119
if actuallyFreqNormValues != test.skipFreqNorm {
113120
t.Errorf("expected docValue to be %v, got %v for %d", test.skipFreqNorm, actuallyFreqNormValues, test.options)
114121
}
122+
actuallyUseGPU := test.options.UseGPU()
123+
if actuallyUseGPU != test.useGPU {
124+
t.Errorf("expected useGPU to be %v, got %v for %d", test.useGPU, actuallyUseGPU, test.options)
125+
}
115126
}
116127
}

vector.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,18 @@
1818
package index
1919

2020
type VectorField interface {
21+
// Name of the field
22+
Name() string
23+
// The vector data
2124
Vector() []float32
2225
// Dimensionality of the vector
2326
Dims() int
2427
// Similarity metric to be used for scoring the vectors
2528
Similarity() string
2629
// nlist/nprobe config (recall/latency) the index is optimized for
2730
IndexOptimizedFor() string
31+
// Field indexing options
32+
Options() FieldIndexingOptions
2833
}
2934

3035
// -----------------------------------------------------------------------------

0 commit comments

Comments
 (0)