Skip to content

fix(environ): align SGLANG_JIT_CACHE_DIR default with SGLANG_CACHE_DIR - #44068

Closed
Asthenia0412 wants to merge 1 commit into
sgl-project:mainfrom
Asthenia0412:fix/unified-cache-dir
Closed

Asthenia0412 wants to merge 1 commit into
sgl-project:mainfrom
Asthenia0412:fix/unified-cache-dir

Conversation

@Asthenia0412

@Asthenia0412 Asthenia0412 commented Oct 13, 2026 •

Copy link
Copy Markdown

Summary

Partial fix for #19612: Align SGLANG_JIT_CACHE_DIR with the unified SGLANG_CACHE_DIR root.

Problem

SGLang already directs third-party JIT caches (Triton, Inductor, CUDA, TileLang, FlashInfer) under SGLANG_CACHE_DIR via redirect_third_party_caches(), and other internal caches (SGLANG_DG_CACHE_DIR, SGLANG_CUTE_AOT_CACHE_DIR) resolve relative to it using _default_cache_subdir(). However, SGLANG_JIT_CACHE_DIR was inconsistent:

  • environ.py: declared as EnvStr(None) (no default)
  • cache.py: hardcoded fallback "~/.cache/sglang/jit"

This split meant setting SGLANG_CACHE_DIR=/mnt/cache did not redirect the JIT kernel build cache — operators needed a separate SGLANG_JIT_CACHE_DIR=/mnt/cache/jit override.

Fix

  1. environ.py — Changed SGLANG_JIT_CACHE_DIR from EnvStr(None) to EnvStr(lambda: _default_cache_subdir("jit")), matching the pattern used by SGLANG_DG_CACHE_DIR and SGLANG_CUTE_AOT_CACHE_DIR.

  2. cache.py — Updated cache_root() fallback from a hardcoded "~/.cache/sglang/jit" to os.path.join(os.path.expanduser(envs.SGLANG_CACHE_DIR.get()), "jit"), eliminating the second source of truth.

Result

All JIT/precompilation caches now resolve under a single configurable root:

Cache Default path Override env
Triton $SGLANG_CACHE_DIR/triton TRITON_CACHE_DIR
Inductor $SGLANG_CACHE_DIR/inductor TORCHINDUCTOR_CACHE_DIR
CUDA $SGLANG_CACHE_DIR/nv CUDA_CACHE_PATH
TileLang $SGLANG_CACHE_DIR/tilelang TILELANG_CACHE_DIR
FlashInfer $SGLANG_CACHE_DIR base FLASHINFER_WORKSPACE_BASE
DeepGEMM $SGLANG_CACHE_DIR/deep_gemm SGLANG_DG_CACHE_DIR
CuTe AOT $SGLANG_CACHE_DIR/cute_aot SGLANG_CUTE_AOT_CACHE_DIR
JIT kernel builds $SGLANG_CACHE_DIR/jit SGLANG_JIT_CACHE_DIR

Setting SGLANG_CACHE_DIR=/mnt/cache/sglang now redirects every cache at once.

Backward Compatibility

  • If SGLANG_JIT_CACHE_DIR is explicitly set, it still takes precedence
  • Default path changes from None → ~/.cache/sglang/jit (same as cache.py's previous hardcoded fallback)
  • External callers that read SGLANG_JIT_CACHE_DIR will now see a concrete path when unset instead of None

Refs: #19612

Signed-off-by: yancy yancy@users.noreply.github.com


CI States

Latest PR Test (Base): ❌ Run #38407097560
Latest PR Test (Extra): ❌ Run #38407096687
Latest PR Test (AMD ROCm 10): ❌ Run #38407097015

The SGLANG_CACHE_DIR root directory (~/.cache/sglang) already drives most
JIT cache paths via _default_cache_subdir() and redirect_third_party_caches(),
but SGLANG_JIT_CACHE_DIR was an exception: it defaulted to None in environ.py
while cache.py hardcoded "~/.cache/sglang/jit" as a fallback, creating two
separate sources of truth.

This change makes SGLANG_JIT_CACHE_DIR resolve via _default_cache_subdir("jit")
so it tracks SGLANG_CACHE_DIR (matching SGLANG_DG_CACHE_DIR and
SGLANG_CUTE_AOT_CACHE_DIR), and updates cache.py cache_root() to derive its
fallback from envs.SGLANG_CACHE_DIR instead of a hardcoded path.

With this change, operators who set SGLANG_CACHE_DIR=/mnt/cache/sglang will
automatically get JIT builds under /mnt/cache/sglang/jit without a separate
SGLANG_JIT_CACHE_DIR override.

Ref: #19612
Signed-off-by: yancy <yancy@users.noreply.github.com>
@Asthenia0412

Copy link
Copy Markdown
Author

Hi @DarkSharpness @HaiShaw — gentle ping for review when you have a moment. Thanks!

@Asthenia0412

Copy link
Copy Markdown
Author

@reviewers @maintainers CI call-gate fails because it requires a 'run-ci' label. Could someone add this label to trigger the full test suite?

@Asthenia0412

Copy link
Copy Markdown
Author

🤖 CI gating notice: This PR's checks (call-gate/pr-gate, pr-test-*-finish) fail because this repo requires a run-ci label to trigger the actual test matrix. The failed jobs are just CI gating placeholders — real tests haven't run yet.

@hnyls2002

Copy link
Copy Markdown
Collaborator

Thanks for your interest in SGLang. This account opened 16 PRs in about eight hours, across unrelated subsystems (attention backends, speculative decoding, diffusion loading, scheduler IPC, KV-cache compression, docs), including two PRs for the same change (#44073 and #44117, both for #28808) and a fix for #43929 that is already on main. We can't review contributions at this volume, so we are closing the ones still open. If you want to pursue one, please pick a single change, verify it on a real run (a repro, a test, or numbers), and open a fresh PR.

@hnyls2002 hnyls2002 closed this Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants