Skip to content

refactor: leverage ExecutorTorch's CustomKVCache for per-layer cache management#78

Merged
guangy10 merged 1 commit into
huggingface:mainfrom
kimishpatel:refactor_custom_kv_cache
Jun 10, 2025
Merged

refactor: leverage ExecutorTorch's CustomKVCache for per-layer cache management#78
guangy10 merged 1 commit into
huggingface:mainfrom
kimishpatel:refactor_custom_kv_cache

Conversation

@kimishpatel

Copy link
Copy Markdown
Collaborator
Summary:

    - Replace separate key/value cache tensors with CustomKVCache
      instances
    - Use CustomKVCache.update() method instead of manual
      torch.ops.llama.update_cache calls
    - Create self.kv_cache list with one CustomKVCache per layer
    - Maintain compatibility with parent StaticCache class
    - Fix type safety issues in get_seq_length method
    - Simplify cache update logic by leveraging ExecutorTorch's proven
      implementation

Test Plan:
CI

@kimishpatel

Copy link
Copy Markdown
Collaborator Author

@guangy10 in prep for ring kv cache

@guangy10

guangy10 commented Jun 6, 2025

Copy link
Copy Markdown
Collaborator

Need rebase in order to run in CI

…management

Summary:

    - Replace separate key/value cache tensors with CustomKVCache
      instances
    - Use CustomKVCache.update() method instead of manual
      torch.ops.llama.update_cache calls
    - Create self.kv_cache list with one CustomKVCache per layer
    - Maintain compatibility with parent StaticCache class
    - Fix type safety issues in get_seq_length method
    - Simplify cache update logic by leveraging ExecutorTorch's proven
      implementation

Test Plan:
CI

Reviewers:

Subscribers:

Tasks:

Tags:
@kimishpatel
kimishpatel force-pushed the refactor_custom_kv_cache branch from cb5e5bd to b6d6fe1 Compare June 10, 2025 03:17
@kimishpatel

Copy link
Copy Markdown
Collaborator Author

@guangy10 rebased

@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@guangy10
guangy10 self-requested a review June 10, 2025 18:35

@guangy10 guangy10 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@guangy10
guangy10 merged commit e1d9cd1 into huggingface:main Jun 10, 2025
106 of 107 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants