Skip to content

Recsys-FlexKV Inference benchmark - #429

Merged
shijieliu merged 5 commits into
NVIDIA:mainfrom
Clebrate:lyl_inference_benchmark
Jul 10, 2026
Merged

shijieliu merged 5 commits into
NVIDIA:mainfrom
Clebrate:lyl_inference_benchmark

Conversation

@Clebrate

Copy link
Copy Markdown
Collaborator

Description

FlexKV inference benchmark: GPU-hit, CPU-hit only, and SSD-hit only

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 force-pushed the lyl_inference_benchmark branch 4 times, most recently from 74f52fb to 111426d Compare July 2, 2026 08:31
@Clebrate
Clebrate force-pushed the lyl_inference_benchmark branch from 111426d to 9b008d8 Compare July 2, 2026 08:34
Clebrate added 2 commits July 5, 2026 18:51
Keep non-layerwise benchmark cleanup improvements (FlexKV client shutdown
and scenario1 offload drain) while moving layerwise benchmark and inference
integration to PR NVIDIA#428.
Clebrate added a commit to Clebrate/recsys-examples that referenced this pull request Jul 8, 2026
Move layerwise benchmark entrypoints and per-layer FlexKV wait/NVTX hooks
from PR NVIDIA#429 so layerwise validation lives with the FlexKV layerwise
backend support.
@Clebrate
Clebrate force-pushed the lyl_inference_benchmark branch from 63dfd29 to 202b657 Compare July 8, 2026 11:20
Clebrate added a commit to Clebrate/recsys-examples that referenced this pull request Jul 8, 2026
Move layerwise benchmark entrypoints and per-layer FlexKV wait/NVTX hooks
from PR NVIDIA#429 so layerwise validation lives with the FlexKV layerwise
backend support.
@Clebrate
Clebrate marked this pull request as ready for review July 9, 2026 02:38
@greptile-apps

greptile-apps Bot commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a new FlexKV inference benchmark (inference_benchmark_flexkv.py) covering GPU-hit, CPU-hit, and SSD-hit scenarios, and updates inference_dense_module.py to synchronously wait for FlexKV onboard tasks before running the HSTU attention kernel.

  • New benchmark: Three timing scenarios that prime user KV state, apply LRU pressure as needed, and measure end-to-end forward latency with NVTX instrumentation and bounded offload-drain loops.
  • Dense module change: A new guard in forward_with_kvcache detects a non-skipped FlexKV onboard handle and calls kvcache.onboard_wait before the attention kernel runs, ensuring GPU KV data is ready for FlexKV backends without changing behavior for other backends.

Confidence Score: 4/5

The dense module change is well-guarded and the benchmark logic is sound for GPU-hit and CPU-hit scenarios; the SSD-hit scenario may silently measure CPU-hit latency when FlexKV config is unavailable at runtime.

The dense module onboard-wait addition is correctly scoped to FlexKV and doesn't regress other backends. The benchmark file is well-structured with bounded drain loops and NVTX markers. However, the SSD-hit scenario's auto-pressure formula uses num_cpu_blocks read from cache_cfg, which silently falls back to 0 when the FlexKV client config is absent — producing only 128 pressure users regardless of actual CPU cache size. If 128 users are not enough to fully evict the target users from CPU, the benchmark records CPU-hit latency under the SSD-hit label without any warning. This measurement-validity concern was raised in prior review threads but has not been addressed in the current diff.

The SSD-hit scenario in examples/hstu/inference/benchmark/inference_benchmark_flexkv.py — specifically the ssd_pressure_users auto-computation block — warrants a second look for cases where cache_cfg resolves to None.

Important Files Changed

Filename Overview
examples/hstu/inference/benchmark/inference_benchmark_flexkv.py New benchmark script for GPU-hit, CPU-hit, and SSD-hit FlexKV scenarios; includes correct os import, bounded offload-drain loops, and NVTX markers. The SSD scenario's auto-pressure computation silently falls back to 128 users when cache_cfg is absent, which may be insufficient to evict target users from CPU.
examples/hstu/modules/inference_dense_module.py Adds a FlexKV-specific onboard wait block guarded by null checks, SKIPPED-status exclusion, and backend identity; intentional blocking on ready=false was confirmed as desired behavior in prior discussion. The change is scoped correctly to FlexKV and does not alter non-FlexKV paths.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant BM as Benchmark
    participant GR as InferenceRankingGR
    participant KV as KVCacheManager
    participant DM as InferenceDenseModule
    participant FKV as FlexKV (host)

    BM->>GR: forward_with_kvcache(batch, user_ids, total_history_lengths)
    GR->>KV: lookup_kvcache(user_ids, total_history_lengths)
    KV-->>GR: index_meta, lookup_res
    GR->>KV: allocate_kvcache(index_meta, lookup_res)
    KV-->>GR: kvcache_metadata
    GR->>KV: onboard_launch(index_meta, lookup_res, kvcache_metadata)
    KV->>FKV: async onboard KV data to GPU
    GR->>GR: strip_cached_tokens + embedding lookup
    GR->>DM: forward_with_kvcache(batch, embeddings, user_ids, total_history_lengths, kvcache_info)
    Note over DM: NEW: check kv_onload_handle for FlexKV
    alt "onboard_handle.backend == flexkv and status != SKIPPED"
        DM->>KV: onboard_wait(kv_index_meta, onboard_handle)
        KV->>FKV: poll until ready
        FKV-->>KV: "ready=True"
        KV-->>DM: return
    end
    DM->>DM: HSTU attention kernel (KV now on GPU)
    DM->>KV: offload_launch(kv_index_meta, kvcache_metadata)
    KV->>FKV: async offload KV data to host
    DM-->>GR: logits
    GR-->>BM: logits
    BM->>KV: offload_try_wait() loop with timeout
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 BM as Benchmark
    participant GR as InferenceRankingGR
    participant KV as KVCacheManager
    participant DM as InferenceDenseModule
    participant FKV as FlexKV (host)

    BM->>GR: forward_with_kvcache(batch, user_ids, total_history_lengths)
    GR->>KV: lookup_kvcache(user_ids, total_history_lengths)
    KV-->>GR: index_meta, lookup_res
    GR->>KV: allocate_kvcache(index_meta, lookup_res)
    KV-->>GR: kvcache_metadata
    GR->>KV: onboard_launch(index_meta, lookup_res, kvcache_metadata)
    KV->>FKV: async onboard KV data to GPU
    GR->>GR: strip_cached_tokens + embedding lookup
    GR->>DM: forward_with_kvcache(batch, embeddings, user_ids, total_history_lengths, kvcache_info)
    Note over DM: NEW: check kv_onload_handle for FlexKV
    alt "onboard_handle.backend == flexkv and status != SKIPPED"
        DM->>KV: onboard_wait(kv_index_meta, onboard_handle)
        KV->>FKV: poll until ready
        FKV-->>KV: "ready=True"
        KV-->>DM: return
    end
    DM->>DM: HSTU attention kernel (KV now on GPU)
    DM->>KV: offload_launch(kv_index_meta, kvcache_metadata)
    KV->>FKV: async offload KV data to host
    DM-->>GR: logits
    GR-->>BM: logits
    BM->>KV: offload_try_wait() loop with timeout
Loading

Reviews (11): Last reviewed commit: "fix" | Re-trigger Greptile

@Clebrate
Clebrate force-pushed the lyl_inference_benchmark branch from 53a3815 to 493df1e Compare July 9, 2026 03:10
@Clebrate

Clebrate commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator Author

/build

@JacoCheung

JacoCheung commented Jul 9, 2026 •

Copy link
Copy Markdown
Collaborator

❌ Pipeline #57348858 -- failed

Job Status Log
pre_check ✅ success 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 ✅ success view
dynamicemb_test_load_dump_8gpus ✅ success view
unit_test_1gpu_a100 ❌ failed view
unit_test_1gpu_h100 ❌ failed 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 ❌ failed view

Result: 12/17 jobs passed

View full pipeline

@Clebrate

Clebrate commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator Author

/build

@JacoCheung

JacoCheung commented Jul 9, 2026 •

Copy link
Copy Markdown
Collaborator

❌ Pipeline #57376612 -- failed

Job Status Log
pre_check ✅ success 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 ✅ success view
dynamicemb_test_load_dump_8gpus ✅ success view
unit_test_1gpu_a100 ❌ failed view
unit_test_1gpu_h100 ❌ failed 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 ❌ failed view

Result: 12/17 jobs passed

View full pipeline

Clebrate added a commit to Clebrate/recsys-examples that referenced this pull request Jul 10, 2026
Move layerwise benchmark entrypoints and per-layer FlexKV wait/NVTX hooks
from PR NVIDIA#429 so layerwise validation lives with the FlexKV layerwise
backend support.
@Clebrate
Clebrate force-pushed the lyl_inference_benchmark branch from d67ce3a to 422b6ac Compare July 10, 2026 03:49
@Clebrate
Clebrate force-pushed the lyl_inference_benchmark branch from 422b6ac to a3f9025 Compare July 10, 2026 03:54
Use --only-onboard to select the onboard-only benchmark path and add configurable request batch size support while removing the duplicate benchmark entry point.
@Clebrate
Clebrate force-pushed the lyl_inference_benchmark branch from a3f9025 to 9dd4285 Compare July 10, 2026 04:02
@Clebrate

Copy link
Copy Markdown
Collaborator Author

/build

@JacoCheung

JacoCheung commented Jul 10, 2026 •

Copy link
Copy Markdown
Collaborator

❌ Pipeline #57485040 -- failed

Job Status Log
pre_check ✅ success 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 ✅ success view
dynamicemb_test_load_dump_8gpus ✅ success 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 ❌ failed view

Result: 13/17 jobs passed

View full pipeline

@Clebrate
Clebrate force-pushed the lyl_inference_benchmark branch from 61cd81d to 92c2bec Compare July 10, 2026 07:23
@Clebrate
Clebrate force-pushed the lyl_inference_benchmark branch from 92c2bec to 584ef38 Compare July 10, 2026 07:27
@Clebrate

Copy link
Copy Markdown
Collaborator Author

/build

@JacoCheung

JacoCheung commented Jul 10, 2026 •

Copy link
Copy Markdown
Collaborator

❌ Pipeline #57501777 -- 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 ✅ success view
dynamicemb_test_load_dump_8gpus ✅ success 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 ❌ failed view

Result: 12/17 jobs passed

View full pipeline

@shijieliu
shijieliu merged commit e59a876 into NVIDIA:main Jul 10, 2026
1 check passed
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