Skip to content

feat: redirect Triton cache into magi managed cache tree - #53

Merged
jiahy0825 merged 1 commit into
mainfrom
feat/triton-cache-dir
Aug 14, 2026
Merged

feat: redirect Triton cache into magi managed cache tree#53
jiahy0825 merged 1 commit into
mainfrom
feat/triton-cache-dir

Conversation

@cennn

@cennn cennn commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Set TRITON_CACHE_DIR alongside TORCHINDUCTOR_CACHE_DIR in _compilation_context(), pointing to {cache_root_dir}/triton_cache.
  • Previously Triton used its default ~/.triton/cache which only stores .cubin files. With this change, all compilation artifacts (.source, .ptx, .json, .cubin) are preserved in the managed cache tree.
  • Enables post-hoc analysis of autotuning decisions (e.g., inspecting multi-config reduction kernels for determinism debugging).

Motivation

When investigating non-determinism in compiled VAE models, we needed to inspect Triton kernel source code and autotuning metadata. However, magi_compiler only stored .cubin files because TRITON_CACHE_DIR was not redirected into the managed tree. This PR fixes the gap.

Changes

  • config.py: Add triton_cache_dump_path() returning {cache_root_dir}/triton_cache
  • _api.py: Import and use triton_cache_dump_path, add TRITON_CACHE_DIR to the env patch dict

Test plan

  • Verify triton_cache/ directory is created under MAGI_COMPILE_CACHE_ROOT_DIR after compilation
  • Verify .source, .ptx, .json artifacts are present (not just .cubin)
  • Run existing MagiCompiler unit tests

Previously only TORCHINDUCTOR_CACHE_DIR was set, leaving Triton to use
its default ~/.triton/cache which only stores cubin files. By also setting
TRITON_CACHE_DIR to {cache_root_dir}/triton_cache, all Triton compilation
artifacts (.source, .ptx, .json, .cubin) are preserved alongside the
Inductor cache, enabling post-hoc analysis of autotuning decisions.

@jiahy0825 jiahy0825 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.

LGTM

@jiahy0825
jiahy0825 merged commit 313558d into main Aug 14, 2026
2 of 3 checks passed
@jiahy0825
jiahy0825 deleted the feat/triton-cache-dir branch August 14, 2026 06:43
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.

2 participants