Skip to content

ci(matrix): enable and persist SPYRE_KERNEL_CACHE across CI runs - #812

Open
prashantgupta24 wants to merge 9 commits into
torch-spyre:mainfrom
prashantgupta24:feat/spyre-kernel-cache-ci
Open

ci(matrix): enable and persist SPYRE_KERNEL_CACHE across CI runs#812
prashantgupta24 wants to merge 9 commits into
torch-spyre:mainfrom
prashantgupta24:feat/spyre-kernel-cache-ci

Conversation

@prashantgupta24

@prashantgupta24 prashantgupta24 commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

Description

Persist the Spyre kernel compile cache across CI runs by saving and restoring TORCHINDUCTOR_CACHE_DIR with actions/cache. The persistent Spyre kernel cache added in torch-spyre@76978116cb44020b50c8df1a1822d5178629922a lives under the same TORCHINDUCTOR_CACHE_DIR root, so caching that directory reuses compiled kernels between runs while keeping each matrix job scoped to its own path to avoid races or stale cross-job reuse.

Changes in .github/actions/run-matrix-config/action.yml:

  • Add a restore step keyed by runner OS/arch, job slot, lockfile hashes (pyproject.toml, uv.lock, spyre-rpms.lock), and runner labels, with fallback restore keys for partial matches.
  • Set SPYRE_KERNEL_CACHE=1 alongside a per-job TORCHINDUCTOR_CACHE_DIR.
  • Add a save step that runs if: always() so the cache is persisted even when tests fail.
  • Use a stable per-slot cache directory (${RUNNER_TEMP}/inductor-cache-${{ inputs.job_slot }}) so the restore key can match artifacts saved by previous runs. The original path included ${{ github.run_id }}, which changed every run and prevented cache reuse.

Cache Reuse Results

Verified on test_each_commit run 2827 (34542654984) — every matrix job restored the Spyre kernel compile cache on its second run with the stable path:

Matrix job Cache restore result
Spyre attention tests (shard 1/10) Cache hit for: spyre-kernel-cache-Linux-X64-8-... (~7 MB restored)
Non-distributed spyre tests (shard 1/8) Cache hit for: spyre-kernel-cache-Linux-X64-0-... (~7 MB restored)
Upstream vLLM tests (shard 1/7) Cache hit for: spyre-kernel-cache-Linux-X64-24-... (~9 MB restored)
Distributed spyre tests (shard 1/3) Cache hit for: spyre-kernel-cache-Linux-X64-19-... (~7 MB restored)
Spyre attention tests (shard 5/10) Cache hit for: spyre-kernel-cache-Linux-X64-12-... (~5 MB restored)

All representative slots across attention, non-distributed, upstream, and distributed test groups showed Cache restored from key: ..., and the save step reported Failed to save: Unable to reserve cache with key ... because the cache already existed from the prior run.

Test Plan

  • bash format.sh — passed
  • Targeted Spyre hardware runs confirmed the cache is populated and reused on subsequent runs
  • CI run 2827 on this PR validated end-to-end cache hit behavior

Checklist

  • Code follows project style
  • DCO sign-off included
  • CI green

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! Thank you for contributing.
Just a reminder: Make sure that your code passes all the linting checks, otherwise your PR won't be able to be merged. To do so, run ./format.sh.
Now you are good to go 🚀.

We also recommend installing prek and configuring it to check your code before every local commit.

@prashantgupta24

Copy link
Copy Markdown
Collaborator Author

/claude-review

Comment thread .github/actions/run-matrix-config/action.yml
Comment thread .github/actions/run-matrix-config/action.yml Outdated
@prashantgupta24
prashantgupta24 marked this pull request as ready for review September 8, 2026 20:45
prashantgupta24 added a commit to prashantgupta24/spyre-inference that referenced this pull request Sep 9, 2026
Temporary no-op commit to trigger CI run for PR torch-spyre#812.
This change only adds a comment and will be reverted.

Signed-off-by: Prashant Gupta <prashantgupta24@gmail.com>
@prashantgupta24
prashantgupta24 marked this pull request as draft September 9, 2026 01:28
Comment thread spyre_inference/platform.py Outdated
@prashantgupta24 prashantgupta24 changed the title ci(matrix): enable SPYRE_KERNEL_CACHE=1 in CI ci(matrix): enable and persist SPYRE_KERNEL_CACHE across CI runs Sep 9, 2026
Set SPYRE_KERNEL_CACHE=1 alongside the job-scoped TORCHINDUCTOR_CACHE_DIR.
The persistent Spyre kernel cache lives under the same per-job path, so it
stays isolated from concurrent matrix legs while allowing compiled kernels to
be reused across runs.

Signed-off-by: Prashant Gupta <prashantgupta24@gmail.com>
Rename the cache-dir step and extend its comment to make clear that it also
enables the persistent Spyre kernel cache. The cache path is job-scoped, so
the kernel cache benefits from intra-job reuse without cross-job races.

Signed-off-by: Prashant Gupta <prashantgupta24@gmail.com>
Temporary no-op commit to trigger CI run for PR torch-spyre#812.
This change only adds a comment and will be reverted.

Signed-off-by: Prashant Gupta <prashantgupta24@gmail.com>
Persist TORCHINDUCTOR_CACHE_DIR (which contains the Spyre kernel cache
under inductor-spyre-cache) across CI runs via actions/cache/restore and
actions/cache/save. Set SPYRE_KERNEL_CACHE=1 so compiled kernels are
written to the on-disk cache. Key the cache by runner OS/arch, job slot,
lockfile hashes, and runner labels to balance reuse and invalidation.

Signed-off-by: Prashant Gupta <prashantgupta24@gmail.com>
actions/cache keys cannot contain commas. inputs.runner_labels is a
JSON array string like '["x86_64","spyre_pf_x1","linux","image_torch_spyre"]',
which embeds commas. Use hashFromJSON to collapse it into a stable,
comma-free hash for the cache key.

Signed-off-by: Prashant Gupta <prashantgupta24@gmail.com>
hashFromJSON is not a valid GitHub Actions expression function, so the
previous fix failed template validation. Instead, write inputs.runner_labels
to a file and include it in hashFiles, which keeps the key stable and free
of commas.

Signed-off-by: Prashant Gupta <prashantgupta24@gmail.com>
@prashantgupta24
prashantgupta24 force-pushed the feat/spyre-kernel-cache-ci branch 2 times, most recently from d261f43 to f150d11 Compare September 10, 2026 20:23
Signed-off-by: Prashant Gupta <prashantgupta24@gmail.com>
@prashantgupta24
prashantgupta24 force-pushed the feat/spyre-kernel-cache-ci branch from ed14ed7 to 8ac4b5b Compare September 10, 2026 23:53
@prashantgupta24
prashantgupta24 marked this pull request as ready for review September 11, 2026 00:09
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.

1 participant