Repository navigation
spark-model: reserve lazy FP8->BF16 copies in the KV budget (#71) - #83
Conversation
With ATLAS_CUBLAS_GEMM, ATLAS_CUTLASS_GEMM or ATLAS_FP8_ROWWISE set, dequant_fp8_bf16_cached materialises a BF16 [N,K] copy of each FP8 projection on the first prefill. That happens after the KV pool is sized, so the copies sit outside the memory budget. On a unified-memory GB10 at util 0.88 the 27B dropped to 2.1 GB MemAvailable (reiner job 262). The KV sizing now reserves the upper bound up front: numel * 2 over the store's resident FP8 matrices, excluding routed experts, which run the MoE kernels and never reach the dequant. The KV pool shrinks by that amount, and a config that cannot fit refuses at boot instead of hanging the box on the first request. With the flags off the reserve is 0 and every log line and number is unchanged. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
Validated on GB10: reiner job 274, arm C71. Setup: merge-train tree
The reserve is the documented superset (every resident FP8 matrix except routed experts), so it is conservative. Even so, the 27B keeps 552k KV tokens at util 0.88. |
|
Merged as part of the GB10 merge train (main Gates on the combined tree:
Tree check: |
Fixes the OOM hazard logged on #71 (found while validating #77).
Problem
With
ATLAS_CUBLAS_GEMM=1,ATLAS_CUTLASS_GEMM=1orATLAS_FP8_ROWWISE=1,dequant_fp8_bf16_cachedmaterialises a BF16[N,K]copy of each FP8 projection on the first prefill that routes it through cuBLASLt or CUTLASS BF16. The KV pool is sized before that, so the copies sit outside the memory budget. On a unified-memory GB10,nvidia/Qwen3.8-27B-NVFP4at util 0.88 planned 54.2 GB pre-KV + 49.9 GB KV. The first prefill's copies then took the box to 2.1 GB MemAvailable, and the watchdog killed the serve (job 262).Fix
factory/build.rsKV sizing now subtractsops::lazy_bf16_reserve(&store)next to the inference reserve.numel * 2over the store's resident FP8 matrices, which is the superset the dequant can reach.KV cache:line gains a+ X GB lazy BF16term. A config that cannot fit now refuses at boot with the flag named in the error, instead of hanging the box on the first request.Validation
clippy -p spark-model --tests; unit tests cover the byte count, including routed-expert exclusion, and the flag predicate.ATLAS_CUBLAS_GEMM=1, util 0.88, with 2.6k and 10k prefills. Pass = the reserve is logged, the prefills run, and MemAvailable stays clear of the watchdog.