perf(test): gate benchmark loops and share GPU backend in test_deepseek4_unit
Merged
DU
3d ago+268+268+012345678901234567890123456789-244-244-012345678901234567890123456789
Based on main (d552394eb). Reduces test_deepseek4_unit GPU runtime without removing any test cases or assertions.
What
- Cause:
- In
mainrun43754866765,test_deepseek4_unittook 21.3 s on R9700 (gfx1201) and 10.3 s on Strix Halo (gfx1151). - Four GPU test functions (
test_ds4_flash_attention_streaming_topk_gpu,test_ds4_indexer_score_m32_gpuacross 30 cases,test_ds4_indexer_score_packed_small_gpuacross 4 cases, andtest_ds4_topk_block_radix_gpuacross 10 widths) ran unguardedmeasure_usmicrobenchmark loops (~8,355 unasserted GPU graph launches) during every defaultctestrun, whereastest_ds4_flash_attention_segmented_kv_gpuandtest_ds4_flash_attention_sparse_value_skip_gpualready gate timing onbool benchmark. - Single-device GPU tests called
ggml_backend_cuda_init(0)andggml_backend_free()31 separate times inside the same process.
- In
- Fix (
server/test/unit/test_deepseek4_unit.cpp):- Gate the
measure_ustiming loops in those four functions behindbool benchmark = false, preserving every functional check and assertion in default runs, and passbenchmark = truefrom the--bench-streaming-attn,--bench-indexer, and--bench-topkCLI flags. - Reuse a single shared device-0 GPU backend (
get_shared_gpu_backend(), released bySharedGpuBackendGuardonmain()exit) across single-device GPU tests. Multi-devicetest_hc_scratch_per_deviceandtest_cuda_graph_rebuild_generation_guardkeep their own dedicated backend instances.
- Gate the
Tests
- Verified syntax and warnings locally with
g++ -std=c++17 -fsyntax-only -Wall -Wextra -Wno-unused-parameter -Wno-unused-function -DLUCE_BACKEND_CUDA=1 -DGGML_USE_CUDAand validated the commit message with.github/ci/check_commit_messages.py. - Full GPU execution and timing delta will be verified by the
dgx-gb10(CUDA) andlucebox3(ROCm R9700 + Strix Halo) CI jobs.
Known limits, not addressed here
- Scoped solely to
server/test/unit/test_deepseek4_unit.cpp; other unit test binaries are unchanged.