Skip to content
Merged
Changes from 4 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/transformers/cache_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from transformers.pytorch_utils import is_torch_greater_or_equal_than_2_6

from .configuration_utils import PretrainedConfig
from .modeling_utils import is_fsdp_enabled
from .utils import (
is_hqq_available,
is_quanto_greater,
Expand Down Expand Up @@ -987,8 +988,8 @@ def from_legacy_cache(cls, past_key_values: tuple[tuple[torch.FloatTensor, torch


# Utilities for `DynamicCache` <> torch.export support

if is_torch_greater_or_equal("2.3"):
# Pytree registration is not supported for FSDP runs, see here: https://github.com/huggingface/transformers/issues/39795
if is_torch_greater_or_equal("2.3") and not is_fsdp_enabled():

def _get_cache_dict(cache: DynamicCache):
if any(not isinstance(layer, DynamicLayer) for layer in cache.layers):
Expand Down