Skip to content

[mem_cache] skip duplicates host evict via environ - #38462

Merged
iforgetmyname merged 2 commits into
sgl-project:mainfrom
Liwansi:top_glm_A5_opt_3
Sep 9, 2026
Merged

iforgetmyname merged 2 commits into
sgl-project:mainfrom
Liwansi:top_glm_A5_opt_3

Conversation

@Liwansi

@Liwansi Liwansi commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

When device-side memory is constrained, evicted cache lines are continuously offloaded to host memory. Once host memory reaches capacity, a host-side eviction policy must be enforced. Under a write-back strategy, cache lines that are redundantly held on both device and host are preferentially selected for eviction. Consequently, prefix cache lines that were previously offloaded from device to host may be re-transmitted, thereby degrading overall throughput during benchmarking.

Modifications

To mitigate the throughput degradation caused by redundant re-transmission of prefix cache lines, we introduce an environment variable SGLANG_HICACHE_SKIP_HOST_DUPLICATE_RECLAIM that bypasses the _reclaim_full_host_duplicates eviction path. When set to 1, the system skips the preferential eviction of device–host duplicate cache lines and proceeds directly to the general host eviction routine (drive_host_eviction), thereby preserving previously offloaded prefix entries on the host side and avoiding unnecessary re-offloading overhead.

Accuracy Tests

None

Speed Tests and Profiling

140k + 95%cache

Before:
image

image

After:
image

image

Checklist

Review and Merge Process

  1. Ping Merge Oncalls to start the process. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • Common commands include /tag-and-rerun-ci, /tag-run-ci-label, /rerun-failed-ci
  4. After green CI and required approvals, ask Merge Oncalls or people with Write permission to merge the PR.

CI States

Latest PR Test (Base): ✅ Run #34211872549
Latest PR Test (Extra): ❌ Run #34211872289
Latest PR Test (AMD ROCm 7.2): ❌ Run #34211872520

@iforgetmyname

Copy link
Copy Markdown
Collaborator

/tag-and-rerun-ci

@github-actions github-actions Bot added the run-ci CI: run the baseline test suite on this PR label Sep 8, 2026
@Liwansi

Liwansi commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

/rerun-failed-ci

@alphabetc1 alphabetc1 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also implement this policy for the Rust TreeCore? Currently this environment variable is silently ignored when SGLANG_UNIFIED_RADIX_TREE_CORE_BACKEND=rust.
Please also provide benchmark results showing the transfer reduction and throughput impact.

@Liwansi

Liwansi commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

Could you also implement this policy for the Rust TreeCore? Currently this environment variable is silently ignored when SGLANG_UNIFIED_RADIX_TREE_CORE_BACKEND=rust. Please also provide benchmark results showing the transfer reduction and throughput impact.

The profiling and benchmark results have been attached. However, I'm not familiar with the Rust-side implementation, so I'm unable to adapt it at this time. Apologies for that.

@Liwansi

Liwansi commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

/rerun-failed-ci

@iforgetmyname iforgetmyname changed the title skip duplicates host evict [mem_cache] skip duplicates host evict Sep 9, 2026
@iforgetmyname iforgetmyname changed the title [mem_cache] skip duplicates host evict [mem_cache] skip duplicates host evict via environ Sep 9, 2026
@iforgetmyname
iforgetmyname merged commit 78da625 into sgl-project:main Sep 9, 2026
298 of 356 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bypass-fastfail run-ci CI: run the baseline test suite on this PR unified-radix-cache

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants