Skip to content

Commit 220038e

Browse files
Rachit-Chaudhary11Signed-off-by: Rachit Chaudhary - r0c0axe
andauthored
Support GPU_BRUTE_FORCE index for Milvus (zilliztech#476)
Signed-off-by: Rachit Chaudhary <rachit.chaudhary@outlook.com> Co-authored-by: Signed-off-by: Rachit Chaudhary - r0c0axe <Rachit.Chaudhary@walmart.com>
1 parent 6832120 commit 220038e

4 files changed

Lines changed: 59 additions & 0 deletions

File tree

vectordb_bench/backend/clients/api.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class IndexType(str, Enum):
2525
ES_HNSW = "hnsw"
2626
ES_IVFFlat = "ivfflat"
2727
GPU_IVF_FLAT = "GPU_IVF_FLAT"
28+
GPU_BRUTE_FORCE = "GPU_BRUTE_FORCE"
2829
GPU_IVF_PQ = "GPU_IVF_PQ"
2930
GPU_CAGRA = "GPU_CAGRA"
3031
SCANN = "scann"

vectordb_bench/backend/clients/milvus/cli.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,26 @@ def MilvusGPUIVFFlat(**parameters: Unpack[MilvusGPUIVFTypedDict]):
194194
**parameters,
195195
)
196196

197+
@cli.command()
198+
@click_parameter_decorators_from_typed_dict(MilvusGPUBruteForceTypedDict)
199+
def MilvusGPUBruteForce(**parameters: Unpack[MilvusGPUBruteForceTypedDict]):
200+
from .config import GPUBruteForceConfig, MilvusConfig
201+
202+
run(
203+
db=DBTYPE,
204+
db_config=MilvusConfig(
205+
db_label=parameters["db_label"],
206+
uri=SecretStr(parameters["uri"]),
207+
user=parameters["user_name"],
208+
password=SecretStr(parameters["password"]),
209+
),
210+
db_case_config=GPUBruteForceConfig(
211+
metric_type=parameters["metric_type"],
212+
limit=parameters["limit"], # top-k for search
213+
),
214+
**parameters,
215+
)
216+
197217

198218
class MilvusGPUIVFPQTypedDict(
199219
CommonTypedDict,

vectordb_bench/backend/clients/milvus/config.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def is_gpu_index(self) -> bool:
4040
IndexType.GPU_CAGRA,
4141
IndexType.GPU_IVF_FLAT,
4242
IndexType.GPU_IVF_PQ,
43+
IndexType.GPU_BRUTE_FORCE,
4344
]
4445

4546
def parse_metric(self) -> str:
@@ -184,6 +185,37 @@ def search_param(self) -> dict:
184185
}
185186

186187

188+
class GPUBruteForceConfig(MilvusIndexConfig, DBCaseConfig):
189+
limit: int = 10 # Default top-k for search
190+
metric_type: str # Metric type (e.g., 'L2', 'IP', etc.)
191+
index: IndexType = IndexType.GPU_BRUTE_FORCE # Index type set to GPU_BRUTE_FORCE
192+
193+
def index_param(self) -> dict:
194+
"""
195+
Returns the parameters for creating the GPU_BRUTE_FORCE index.
196+
No additional parameters required for index building.
197+
"""
198+
return {
199+
"metric_type": self.parse_metric(), # Metric type for distance calculation (L2, IP, etc.)
200+
"index_type": self.index.value, # GPU_BRUTE_FORCE index type
201+
"params": {}, # No additional parameters for GPU_BRUTE_FORCE
202+
}
203+
204+
def search_param(self) -> dict:
205+
"""
206+
Returns the parameters for performing a search on the GPU_BRUTE_FORCE index.
207+
Only metric_type and top-k (limit) are needed for search.
208+
"""
209+
return {
210+
"metric_type": self.parse_metric(), # Metric type for search
211+
"params": {
212+
"nprobe": 1, # For GPU_BRUTE_FORCE, set nprobe to 1 (brute force search)
213+
"limit": self.limit, # Top-k for search
214+
},
215+
}
216+
217+
218+
187219
class GPUIVFPQConfig(MilvusIndexConfig, DBCaseConfig):
188220
nlist: int = 1024
189221
m: int = 0
@@ -261,4 +293,5 @@ def search_param(self) -> dict:
261293
IndexType.GPU_IVF_FLAT: GPUIVFFlatConfig,
262294
IndexType.GPU_IVF_PQ: GPUIVFPQConfig,
263295
IndexType.GPU_CAGRA: GPUCAGRAConfig,
296+
IndexType.GPU_BRUTE_FORCE: GPUBruteForceConfig,
264297
}

vectordb_bench/frontend/config/dbCaseConfigs.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ class CaseConfigInput(BaseModel):
173173
IndexType.GPU_IVF_FLAT.value,
174174
IndexType.GPU_IVF_PQ.value,
175175
IndexType.GPU_CAGRA.value,
176+
IndexType.GPU_BRUTE_FORCE.value,
176177
],
177178
},
178179
)
@@ -562,6 +563,7 @@ class CaseConfigInput(BaseModel):
562563
IndexType.IVFSQ8.value,
563564
IndexType.GPU_IVF_FLAT.value,
564565
IndexType.GPU_IVF_PQ.value,
566+
IndexType.GPU_BRUTE_FORCE.value,
565567
],
566568
)
567569

@@ -579,6 +581,7 @@ class CaseConfigInput(BaseModel):
579581
IndexType.IVFSQ8.value,
580582
IndexType.GPU_IVF_FLAT.value,
581583
IndexType.GPU_IVF_PQ.value,
584+
IndexType.GPU_BRUTE_FORCE.value,
582585
],
583586
)
584587

@@ -703,6 +706,7 @@ class CaseConfigInput(BaseModel):
703706
IndexType.GPU_CAGRA.value,
704707
IndexType.GPU_IVF_PQ.value,
705708
IndexType.GPU_IVF_FLAT.value,
709+
IndexType.GPU_BRUTE_FORCE.value,
706710
],
707711
)
708712

@@ -720,6 +724,7 @@ class CaseConfigInput(BaseModel):
720724
IndexType.GPU_CAGRA.value,
721725
IndexType.GPU_IVF_PQ.value,
722726
IndexType.GPU_IVF_FLAT.value,
727+
IndexType.GPU_BRUTE_FORCE.value,
723728
],
724729
)
725730

0 commit comments

Comments
 (0)