Persist torch.compile cache across GPU CI jobs - #570
Conversation
Local compile_module already reuses FX-graph and Triton caches; CI was recompiling from scratch because that directory was not restored. Signed-off-by: Set Paing <spaing@nvidia.com>
Greptile SummaryThe PR persists PyTorch Inductor artifacts between GPU CI jobs and adds cross-process validation of cache reuse.
Confidence Score: 3/5The PR should not merge until the GPU cache action is pinned to a reviewed immutable commit SHA. The timing-gate issue is fixed, but every GPU job still executes Files Needing Attention: .github/workflows/ci.yml Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[GPU CI job] --> B[Restore architecture-keyed cache]
B --> C[Set FLASHDREAMS_CACHE_DIR]
C --> D[First worker compiles TinyMLP]
D --> E[Write Inductor and FX-graph artifacts]
E --> F[Second worker compiles TinyMLP]
F --> G[Verify cached artifacts remain]
G --> H[Save cache for later GPU jobs]
Reviews (2): Last reviewed commit: "Stop gating GPU compile-cache CI on a 2x..." | Re-trigger Greptile |
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Cache torch.compile artifacts | ||
| uses: actions/cache@v4 |
There was a problem hiding this comment.
Mutable cache action reference
The new GPU CI step references actions/cache@v4, so an upstream tag mutation changes the code executed by the workflow without a repository change. Pin the action to a reviewed full commit SHA to make this dependency immutable.
How this was verified: The workflow directly executes the mutable actions/cache@v4 reference on every GPU CI job.
Keep the FX-graph artifact check so a loaded runner cannot fail a real cache hit. Signed-off-by: Set Paing <spaing@nvidia.com>
fangjunzhou-nv
left a comment
There was a problem hiding this comment.
#500 is not a CI specific issue. This issue happens to torch.compile even outside the CI. Specifically, running compile_module from flashdreams/flashdreams/infra/compile.py usually takes a long time.
This indicates we're not using torch.compile cache properly and we need to investigate this before we propose a fix.
|
Agreed — the CI cache was the wrong problem. Converting to draft. Next I will measure a real OmniDreams compile (wrap vs first forward vs CUDA-graph warmup, cold vs second process) and report cache hit/miss before proposing a fix. |
|
The change reuses the existing cache-root abstraction, stays narrowly scoped, and the added cache_dir() assertion is useful. [P1 correctness/reliability] The GPU test can pass without a cache hit. It writes to a fresh tmp_path, while CI persists /tmp/flashdreams-cache/torchinductor; moreover, the assertions only prove files remain, not that the warm worker reused them ([lines 61–103 flashdreams/tests/test_compile_cache_gpu.py#L61-L103)) . Can the test assert PyTorch’s fxgraph_cache_hit counter? Test the desired outcome directly. . Comment P1 security: GitHub also recommends treating restored cache contents as untrusted and keeping secrets out of cached paths (GitHub cache security guidance). |
Summary
$FLASHDREAMS_CACHE_DIR/torchinductor, keyed by GPU arch anduv.lock.compile_modulealready pinned Inductor under that path locally; this is what was missing for CI.ci_gputwo-process check that a warm compile is at least twice as fast as a cold one.Fixes #500.
Test plan
pytest flashdreams/tests/test_compile.py -m ci_cpupytest flashdreams/tests/test_compile_cache_gpu.py -m ci_gpuon RTX PRO 6000 (cold ~6s, warm ~1s)uv.lockshows an inductor cache restore