Skip to content

Voxtral Realtime: Refactor StandardEncoderRingKVCache#17729

Open
manuelcandales wants to merge 2 commits intomainfrom
manuel/metal-vr-streaming-refactor
Open

Voxtral Realtime: Refactor StandardEncoderRingKVCache#17729
manuelcandales wants to merge 2 commits intomainfrom
manuel/metal-vr-streaming-refactor

Conversation

@manuelcandales
Copy link
Contributor

This pull request improves device and dtype consistency for streaming encoder buffers and cache classes in voxtral_realtime/model.py. The main changes ensure that all buffers and caches are initialized with the same dtype and device as the encoder weights, which helps prevent runtime errors and improves compatibility across different hardware and export scenarios. It also refactors the cache classes for better code reuse and maintainability.

Device and dtype consistency improvements:

  • The EncoderRingKVCache and StandardEncoderRingKVCache classes now accept dtype and device parameters, ensuring their buffers (k_cache, v_cache) are initialized to match the encoder's configuration.
  • The StreamingAudioEncoderExport class infers dtype and device from encoder weights and uses them when initializing convolution states and cache buffers, ensuring all state is consistently placed and typed.

Cache class refactoring and simplification:

  • StandardEncoderRingKVCache now subclasses EncoderRingKVCache to reduce code duplication, and its docstring clarifies its intended use for export scenarios.
  • The redundant create_causal_mask method in StandardEncoderRingKVCache is removed in favor of the inherited implementation.

Other minor improvements:

  • The create_causal_mask method in EncoderRingKVCache now always uses the device of the cache buffer, simplifying device management.

Copilot AI review requested due to automatic review settings February 26, 2026 03:03
@pytorch-bot
Copy link

pytorch-bot bot commented Feb 26, 2026

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/17729

Note: Links to docs will display an error until the docs builds have been completed.

❌ 12 New Failures

As of commit 76c8860 with merge base bac3ad3 (image):

NEW FAILURES - The following jobs have failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 26, 2026
@manuelcandales manuelcandales removed the request for review from lucylq February 26, 2026 03:04
@manuelcandales manuelcandales added the release notes: none Do not include this in the release notes label Feb 26, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request refactors the streaming encoder cache classes to improve device and dtype consistency, ensuring all buffers are initialized to match the encoder's configuration. This helps prevent runtime errors and improves compatibility across different hardware and export scenarios.

Changes:

  • Added dtype and device parameters to cache classes (EncoderRingKVCache and StandardEncoderRingKVCache)
  • Modified StreamingAudioEncoderExport to infer dtype/device from encoder weights and use them consistently for all buffer initialization
  • Refactored StandardEncoderRingKVCache to inherit from EncoderRingKVCache, eliminating code duplication

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. release notes: none Do not include this in the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants