diff --git a/shortfin/python/shortfin_apps/llm/components/kvcache/trie_attention_cache.py b/shortfin/python/shortfin_apps/llm/components/kvcache/trie_attention_cache.py index fbb008005..3993e2444 100644 --- a/shortfin/python/shortfin_apps/llm/components/kvcache/trie_attention_cache.py +++ b/shortfin/python/shortfin_apps/llm/components/kvcache/trie_attention_cache.py @@ -90,6 +90,10 @@ def __eq__(self, other: object) -> bool: """Nodes are equal only if they are the same object.""" return self is other + def __lt__(self, other): + """Sort nodes by their memory address.""" + return id(self) < id(other) + class TriePagedAttentionCacheAllocation(PageAllocation): """Represents a page allocation in the trie-based cache.