Support: persist scene-test kernel compilation cache - #1675
Conversation
📝 WalkthroughWalkthroughThe PR adds persistent, content-sensitive caching for compiled scene-test ChangesScene-Test Compilation Cache
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant CI as Hardware CI
participant Pytest as pytest
participant Warmup as scene_test_compile
participant Cache as scene_test_cache
participant Compiler as scene_test.py
CI->>CI: Restore build/cache/kernels
CI->>Warmup: Run selected tests with --collect-only
Warmup->>Pytest: Collect scene-test items
Pytest-->>Warmup: Return collected classes
Warmup->>Compiler: Compile selected classes
Compiler->>Cache: Load or compile ChipCallable
Cache-->>Compiler: Return cached artifact
CI->>Pytest: Execute hardware tests
Pytest->>Cache: Reuse compiled artifacts
Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@simpler_setup/scene_test.py`:
- Around line 1032-1055: The artifact metadata built in the compile_artifact_key
call must include a compiler cache token covering the selected compiler version,
relevant compile/link flags, and a schema token for KernelCompiler behavior.
Update the surrounding artifact-key generation to use this token, and add a
regression test proving that changing the schema token invalidates the artifact
key.
In `@simpler_setup/tools/scene_test_compile.py`:
- Around line 24-25: Update the warm-up filtering around item.iter_markers() to
evaluate active pytest skipif conditions, not only markers named "skip", and
skip compilation whenever pytest would skip the collected item. Add a regression
test covering a truthy pytest.mark.skipif condition while preserving compilation
for inactive conditions.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: bdf8b3c9-b100-41e8-8b49-59279b55f34a
📒 Files selected for processing (11)
.github/workflows/_st-npu.ymldocs/ci.mddocs/investigations/2026-07-qwen-scene-test-406s-decomposition.mddocs/testing.mdsimpler_setup/kernel_compiler.pysimpler_setup/scene_test.pysimpler_setup/scene_test_cache.pysimpler_setup/tools/README.mdsimpler_setup/tools/scene_test_compile.pytests/ut/py/test_scene_test_cache.pytests/ut/py/test_scene_test_compile.py
eacc55c to
98b2456
Compare
50485dd to
fb4547e
Compare
fb4547e to
a1dcb88
Compare
|
Rebased onto 必须处理
建议修复
可以考虑
新增测试 ( 验证: 一个无关的既有缺陷(不在本 PR 范围,已单独记录): |
a1dcb88 to
b3a418b
Compare
Store content-addressed ChipCallable artifacts under build/cache/kernels with atomic publication, per-key locking, and integrity validation. An artifact's key covers its orchestration, incore and transitively included sources, the compiler identities and effective fixed flags, a digest of the modules that decide artifact bytes (kernel_compiler.py, toolchain.py, elf_parser.py), the binding's serialized-callable ABI, and a schema constant for the one remaining input nothing else fingerprints: how scene_test assembles compiled binaries into a ChipCallable. Warm selected callables before task-submit without acquiring an NPU. Compilation is serial by default; both onboard jobs opt into eight host workers and preserve artifacts through actions/cache, since actions/checkout clears the ignored build/ tree. The sim jobs have no warm-up step and compile cold. A class the warm-up cannot compile is reported rather than raised: the pass only fills a cache, so the locked run behind it recompiles the class and attributes the error to the case that owns it, instead of an unbuildable kernel costing every later step of the job its results. Entries are content-addressed and never overwritten, so a run prunes entries unused for 14 days and every hit refreshes its entry's mtime; without that the directory grows by one entry per kernel change forever and its actions/cache archive crowds the repository cache budget. An unwritable build/ -- a wheel whose PROJECT_ROOT sits in a read-only site-packages -- degrades to plain in-process compilation with a warning rather than failing a scene test. Per-file digests and include directives are memoized on (path, mtime_ns, size), because the compilation units of one scene test share most of their include closure. Only includes resolvable within the -I list join the closure; toolchain-supplied headers are covered by the compiler --version identity in the key instead. Tests cover reuse, invalidation, corruption, concurrency, skip selection, configurable warm-up parallelism, compile-failure reporting, retention pruning, and read-only fallback. Refs hw-native-sys#1604
Summary
ChipCallableartifacts underbuild/cache/kernels, with source/include-closure, compiler identity/flags/schema, and ABI invalidation, plus integrity validation, atomic publication, and per-key locking--compile-workers 8beforetask-submitwithout acquiring an NPUactions/cache, while keeping the existing batch-level device acquisition and separate SDMA executionLock-boundary measurement
qwen3_14b_decode::StressBatch16Seq3500on a2a3, with both device jobs acquiring immediately:task-submitwallThe cold-cache path moves compilation out of the device allocation rather than shortening first-run wall time. Device-lock wall falls by 77.42 s (58.8%); restored caches also reduce total wall time.
Fixture construction and golden computation remain inside the locked pytest invocation and are intentionally outside this PR's scope.
Testing
--compile-workers 8and rejection of zero workersqwen3_14b_decode::StressBatch16Seq3500: baseline, cold warm-up, cached device run, and hot warm-up all passedClose #1604