Repository navigation
[Refactor] unified-cache: Factor match validators and match completion into helpers - #45714
Conversation
|
This port clears our bar on 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. |
…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>
2fec0c3 to
d40c9a3
Compare
|
This port clears our bar on 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. |
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_helperbuilds the per-component match validators inline, andUnifiedRadixCache._match_treeruns 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_helpercalls 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_treecalls it right after the walk's actions are applied.TestUnifiedRadixCacheActionRoutingpins the order: the walk's actions first (a split routed to FULL, then the freed KV segment), then the completion with the sameparamsandresultobjects, 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.pyandtest_unified_radix_cache_rust.pypass on a CUDA host (TestUnifiedRadixCacheActionRouting: 8 tests, 4 subtests).CI States
Latest PR Test (Base): 🚫 Run #39849934322
Latest PR Test (Extra): ❌ Run #39849933761
Latest PR Test (AMD ROCm 10): 🚫 Run #39849933907