feat(retrieval): add CAM retrieval benchmark with topk scoring and read noise support

- Add cocotb benchmark infrastructure under hw/sim/benchmarks/retrieval/ with Makefile
- Implement test_retrieval_benchmark.py supporting configurable topk-k, read/write noise
- Add cluster-based synthetic dataset generator with configurable bit-flip rates
- Add reference model functions: match_topk, match_topk_from_scores, score_rows_with_read_noise
- Add .justfile shortcuts: cam-test-retrieval-no-noise, cam-test-retrieval-read-noise
- Add TOPK_K to Verilator EXTRA_ARGS via cocotb-common.mk
- Add unit tests for topk sorting logic and stateful read-noise scoring
This commit is contained in:
2026-05-22 19:01:43 +08:00
parent 29f4cc91f6
commit e1bed00cc4
8 changed files with 503 additions and 2 deletions

View File

@@ -2,7 +2,7 @@ PYTHON ?= python
MODULE_TESTS := cam_core_banked candidate_fifo match_engine_pipeline cam_write_noise cam_read_noise popcount_pipeline topk_tracker result_serializer
TOP_CONFIGS := no_noise write_noise read_noise
.PHONY: help test-all test-top test-top-all test-modules test-module test-model test-perf clean $(MODULE_TESTS:%=test-module-%) $(TOP_CONFIGS:%=test-top-%)
.PHONY: help test-all test-top test-top-all test-modules test-module test-model test-perf clean $(MODULE_TESTS:%=test-module-%) $(TOP_CONFIGS:%=test-top-%) test-benchmark-retrieval
help:
@echo "Available hw/sim targets:"
@@ -15,6 +15,7 @@ help:
@echo " make test-module MODULE=cam_core_banked"
@echo " make test-modules"
@echo " make test-perf"
@echo " make test-benchmark-retrieval # 检索质量 benchmark非默认"
@echo " make test-all"
@echo " make clean"
@@ -42,6 +43,9 @@ test-model:
test-perf:
$(MAKE) -C tests/perf
test-benchmark-retrieval:
$(MAKE) -C benchmarks/retrieval
clean:
@for config in $(TOP_CONFIGS); do \
$(MAKE) -C tests/top/$$config clean || exit $$?; \
@@ -49,5 +53,6 @@ clean:
@for module in $(MODULE_TESTS); do \
$(MAKE) -C tests/modules/$$module clean || exit $$?; \
done
$(MAKE) -C benchmarks/retrieval clean
$(MAKE) -C tests/perf clean
rm -rf .pytest_cache tests/model/.pytest_cache