fix(kvcache): count per-tier bytes when data reaches a tier via eviction#420
fix(kvcache): count per-tier bytes when data reaches a tier via eviction#420jay-tau wants to merge 2 commits into
Conversation
|
MLCommons CLA bot: |
|
@hazemawadalla , can you review? |
|
recheck |
|
thanks let me check it one more time today |
MultiTierCache._demote_entry() incremented the offload counters and storage_tokens_processed but never the destination tier's byte counter, so tier_cpu_kv_bytes_written / tier_storage_kv_bytes_written (and the _gb and _write_bandwidth_gbps values derived from them in results.json) stayed 0 on any multi-tier setup where data reaches CPU or NVMe through eviction rather than direct allocation. The read side of the demotion (data read out of the source tier) was likewise untracked. Increment the source tier's read-bytes counter and the destination tier's written-bytes counter inside the existing stats lock, mirroring the accounting already done on the direct-allocation and access paths. Strengthen the three-tier eviction cascade test to assert the demote-only byte counters are non-zero and that bytes read out of a tier equal the bytes written into the tier below it. Fixes mlcommons#408 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
efc9407 to
c4692fa
Compare
@hazemawadalla If this change looks good to you, can you open a new PR so that we can get this in? Resolving the CLA issue may take some time. |
|
Do I need to do anything beyond replying to the mail that I
received related to the CLA?
Joel
…On Fri, 12 Jun 2026 at 22:06, David Slik ***@***.***> wrote:
*dslik* left a comment (mlcommons/storage#420)
<#420 (comment)>
thanks let me check it one more time today
@hazemawadalla <https://github.com/hazemawadalla> If this change looks
good to you, can you open a new PR so that we can get this in? Resolving
the CLA issue may take some time.
—
Reply to this email directly, view it on GitHub
<#420?email_source=notifications&email_token=AWXQGCBDS3MYYQBPVAVENUD47QWSNA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTINRZGMZDINJRGY4KM4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#issuecomment-4693245168>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AWXQGCHZDUXYXFJOOTP5BXD47QWSNAVCNFSNUABFKJSXA33TNF2G64TZHM2DKOJXGYZTMMBTHNEXG43VMU5TINRSGQ3TCNRQGE4KC5QC>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Fixes #408
Summary
MultiTierCache._demote_entry()(kv_cache_benchmark/kv_cache/cache.py) increments the offload counters andstorage_tokens_processedwhen it evicts an entry into a lower tier, but it never increments the destination tier's byte counter. As a result,tier_cpu_kv_bytes_written/tier_storage_kv_bytes_written— and the*_gband*_write_bandwidth_gbpsvalues derived from them inresults.json → summary.cache_stats— report0on any multi-tier setup where data reaches CPU or NVMe through eviction rather than direct allocation (the typical GPU-first configuration). The read side of the demotion (data read out of the source tier) was likewise untracked.This is the bug reported in #408, where
offloads_storagewas810(data demonstrably written to storage) yettier_storage_kv_bytes_written_gbandtier_storage_write_bandwidth_gbpswere0.0.Fix
Inside the existing
stats_lockblock in_demote_entry():tier_*_kv_bytes_readcounter (the eviction reads the entry out offrom_tier), andtier_*_kv_bytes_writtencounter for thecpu/nvmebranches.This mirrors the accounting already performed on the direct-allocation path (
_allocate_cache_inner) and the read path (access_cache), reusing the samenvme → storagestat-name mapping.Test
Strengthens
TestThreeTierEvictionCascade::test_full_cascade_gpu_to_cpu_to_nvme_to_delete, which already forces a GPU→CPU→NVMe cascade (every new entry is admitted to GPU, so CPU/NVMe bytes can only arrive via demotion). New assertions verify:tier_cpu_kv_bytes_written,tier_storage_kv_bytes_written,tier_gpu_kv_bytes_read,tier_cpu_kv_bytes_read) are non-zero;tier_{cpu,storage}_kv_bytes_written_gbandtier_storage_write_bandwidth_gbps;This test fails before the fix (counters
0whileoffloads_cpu/offloads_storageare non-zero) and passes after.Verification
206 passed, 28 skipped(skips are CUDA-only).darshan-measured ground truth in KVCache: tier_storage_kv_bytes_written_gb and tier_cpu_kv_bytes_written_gb always 0 when data reaches those tiers via eviction #408 (~1% delta, attributable to.npyheader bytes excluded from bench size accounting).rufffindings on the changed lines.