Skip to content

Add cache usage property to ChatSampler and Sampler #471

@arJ-V

Description

@arJ-V

Cache Usage Monitoring Enhancement

Overview

Previously, a TODO was marked to add a property showing how much of the cache is used. This is useful for debugging and monitoring cache usage during multi-turn conversations.


Previous State

  • No easy way to check cache usage without accessing internal last_state directly
  • Users had to manually compute state.used_cache_length / cache_length

Changes

Added Cache Usage Monitoring

Cache usage monitoring was added to both sampler classes:

  • ChatSampler.cache_usage property

    • Returns a (used, total) tuple
    • Returns None if no sampling has been performed yet
  • Sampler.get_cache_usage() static method — For stateless usage with the low-level API

    • Takes a SamplingState and cache_length as parameters

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions