integrate streaming session into UnifiedRadixCache#23145
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the streaming session implementation by integrating SessionAwareCache directly into UnifiedRadixCache via composition. This change simplifies the cache management logic by allowing session-related operations to be called directly on the cache object, removing the need for explicit type checks in the scheduler and session controller. Additionally, the BasePrefixCache now includes default implementations for streaming session methods. I have no feedback to provide.
…ng-session # Conflicts: # python/sglang/srt/session/session_controller.py
|
/rerun-test test/registered/unit/mem_cache/test_streaming_session_unit.py test/registered/unit/mem_cache/test_unified_radix_cache_unittest.py test/registered/sessions/test_streaming_session.py test/registered/sessions/test_streaming_session_swa.py test/registered/sessions/test_session_control.py test/registered/sessions/test_session_latency.py |
|
✅ ✅ ✅ |
Summary
UnifiedRadixCachevia embeddedSessionAwareCacheSessionAwareCacheexposes a uniformtry_*contract shared by external-wrapper mode (RadixCache/SWARadixCache/...) and embedded mode (UnifiedRadixCachecomposesSessionAwareCache(inner=self)) -- zero duplication between the two pathsChanges
BasePrefixCachesupports_streaming_session(),release_session(), andsession_held_*()no-op methods so callers (scheduler, runtime checker) don't needisinstance(tree_cache, SessionAwareCache)guardsUnifiedRadixCacheSessionAwareCache(inner=self)whenenable_streaming_sessionis set; overridesupports_streaming_session()to returnTruematch_prefix/inc_lock_ref/dec_lock_ref/cache_finished_reqpre-check session state viatry_*, falling through to the normal radix path otherwise (no recursion -- preconditions prevent re-entry)Scheduler
SessionAwareCachewrap whentree_cache.supports_streaming_session()is alreadyTrueisinstance(tree_cache, SessionAwareCache)checks inscheduler_runtime_checker_mixin-- calls now dispatch through the base class