Skip to content

Recsys-FlexKV cpu breakdown benchmark - #416

Merged
shijieliu merged 5 commits into
NVIDIA:mainfrom
Clebrate:CPU_breakdown_benchmark
Jun 16, 2026
Merged

shijieliu merged 5 commits into
NVIDIA:mainfrom
Clebrate:CPU_breakdown_benchmark

Conversation

@Clebrate

@Clebrate Clebrate commented Jun 5, 2026 •

Copy link
Copy Markdown
Collaborator

Description

This PR adds FlexKV CPU breakdown profiling benchmarks and analysis.
Contents:

  • breakdown_1/ — 3-step profiling with Nsys / NVTX L1–L2 breakdown
  • offload_stress_test/ — offload stress test micro-benchmark
  • PERF_ANALYSIS.md — test environment, metrics, results and conclusion

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@Clebrate Clebrate mentioned this pull request Jun 5, 2026
2 of 3 tasks
@Clebrate Clebrate changed the title Cpu breakdown benchmark Recsys-FlexKV cpu breakdown benchmark Jun 5, 2026
@Clebrate
Clebrate force-pushed the CPU_breakdown_benchmark branch 7 times, most recently from 8609bb4 to 23de93c Compare June 8, 2026 02:54
Clebrate added a commit to Clebrate/recsys-examples that referenced this pull request Jun 8, 2026
Cherry-pick from PR NVIDIA#416 (CPU_breakdown_benchmark):
- FLEXKV_CPU_BREAKDOWN.md with H100 micro-bench results
- breakdown_1 profiler/plot scripts and H100 charts
- offload_stress_test harness
Clebrate added a commit to Clebrate/recsys-examples that referenced this pull request Jun 8, 2026
Cherry-pick from PR NVIDIA#416 (CPU_breakdown_benchmark):
- FLEXKV_CPU_BREAKDOWN.md with H100 micro-bench results
- breakdown_1 profiler/plot scripts and H100 charts
- offload_stress_test harness
@Clebrate
Clebrate force-pushed the CPU_breakdown_benchmark branch 2 times, most recently from eb17ec3 to 6d91af2 Compare June 8, 2026 07:59
@Clebrate
Clebrate marked this pull request as ready for review June 15, 2026 08:32
@Clebrate

Copy link
Copy Markdown
Collaborator Author

/build

@greptile-apps

greptile-apps Bot commented Jun 15, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds FlexKV CPU breakdown profiling infrastructure: a 3-step NVTX pipeline profiler (test_flexkv_profiler.py), an offload stress test (offload_stress_test.py), a matplotlib-based L1/L2 stacked-bar and nested-donut plot generator (plot.py), and an analysis document with H100 results.

  • The documented benchmark configuration (num_layers=8/64, head_dim=256) does not match the profiler script defaults (_PROFILER_NUM_LAYERS=3, head_dim=128), so the published results in FLEXKV_CPU_BREAKDOWN.md cannot be reproduced by running the committed scripts as-is.
  • Tensor allocations in both scripts hardcode layer/head dimensions rather than using the named _PROFILER_* constants that are already used elsewhere in the same files, creating a latent divergence risk if the constants are updated.
  • ensure_dir does not guard against empty-string inputs and can raise FileNotFoundError when called with a bare filename.

Confidence Score: 4/5

Safe to merge for benchmarking use, but the documented test environment does not match the committed code, so published results are not reproducible from this branch alone.

The configuration table in FLEXKV_CPU_BREAKDOWN.md (num_layers=8/64, head_dim=256) is substantially different from the constants in the scripts (num_layers=3, head_dim=128). Anyone trying to validate or reproduce the H100 numbers by running the provided scripts will get results that differ significantly from what is documented.

FLEXKV_CPU_BREAKDOWN.md needs its configuration table reconciled with the actual script defaults, or the scripts need to be updated to use the configurations that generated the documented results.

Important Files Changed

Filename Overview
corelib/recsys_kvcache_manager/test/FLEXKV_CPU_BREAKDOWN.md Analysis document whose configuration table (num_layers=8/64, head_dim=256) does not match the profiler scripts (num_layers=3, head_dim=128), making the documented results non-reproducible
corelib/recsys_kvcache_manager/test/breakdown_1/test_flexkv_profiler.py 3-step NVTX profiler with classmethod guard and layer-count constant fixes applied; tensor allocation still hardcodes 3 instead of _PROFILER_NUM_LAYERS
corelib/recsys_kvcache_manager/test/offload_stress_test/offload_stress_test.py Burst-once offload stress test with CSV output; tensor shapes hardcode 3/4/128 instead of the named PROFILER* constants already used in the config call
corelib/recsys_kvcache_manager/test/breakdown_1/plot.py L1/L2 stacked-bar and nested donut plot generator; ensure_dir does not guard against empty-string paths, which can trigger FileNotFoundError if called with a bare filename

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant Test as test_flexkv_profiler
    participant KVM as KVCacheManager
    participant GPU as gpu_kvcache_mgr
    participant FlexKV as FlexKVStorageManager
    participant Client as flexkv_client

    Note over Test: Step 1 — Offload Round
    Test->>KVM: lookup_kvcache(user_ids, seq_lens)
    KVM->>FlexKV: build_index_meta
    KVM->>FlexKV: lookup_kvcache → get_match
    KVM-->>Test: index_meta, lookup_res
    Test->>KVM: allocate_kvcache(index_meta, lookup_res)
    KVM->>GPU: allocate
    loop for each layer
        Test->>GPU: put(keys[layer], values[layer])
    end
    Test->>KVM: offload_launch(index_meta, kvcache_metadata)
    KVM->>FlexKV: offload_kvcache_launch → put_async
    KVM-->>Test: task_handle
    loop poll until done
        Test->>KVM: offload_try_wait()
        KVM->>Client: try_wait
    end

    Note over Test: Step 2 — Evict GPU
    Test->>KVM: "evict(user_ids, for_gpu=True)"
    KVM->>GPU: evict

    Note over Test: Step 3 — Onboard Round
    Test->>KVM: lookup_kvcache(user_ids, seq_lens)
    KVM-->>Test: index_meta, lookup_res (GPU miss, CPU hit)
    Test->>KVM: allocate_kvcache(index_meta, lookup_res)
    Test->>KVM: onboard_launch(index_meta, lookup_res, kvcache_metadata)
    KVM->>Client: launch
    KVM-->>Test: onboard_handle
    loop poll until ready
        Test->>KVM: onboard_wait(index_meta, onboard_handle)
        KVM->>Client: wait
    end
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant Test as test_flexkv_profiler
    participant KVM as KVCacheManager
    participant GPU as gpu_kvcache_mgr
    participant FlexKV as FlexKVStorageManager
    participant Client as flexkv_client

    Note over Test: Step 1 — Offload Round
    Test->>KVM: lookup_kvcache(user_ids, seq_lens)
    KVM->>FlexKV: build_index_meta
    KVM->>FlexKV: lookup_kvcache → get_match
    KVM-->>Test: index_meta, lookup_res
    Test->>KVM: allocate_kvcache(index_meta, lookup_res)
    KVM->>GPU: allocate
    loop for each layer
        Test->>GPU: put(keys[layer], values[layer])
    end
    Test->>KVM: offload_launch(index_meta, kvcache_metadata)
    KVM->>FlexKV: offload_kvcache_launch → put_async
    KVM-->>Test: task_handle
    loop poll until done
        Test->>KVM: offload_try_wait()
        KVM->>Client: try_wait
    end

    Note over Test: Step 2 — Evict GPU
    Test->>KVM: "evict(user_ids, for_gpu=True)"
    KVM->>GPU: evict

    Note over Test: Step 3 — Onboard Round
    Test->>KVM: lookup_kvcache(user_ids, seq_lens)
    KVM-->>Test: index_meta, lookup_res (GPU miss, CPU hit)
    Test->>KVM: allocate_kvcache(index_meta, lookup_res)
    Test->>KVM: onboard_launch(index_meta, lookup_res, kvcache_metadata)
    KVM->>Client: launch
    KVM-->>Test: onboard_handle
    loop poll until ready
        Test->>KVM: onboard_wait(index_meta, onboard_handle)
        KVM->>Client: wait
    end
Loading

Reviews (5): Last reviewed commit: "fix pre-commit formatting" | Re-trigger Greptile

@JacoCheung

JacoCheung commented Jun 15, 2026 •

Copy link
Copy Markdown
Collaborator

❌ Pipeline #54791250 -- failed

Job Status Log
pre_check ❌ failed view
train_build ✅ success view
inference_build ✅ success view
tritonserver_build ✅ success view
build_whl ✅ success view
dynamicemb_test_fwd_bwd_8gpus ❌ failed view
dynamicemb_test_load_dump_8gpus ❌ failed view
unit_test_1gpu_a100 ❌ failed view
unit_test_1gpu_h100 ❌ failed view
unit_test_4gpu ✅ success view
unit_test_tp_4gpu ❌ failed view
L20_unit_test_1gpu ✅ success view
inference_unit_test_1gpu ✅ success view
inference_test_1gpu ✅ success view

Result: 8/14 jobs passed

View full pipeline

@Clebrate
Clebrate force-pushed the CPU_breakdown_benchmark branch from 6d91af2 to b68a28b Compare June 15, 2026 13:03
@Clebrate
Clebrate force-pushed the CPU_breakdown_benchmark branch from b68a28b to 4c86691 Compare June 15, 2026 13:07
@Clebrate

Copy link
Copy Markdown
Collaborator Author

/build

@JacoCheung

JacoCheung commented Jun 15, 2026 •

Copy link
Copy Markdown
Collaborator

❌ Pipeline #54813039 -- failed

Job Status Log
pre_check ❌ failed view
train_build_x86 ✅ success view
train_build_arm64 ✅ success view
tritonserver_build_x86 ✅ success view
prepare-jet-b200-smoke ✅ success view
prepare-jet-b200-inference ✅ success view
prepare-jet-cw-dfw-e2e-benchmark ✅ success view
build_whl ✅ success view
dynamicemb_test_fwd_bwd_8gpus ❌ failed view
dynamicemb_test_load_dump_8gpus ❌ failed view
unit_test_1gpu_a100 ✅ success view
unit_test_1gpu_h100 ✅ success view
unit_test_4gpu ❌ failed view
unit_test_tp_4gpu ❌ failed view
L20_unit_test_1gpu ✅ success view
inference_unit_test_1gpu ✅ success view
inference_test_1gpu ✅ success view

Result: 12/17 jobs passed

View full pipeline

@Clebrate

Copy link
Copy Markdown
Collaborator Author

/build

@JacoCheung

JacoCheung commented Jun 16, 2026 •

Copy link
Copy Markdown
Collaborator

❌ Pipeline #54881269 -- failed

Job Status Log
pre_check ❌ failed view
train_build_x86 ✅ success view
train_build_arm64 ✅ success view
tritonserver_build_x86 ✅ success view
prepare-jet-b200-smoke ✅ success view
prepare-jet-b200-inference ✅ success view
prepare-jet-cw-dfw-e2e-benchmark ✅ success view
build_whl ✅ success view
dynamicemb_test_fwd_bwd_8gpus ❌ failed view
dynamicemb_test_load_dump_8gpus ✅ success view
unit_test_1gpu_a100 ✅ success view
unit_test_1gpu_h100 ✅ success view
unit_test_4gpu ✅ success view
unit_test_tp_4gpu ❌ failed view
L20_unit_test_1gpu ✅ success view
inference_unit_test_1gpu ✅ success view
inference_test_1gpu ❌ failed view

Result: 13/17 jobs passed

View full pipeline

@shijieliu
shijieliu merged commit 14027d5 into NVIDIA:main Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants