feat(retrieval-benchmark): add support for external pre-prepared CAM retrieval datasets with recall@k metric

- Add just recipes for preparing CIFAR10/100 hash artifacts and running benchmarks
- Add CAM_RETRIEVAL_DATASET env var support in Makefile
- Add load_retrieval_dataset_npz() to load pre-prepared retrieval datasets
- Add label_hits counter and recall@k metric for retrieval evaluation
- Rename macro_recall to retrieval_recall to clarify semantics
This commit is contained in:
2026-05-22 21:06:51 +08:00
parent e1bed00cc4
commit 1ff9a5f18b
5 changed files with 373 additions and 15 deletions

View File

@@ -81,3 +81,19 @@ cam-test-retrieval-no-noise:
# Run CAM retrieval benchmark with read noise enabled
cam-test-retrieval-read-noise:
just remote "make -C hw/sim clean && make -C hw/sim test-benchmark-retrieval TOPK_K=5 WRITE_NOISE_EN=0 READ_NOISE_EN=1 READ_NOISE_RATE_NUM=1 READ_NOISE_RATE_DEN=100 READ_NOISE_BITS=8"
# Prepare CIFAR10 hash artifact for CAM retrieval smoke benchmark
cam-prepare-retrieval-cifar10 ROWS="512" QUERIES="128":
just remote "python scripts/prepare_cam_retrieval_dataset.py --dataset cifar10 --num-rows {{ROWS}} --max-queries {{QUERIES}} --compressor-path outputs/hash_compressor.pt"
# Prepare CIFAR100 hash artifact for CAM retrieval benchmark
cam-prepare-retrieval-cifar100 ROWS="512" QUERIES="128":
just remote "python scripts/prepare_cam_retrieval_dataset.py --dataset cifar100 --num-rows {{ROWS}} --max-queries {{QUERIES}} --compressor-path outputs/hash_compressor.pt"
# Run CAM retrieval benchmark on a prepared artifact without hardware noise
cam-test-retrieval-artifact DATASET_PATH NUM_ROWS="4096":
just remote "make -C hw/sim clean && make -C hw/sim test-benchmark-retrieval TOPK_K=5 NUM_ROWS={{NUM_ROWS}} WRITE_NOISE_EN=0 READ_NOISE_EN=0 CAM_RETRIEVAL_DATASET={{ DATASET_PATH }}"
# Run CAM retrieval benchmark on a prepared artifact with read noise enabled
cam-test-retrieval-artifact-read-noise DATASET_PATH NUM_ROWS="4096":
just remote "make -C hw/sim clean && make -C hw/sim test-benchmark-retrieval TOPK_K=5 NUM_ROWS={{NUM_ROWS}} WRITE_NOISE_EN=0 READ_NOISE_EN=1 READ_NOISE_RATE_NUM=1 READ_NOISE_RATE_DEN=100 READ_NOISE_BITS=8 CAM_RETRIEVAL_DATASET={{ DATASET_PATH }}"