Repository navigation
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/25621
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: ⏳ 2 Pending, 2 Unrelated FailuresAs of commit 21587c4 with merge base 5f6a523 ( BROKEN TRUNK - The following jobs failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
|
@claude /pr-review Please review current head |
|
Claude finished @Gasoonjia's task in 50m 41s —— View job Needs Discussion. The opt-in ABI 2 runtime-columns path has no correctness blocker, but three design problems need a fix or explicit sign-off:
CI also can't confirm the expected-failure gate on Full review of
|
| Gate item (PR body) | a80ab388 |
|---|---|
unittest-cuda (system): four DFlash failures, same as main |
Queued and not started in both the PR run and the push run. Unverified. |
unittest-cuda (kernel): the earlier run failed in dependency install, "not a pass" |
Queued, not started. No passing kernel run exists yet. |
CUDA jobs that exercise this diff (unittest-cuda-runtime, unittest-cuda-muse-glimmer-batching, the three muse-glimmer e2e jobs) |
Queued, not started. Unverified. |
| MLX: one unexplained Voxtral realtime failure | In the PR run, test-mlx-voxtral-realtime and test-mlx-dflash are still running and all other MLX jobs passed. The push run passed, but voxtral-realtime was skipped there. Unverified. |
| Arm/QNN failures match main | Test ARM Backend and Test QNN Backend passed in both runs. The only trunk failure, test_smaller_stories_llama_vkml, was curl: (56) Recv failure: Connection reset by peer while downloading the Vulkan SDK. The same job passed in the push trunk run. |
| CoreML failed during environment setup | Passed in both runs. |
| Not in the gate | pull / unittest / windows failed inside pip install . with Cannot restore timestamp ".../XNNPACK/CMakeFiles/generate.stamp": Access is denied (MSB8066). That looks like a Windows file-lock flake rather than this diff. The push-run twin is still running. |
Not fully reviewed:
backends/cuda/runtime/test/test_cuda_kv_cache.cpp(+646, partly)backends/cuda/runtime/test/test_cuda_backend_execute.cpp(+183, partly)backends/cuda/tests/test_offgraph_kv_batched_sequence.py(diff only)examples/models/muse-glimmer/tests/check_runtime_kv_columns.py(diff only)
Code Quality
- (minor)
sdpa_varlendoesn't enforce its 5-wide layout precondition (backends/cuda/triton/kernels/sdpa_varlen.py:456-465).- The docstring (
408-411) requires contiguous column/head lanes for 5-wideseq_info. The kernels computestride_kr = columns * stride_kcand ignorekey.stride(0)(94-96,254-256). - The wrapper only checks
stride(-1) == 1andshape[1] in (4, 5), so a permuted or sliced K/V view is mis-addressed with no error. The in-tree lowering passes dense storage and is unaffected. - Fix: when
seq_info.shape[1] == 5, raise unlesskey.stride(2) == D and key.stride(1) == Hkv * D, and the same forvalue. Fix this →
- The docstring (
- (minor) The generic allocator carries one caller's ordering rule (
extension/cuda/cuda_allocator.cpp:847-850).- The rule is "must not allocate a host snapshot that can throw before pitch reconciliation".
- It exists because
resize_columnstrims after the pool commits (cuda_kv_pool.cpp:605-616) but beforeensure_columnsupdatescolumns_and the column mapping (cuda_kv_cache.cpp:1385-1388). - Only the global
operator newoverride inextension/cuda/test/cuda_allocator_exit.cppenforces it. - Fix: trim in
ensure_columnsafter reconciliation, and the constraint goes away. Fix this →
Testing
- (major) Nothing tests idle compaction through the production path.
- The probe sleeps 550 ms and calls
on_idle()directly (examples/models/muse-glimmer/tests/runtime_kv_columns_probe.cpp:290-292). RunnerMaintenanceTest.IdleHookRunsBetweenBatchesOnTheEngineThreaduses aFakeExecutor(extension/llm/batching/test/runner_test.cpp:382-387).- Untested: a
RunnerdrivingCudaExecutor::on_idleon a real ABI-2 cache. - Untested: cache activity inside the 500 ms grace suppressing compaction.
- Untested: the failure and poison path. The PR body lists real-cache fault injection as a follow-up.
- Fix this →
- The probe sleeps 550 ms and calls
API Design
- (major) The new
Executor::on_idle()hook can't report failure, andCudaExecutordrops it (extension/llm/batching/executor.h:97-100,runner.cpp:801-809,cuda_executor.cpp:1127-1135).on_idle()returnsvoid, the Runner only catches exceptions, and the compactionErrorgoes only toET_LOG, which is compiled out of release builds.- The PR body defers "release observability", but two problems go beyond logging:
- No backoff. A failure before commit rolls back and leaves the trigger condition true. The Runner's idle loop then retries every 500 ms, paying a device sync and two allocator/graph trims each time.
- Silent poisoning. A failure after commit sets
poisoned_(cuda_kv_cache.cpp:1389-1391). Every later admission and step then fails, and nothing points back at idle maintenance.
- Fix: return
Errorfromon_idle()so the Runner can record it and back off. Alternatively, back off insideCudaExecutorand expose a failure count and the last error viakv_metrics(). Fix this →
- (minor)
graph_metrics()can't tell "no data" from "no failures."CudaKVCache::graph_metricsreturns{}by default (backends/cuda/runtime/cuda_kv_cache.h:101-103), and onlycuda_kv_cache.cpp:1244-1247overrides it.- As a result,
CudaExecutor::graph_metrics(cuda_executor.cpp:1103-1105) reports all-zero counters for every other cache kind and for any method the pool never bound. Acapture_failures == 0check passes vacuously in both cases. - Fix: return
std::optional<CudaGraphMetrics>, and have the probe and checker require metrics for graph-enabled methods. Fix this →
- (minor) The generic cache API drifted from its docs.
kBatchedSequenceRuntimeis described as "Batched-sequence ABI 2" (extension/llm/cache/cache_registry.h:79-81). That is the CUDA lowering's term, not a backend-agnostic contract such as "physical width can change between forwards; the pitch arrives in the step's seq_info".- The README "Cache kinds" table (
extension/llm/cache/README.md:137-142) doesn't list the new kind. seq_new()may now returnnulloptfor "insufficient resources" (cache.h:114-115). Butmax_seqs()(110-113) still says callers can size themselves against it to avoid workseq_newwould refuse. That no longer holds for this kind, andSessionTable(session_table.cpp:83-84) reports both causes as the samenullopt.- Fix this →
Thread Safety
- (low confidence) A partly failed
prepare_stepisn't fenced (backends/cuda/runtime/cuda_kv_cache.cpp:1127-1178).inflight_is set only on success (1178). Supposepool_.prepare()grows storage on the caller's stream, and thenreserve_staging,upload/fence_stagingorplan.planfails. The backend'skv_preparedguard never arms, soabort_step()doesn't run.- A later ABI-2
seq_cloneoncudaStreamPerThreadcould then read storage before the grow copy lands. This only applies to methods that run on a caller-provided stream; the default stream has no race. - I didn't confirm that
pool_.prepare()leaves that copy unfenced. If it does, settinginflight_as soon aspool_.prepare()succeeds closes the gap.
Performance
- (major) Idle compaction has no hysteresis (
backends/cuda/batching/cuda_executor.cpp:1117-1129).- The shrink trigger (
2·live+1 < physical) and the target are the same value:compact_columns(live)givesmin(max_seqs, 2·live) + 1(cuda_kv_cache.cpp:1330-1333). - Every session that closes while the runner is idle triggers a resize 500 ms later. Draining nine idle-open sessions from 17 columns costs eight resizes (17→15→13→…→3→2).
- At zero live sessions the cache drops to 2 columns. The next burst of nine admissions then pays 2→3→5→9→17 again: four resizes, each a device sync, a copy of every retained column and an
invalidate_bindings()that drops all CUDA graphs for recapture. That undoes the rationale in the comment atcuda_kv_cache.cpp:1320-1324. - Compaction runs on the engine thread before
wait_for(runner.cpp:804), so requests that arrive meanwhile queue behind it. - The 500 ms grace and the spare rule are hard-coded.
- Fix: add hysteresis, for example shrink only when
physical > 4·live+1, or floor at a decaying high-water mark. Make the grace and spare countCudaExecutorConfigknobs. Fix this →
- The shrink trigger (
- (major) Admission-time growth trims the device's whole allocator and graph memory.
ensure_columnshard-codestrim_unused=true(cuda_kv_cache.cpp:1373-1381). Every resize, not just compaction, therefore callsCudaAllocator::release_cached_memory(device_): before allocating (cuda_kv_pool.cpp:530-532), after commit (610-616), and again on rollback (540-542).- That call runs
cudaMemPoolTrimTo(pool, 0)andcudaDeviceGraphMemTrim(device). The latter is documented atextension/cuda/cuda_allocator.cpp:833-836as releasing unused graph memory "cached by every user of the device". - So each admission that grows the cache makes the next forward re-reserve its workspace and graph memory, and the same goes for any other model or library on the device.
- Fix: pass
trim_unusedonly for compaction, and leave growth on the cached pool. Fix this →
- (minor) Growth briefly holds old and new storage, up to 1.77× ABI 1's footprint (
cuda_kv_cache.cpp:1325-1329;cuda_kv_pool.cpp:544-554vs598-600).- Every replacement is allocated before any old layer is freed.
- With
max_seqs = 21(the probe default), 9→17 needs 26 column-widths and 17→22 needs 39. ABI 1 allocates its 22 up front and never allocates at admission. - So on a GPU sized for ABI 1, ABI 2 admission can return
nullopt. - Fix: when the doubled width lands near
max_seqs + 1, grow straight to it; 9→22 needs 31 and skips a resize. Otherwise, document the transient. Fix this →
Recommendation
Needs Discussion
- CI. None of the CUDA jobs that exercise this diff has started on
a80ab388, including both CUDA gate items, and MLX Voxtral realtime is still running. Prior qualification of952486c40does not carry over. To confirm the gate on this head:unittest-cuda (system)must finish with only the four documented DFlash failures.unittest-cuda (kernel)must actually run its tests, which it hasn't done on any recorded run.- The remaining CUDA and MLX jobs must pass or match the gate.
- Code. There is no blocker, and ABI 2 is opt-in. The three major items need a decision: fix them, or explicitly accept them as follow-ups. They are idle-compaction hysteresis, device-wide trims on growth, and
on_idlefailure handling. I would fix the trim-on-growth item now. It changes allocator behaviour for every user of the device, and the fix is one line inensure_columns. - Path to Approve. Once CI confirms the gate and the major items are resolved, this is an Approve.
Task list
- Read the PR context, comments and documented expected-failure gate
- Diff
a80ab388againstmain(ec5937f8), 29 files - Run three independent reviews against
.claude/skills/pr-review/review-checklist.md - Consolidate and fact-check findings
- Recheck current-head CI against the gate (no dispatch, rerun or cancel)
- Post final review
|
@claude /pr-review Please review head Local validation: 230 Runner tests, 6 CI workload tests, Python checks, and host syntax/type checks of the actual CUDA pool/cache/tests/executor passed. GPU execution on this head is still pending normal CI; previous-head results are not claimed as qualification. Keep the review focused on the runtime physical-column feature and its necessary contracts. Do not expand historical compatibility, allocator-retention policy, router, prefix, or unrelated kernel tuning. |
|
Claude finished @Gasoonjia's task in 48m 22s —— View job Request Changes: 66a6470 changed PR Review: #25621 (head 66a6470 vs origin/main)SummaryAdds ABI 2 for the CUDA batched-sequence off-graph KV cache: There is one blocker, listed under Infrastructure. The CI harness overrides I found the blocker by reading the code, not by compiling it. CUDA CI on this head is still queued: 14 of 35 runs have passed and none have failed. I did not fully review Code Quality
Infrastructure
Testing
API Design
Performance
RecommendationRequest Changes The
|
|
@claude /pr-review Please review current head Keep this PR focused on runtime physical columns and the current exporter/runtime contract. New-head CI must qualify independently; no workflow dispatch, rerun or cancellation is requested. |
|
All four minor follow-ups from the approved review are addressed in |
6c1bcce to
3bff904
Compare
Grow physical session columns on admission using the default five-field sequence interface, preserving live KV and rebinding CUDA graphs after storage moves. Cover failed admission recovery and exact mini-model logits; keep shrinking as a separate follow-up. Authored with OpenAI Codex assistance.
Use the documented batching target, enforce native cache coverage without skipped cases, and retain only correctness and graph counters in the probe. Bound the Make target parallelism to the available CPU count.
3bff904 to
21587c4
Compare
|
@claude /pr-review Rebased onto main A100 checks of the rebased PR1/PR2 stack passed Python/kernel tests, native cache/Runner/allocator tests, fresh cell/sequence DFlash tests, and exact solo growth/shrink/regrowth with CUDA graphs. Normal push CI is pending; the allocator suite has four expected no-pool-only skips on this pool-enabled device. |
|
Claude finished @Gasoonjia's task in 30m 46s —— View job Approve: at Detailed reviewPR Review: #25621SummaryThe PR grows the batched-sequence KV storage's physical columns geometrically on admission (2 → 3 → 5 → 9 → … → I found no issues in live KV preservation, allocation-failure rollback or graph rebinding. Test coverage has one gap (grow-mode Not fully reviewed:
CI was not rerun or dispatched. The A100 results and the four expected allocator skips come from your comment; I did not reproduce them. Code Quality
Testing
Performance
RecommendationApprove None of the five items blocks merging. The |
CUDA batched-sequence KV caches grow physical session columns on admission using the five-field sequence interface by default. Live history survives resizing, and CUDA graphs rebind when storage moves. Shrinking and idle maintenance are separate follow-ups.
Native cache tests and a same-export mini-model check cover KV preservation, sparse owners, wrapped Ring cloning, failed admissions and recovery, and graph recapture. Resize documentation describes its transient old-plus-replacement memory requirement.
Authored with OpenAI Codex assistance.