Skip to content

Commit 268e7ab

Browse files
Introduce Intel SVS (#749)
Signed-off-by: Alexandr Guzhva <alexanderguzhva@gmail.com>
1 parent cf09d63 commit 268e7ab

File tree

3 files changed

+228
-0
lines changed

3 files changed

+228
-0
lines changed

vectordb_bench/backend/clients/api.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ class IndexType(StrEnum):
4343
GPU_CAGRA = "GPU_CAGRA"
4444
SCANN = "scann"
4545
SCANN_MILVUS = "SCANN_MILVUS"
46+
SVS_VAMANA = "SVS_VAMANA"
47+
SVS_VAMANA_LVQ = "SVS_VAMANA_LVQ"
48+
SVS_VAMANA_LEANVEC = "SVS_VAMANA_LEANVEC"
4649
Hologres_HGraph = "HGraph"
4750
Hologres_Graph = "Graph"
4851
NONE = "NONE"

vectordb_bench/backend/clients/milvus/cli.py

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,169 @@ def MilvusGPUBruteForce(**parameters: Unpack[MilvusGPUBruteForceTypedDict]):
485485
)
486486

487487

488+
class MilvusSVSVamanaTypedDict(CommonTypedDict, MilvusTypedDict):
489+
svs_graph_max_degree: Annotated[
490+
int,
491+
click.option(
492+
"--svs-graph-max-degree",
493+
type=int,
494+
help="Maximum degree of the Vamana graph (4-256).",
495+
required=True,
496+
),
497+
]
498+
svs_construction_window_size: Annotated[
499+
int,
500+
click.option(
501+
"--svs-construction-window-size",
502+
type=int,
503+
help="Window size for graph construction.",
504+
required=False,
505+
default=40,
506+
show_default=True,
507+
),
508+
]
509+
svs_alpha: Annotated[
510+
float | None,
511+
click.option(
512+
"--svs-alpha",
513+
type=float,
514+
help="Pruning parameter (default: 1.2 for L2, 0.95 for IP/COSINE).",
515+
required=False,
516+
default=None,
517+
),
518+
]
519+
svs_storage_kind: Annotated[
520+
str,
521+
click.option(
522+
"--svs-storage-kind",
523+
type=click.Choice(
524+
["fp32", "fp16", "sqi8", "lvq4x0", "lvq4x4", "lvq4x8", "leanvec4x4", "leanvec4x8", "leanvec8x8"],
525+
case_sensitive=False,
526+
),
527+
help="Data storage format.",
528+
required=False,
529+
default="fp32",
530+
show_default=True,
531+
),
532+
]
533+
svs_search_window_size: Annotated[
534+
int | None,
535+
click.option(
536+
"--svs-search-window-size",
537+
type=int,
538+
help="Window size for search (1-10000).",
539+
required=False,
540+
default=None,
541+
),
542+
]
543+
svs_search_buffer_capacity: Annotated[
544+
int | None,
545+
click.option(
546+
"--svs-search-buffer-capacity",
547+
type=int,
548+
help="Buffer capacity for search priority queue (1-10000).",
549+
required=False,
550+
default=None,
551+
),
552+
]
553+
554+
555+
@cli.command()
556+
@click_parameter_decorators_from_typed_dict(MilvusSVSVamanaTypedDict)
557+
def MilvusSVSVamana(**parameters: Unpack[MilvusSVSVamanaTypedDict]):
558+
from .config import MilvusConfig, SVSVamanaConfig
559+
560+
run(
561+
db=DBTYPE,
562+
db_config=MilvusConfig(
563+
db_label=parameters["db_label"],
564+
uri=SecretStr(parameters["uri"]),
565+
user=parameters["user_name"],
566+
password=SecretStr(parameters["password"]) if parameters["password"] else None,
567+
num_shards=int(parameters["num_shards"]),
568+
replica_number=int(parameters["replica_number"]),
569+
),
570+
db_case_config=SVSVamanaConfig(
571+
svs_graph_max_degree=parameters["svs_graph_max_degree"],
572+
svs_construction_window_size=parameters["svs_construction_window_size"],
573+
svs_alpha=parameters["svs_alpha"],
574+
svs_storage_kind=parameters["svs_storage_kind"],
575+
svs_search_window_size=parameters["svs_search_window_size"],
576+
svs_search_buffer_capacity=parameters["svs_search_buffer_capacity"],
577+
),
578+
**parameters,
579+
)
580+
581+
582+
@cli.command()
583+
@click_parameter_decorators_from_typed_dict(MilvusSVSVamanaTypedDict)
584+
def MilvusSVSVamanaLVQ(**parameters: Unpack[MilvusSVSVamanaTypedDict]):
585+
from .config import MilvusConfig, SVSVamanaLVQConfig
586+
587+
run(
588+
db=DBTYPE,
589+
db_config=MilvusConfig(
590+
db_label=parameters["db_label"],
591+
uri=SecretStr(parameters["uri"]),
592+
user=parameters["user_name"],
593+
password=SecretStr(parameters["password"]) if parameters["password"] else None,
594+
num_shards=int(parameters["num_shards"]),
595+
replica_number=int(parameters["replica_number"]),
596+
),
597+
db_case_config=SVSVamanaLVQConfig(
598+
svs_graph_max_degree=parameters["svs_graph_max_degree"],
599+
svs_construction_window_size=parameters["svs_construction_window_size"],
600+
svs_alpha=parameters["svs_alpha"],
601+
svs_storage_kind=parameters["svs_storage_kind"],
602+
svs_search_window_size=parameters["svs_search_window_size"],
603+
svs_search_buffer_capacity=parameters["svs_search_buffer_capacity"],
604+
),
605+
**parameters,
606+
)
607+
608+
609+
class MilvusSVSVamanaLeanVecTypedDict(MilvusSVSVamanaTypedDict):
610+
svs_leanvec_dim: Annotated[
611+
int,
612+
click.option(
613+
"--svs-leanvec-dim",
614+
type=int,
615+
help="Dimensionality for LeanVec compression (0 = d/2).",
616+
required=False,
617+
default=0,
618+
show_default=True,
619+
),
620+
]
621+
622+
623+
@cli.command()
624+
@click_parameter_decorators_from_typed_dict(MilvusSVSVamanaLeanVecTypedDict)
625+
def MilvusSVSVamanaLeanVec(**parameters: Unpack[MilvusSVSVamanaLeanVecTypedDict]):
626+
from .config import MilvusConfig, SVSVamanaLeanVecConfig
627+
628+
run(
629+
db=DBTYPE,
630+
db_config=MilvusConfig(
631+
db_label=parameters["db_label"],
632+
uri=SecretStr(parameters["uri"]),
633+
user=parameters["user_name"],
634+
password=SecretStr(parameters["password"]) if parameters["password"] else None,
635+
num_shards=int(parameters["num_shards"]),
636+
replica_number=int(parameters["replica_number"]),
637+
),
638+
db_case_config=SVSVamanaLeanVecConfig(
639+
svs_graph_max_degree=parameters["svs_graph_max_degree"],
640+
svs_construction_window_size=parameters["svs_construction_window_size"],
641+
svs_alpha=parameters["svs_alpha"],
642+
svs_storage_kind=parameters["svs_storage_kind"],
643+
svs_search_window_size=parameters["svs_search_window_size"],
644+
svs_search_buffer_capacity=parameters["svs_search_buffer_capacity"],
645+
svs_leanvec_dim=parameters["svs_leanvec_dim"],
646+
),
647+
**parameters,
648+
)
649+
650+
488651
class MilvusGPUIVFPQTypedDict(
489652
CommonTypedDict,
490653
MilvusTypedDict,

vectordb_bench/backend/clients/milvus/config.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,65 @@ def search_param(self) -> dict:
442442
}
443443

444444

445+
class SVSVamanaConfig(MilvusIndexConfig, DBCaseConfig):
446+
svs_graph_max_degree: int
447+
svs_construction_window_size: int = 40
448+
svs_alpha: float | None = None
449+
svs_storage_kind: str = "fp32"
450+
svs_search_window_size: int | None = None
451+
svs_search_buffer_capacity: int | None = None
452+
index: IndexType = IndexType.SVS_VAMANA
453+
454+
def index_param(self) -> dict:
455+
params = {
456+
"svs_graph_max_degree": self.svs_graph_max_degree,
457+
"svs_construction_window_size": self.svs_construction_window_size,
458+
"svs_storage_kind": self.svs_storage_kind,
459+
}
460+
if self.svs_alpha is not None:
461+
params["svs_alpha"] = self.svs_alpha
462+
return {
463+
"metric_type": self.parse_metric(),
464+
"index_type": self.index.value,
465+
"params": params,
466+
}
467+
468+
def search_param(self) -> dict:
469+
return {
470+
"metric_type": self.parse_metric(),
471+
"params": {
472+
"svs_search_window_size": self.svs_search_window_size,
473+
"svs_search_buffer_capacity": self.svs_search_buffer_capacity,
474+
},
475+
}
476+
477+
478+
class SVSVamanaLVQConfig(SVSVamanaConfig):
479+
svs_storage_kind: str = "lvq4x4"
480+
index: IndexType = IndexType.SVS_VAMANA_LVQ
481+
482+
483+
class SVSVamanaLeanVecConfig(SVSVamanaConfig):
484+
svs_storage_kind: str = "leanvec4x4"
485+
svs_leanvec_dim: int = 0
486+
index: IndexType = IndexType.SVS_VAMANA_LEANVEC
487+
488+
def index_param(self) -> dict:
489+
params = {
490+
"svs_graph_max_degree": self.svs_graph_max_degree,
491+
"svs_construction_window_size": self.svs_construction_window_size,
492+
"svs_storage_kind": self.svs_storage_kind,
493+
"svs_leanvec_dim": self.svs_leanvec_dim,
494+
}
495+
if self.svs_alpha is not None:
496+
params["svs_alpha"] = self.svs_alpha
497+
return {
498+
"metric_type": self.parse_metric(),
499+
"index_type": self.index.value,
500+
"params": params,
501+
}
502+
503+
445504
_milvus_case_config = {
446505
IndexType.AUTOINDEX: AutoIndexConfig,
447506
IndexType.HNSW: HNSWConfig,
@@ -459,4 +518,7 @@ def search_param(self) -> dict:
459518
IndexType.GPU_CAGRA: GPUCAGRAConfig,
460519
IndexType.GPU_BRUTE_FORCE: GPUBruteForceConfig,
461520
IndexType.SCANN_MILVUS: SCANNConfig,
521+
IndexType.SVS_VAMANA: SVSVamanaConfig,
522+
IndexType.SVS_VAMANA_LVQ: SVSVamanaLVQConfig,
523+
IndexType.SVS_VAMANA_LEANVEC: SVSVamanaLeanVecConfig,
462524
}

0 commit comments

Comments
 (0)