Skip to content

[Refactor] unified-cache: Factor match validators and match completion into helpers - #45714

Merged
hanming-lu merged 1 commit into
mainfrom
oss-sync-3444d9c208
Oct 23, 2026
Merged

hanming-lu merged 1 commit into
mainfrom
oss-sync-3444d9c208

Conversation

@metamergebot

@metamergebot metamergebot commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

Follows #45703 (the shared match result fields and the _match_prefix_helper(key, params) signature it introduces); this pull request's base is that branch, and its own diff is the top commit only.

Motivation

UnifiedTreeCore._match_prefix_helper builds the per-component match validators inline, and UnifiedRadixCache._match_tree runs the component finalizers and the linker inline after the walk's actions are applied. A tree core or cache layered on these classes (for example one registered through the tree core registry) that wants another validator, or work between the walk's actions and the finalizers, has to copy both loops.

Modifications

  • UnifiedTreeCore._create_match_validators(params, match_device_only) returns the validator tuple for a walk; _match_prefix_helper calls it for the HiCache case (host-backed nodes allowed) and the device-only case instead of building the tuples inline.
  • UnifiedRadixCache._finalize_match_result(params, result) runs the component finalizers in component order, asserts they emitted no actions, and applies the linker; _match_tree calls it right after the walk's actions are applied.
  • A unit test in TestUnifiedRadixCacheActionRouting pins the order: the walk's actions first (a split routed to FULL, then the freed KV segment), then the completion with the same params and result objects, the finalizers in component order, and the linker last.

No behaviour change for the stock cores: the same calls run in the same order.

Accuracy Tests

Not applicable: no model or kernel numerics change.

Benchmarking and Profiling

Not applicable: no extra work on the match path beyond one method call.

Checklist

  • test/registered/unit/mem_cache/unified_radix_cache/test_unified_radix_cache_core.py, test_unified_radix_cache_hicache.py and test_unified_radix_cache_rust.py pass on a CUDA host (TestUnifiedRadixCacheActionRouting: 8 tests, 4 subtests).
  • pre-commit (isort, ruff, ruff-format, codespell) clean on the touched files.

CI States

Latest PR Test (Base): 🚫 Run #39849934322
Latest PR Test (Extra): ❌ Run #39849933761
Latest PR Test (AMD ROCm 10): 🚫 Run #39849933907

@metamergebot metamergebot added run-ci CI: run the baseline test suite on this PR bypass-fail-fast CI: a failing job no longer aborts its siblings (lint still gates) labels Oct 22, 2026
@metamergebot

Copy link
Copy Markdown
Collaborator Author

This port clears our bar on 2fec0c3df24c015a7d7cd692e8160219efce4aab: every base-a and base-b job is green.
base-c and the accelerator suites are reported but not gated, because they run
on scarce hardware and upstream merges through them routinely.

gate✓ lint✓ build✓ A✓ B✓ C 0/11⏳ other✓ · accel ✗amd

@luccafong @merrymercy @Jialin — could one of you take a look and merge it if you are happy? Nothing else is waiting on our side.

Base automatically changed from oss-sync-e1edc9c9f6 to main October 22, 2026 20:11
@hanming-lu
hanming-lu requested a review from Jialin as a code owner October 22, 2026 20:11
…n into helpers

`UnifiedTreeCore._match_prefix_helper` built the per-component match
validators inline, and `UnifiedRadixCache._match_tree` ran the component
finalizers and the linker inline after applying the walk's actions. A tree
core or cache layered on these classes (for example one registered through
the tree core registry) that needs another validator, or work between the
walk's actions and the finalizers, had to copy both loops.

Move them into two protected helpers with the same behaviour:

- `UnifiedTreeCore._create_match_validators(params, match_device_only)`
  returns the validator tuple for a walk; the HiCache and device-only cases
  call it with the flag they need.
- `UnifiedRadixCache._finalize_match_result(params, result)` runs the
  component finalizers in component order, asserts they emitted no actions,
  and applies the linker; `_match_tree` calls it after the walk's actions
  are applied.

A unit test pins the order: the walk's actions are applied first, then the
completion runs the finalizers in component order and the linker last, with
the same params and result objects passed through.

Co-authored-by: Jialin <Jialin@users.noreply.github.com>
@metamergebot

Copy link
Copy Markdown
Collaborator Author

This port clears our bar on d40c9a3ddf5ab0ee8bc4002ca3f04f662f7a775c: every base-a and base-b job is green.
base-c and the accelerator suites are reported but not gated, because they run
on scarce hardware and upstream merges through them routinely.

gate✓ lint✓ build✓ A✓ B✓ C 0/11⏳ other✓ · accel ✗amd,npu

@luccafong @merrymercy @Jialin — could one of you take a look and merge it if you are happy? Nothing else is waiting on our side.

@hanming-lu
hanming-lu merged commit 94e4611 into main Oct 23, 2026
232 of 258 checks passed
@hanming-lu
hanming-lu deleted the oss-sync-3444d9c208 branch October 23, 2026 01:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bypass-fail-fast CI: a failing job no longer aborts its siblings (lint still gates) run-ci CI: run the baseline test suite on this PR unified-radix-cache

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants