feat: vectorize CAM retrieval with NumPy and add multi-worker support

- Replace scalar hamming distance with NumPy bitwise_count for batch retrieval
- Add ThreadPoolExecutor-based multi-worker query parallelism
- Improve missing dataset error message with generation command hint
- Increase DEFAULT_MAX_QUERIES from 128 to 8192 for meaningful throughput tests
This commit is contained in:
2026-06-04 16:57:53 +08:00
parent e5b764520c
commit b5a40819cc
5 changed files with 283 additions and 43 deletions

View File

@@ -1,20 +1,27 @@
from __future__ import annotations
import csv
import importlib.util
import sys
from pathlib import Path
HW_SIM_DIR = Path(__file__).resolve().parents[1] / "hw" / "sim"
if str(HW_SIM_DIR) not in sys.path:
sys.path.insert(0, str(HW_SIM_DIR))
if str(HW_SIM_DIR) in sys.path:
sys.path.remove(str(HW_SIM_DIR))
sys.path.insert(0, str(HW_SIM_DIR))
benchmark_path = HW_SIM_DIR / "benchmarks" / "retrieval" / "test_retrieval_benchmark.py"
spec = importlib.util.spec_from_file_location("hw_retrieval_benchmark", benchmark_path)
assert spec is not None
assert spec.loader is not None
hw_retrieval_benchmark = importlib.util.module_from_spec(spec)
sys.modules[spec.name] = hw_retrieval_benchmark
spec.loader.exec_module(hw_retrieval_benchmark)
from benchmarks.retrieval.test_retrieval_benchmark import ( # noqa: E402
QueryTiming,
build_hardware_performance,
summarize_query_timings,
write_outputs,
)
QueryTiming = hw_retrieval_benchmark.QueryTiming
build_hardware_performance = hw_retrieval_benchmark.build_hardware_performance
summarize_query_timings = hw_retrieval_benchmark.summarize_query_timings
write_outputs = hw_retrieval_benchmark.write_outputs
def test_summarize_query_timings_uses_query_only_accept_to_last_cycles() -> None: