Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 14 additions & 0 deletions src/transformers/models/apertus/modeling_apertus.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,20 @@ def __init__(self, config: ApertusConfig, device=None):
self.register_buffer("inv_freq", inv_freq, persistent=False)
self.original_inv_freq = inv_freq

# Add a compatibility method so callers expecting PreTrainedModel-like API don't crash.
def get_parameter_or_buffer(self, name: str):
# Prefer direct attribute access (parameters and buffers are attributes)
if hasattr(self, name):
return getattr(self, name)
# Fallback: search named parameters and buffers (non-recursive to keep semantics)
for n, p in self.named_parameters(recurse=False):
if n == name:
return p
for n, b in self.named_buffers(recurse=False):
if n == name:
return b
raise AttributeError(f"{self.__class__.__name__} has no parameter or buffer named '{name}'")

@staticmethod
def compute_default_rope_parameters(
config: Optional[ApertusConfig] = None,
Expand Down
14 changes: 14 additions & 0 deletions src/transformers/models/arcee/modeling_arcee.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,20 @@ def __init__(self, config: ArceeConfig, device=None):
self.register_buffer("inv_freq", inv_freq, persistent=False)
self.original_inv_freq = inv_freq

# Add a compatibility method so callers expecting PreTrainedModel-like API don't crash.
def get_parameter_or_buffer(self, name: str):
# Prefer direct attribute access (parameters and buffers are attributes)
if hasattr(self, name):
return getattr(self, name)
# Fallback: search named parameters and buffers (non-recursive to keep semantics)
for n, p in self.named_parameters(recurse=False):
if n == name:
return p
for n, b in self.named_buffers(recurse=False):
if n == name:
return b
raise AttributeError(f"{self.__class__.__name__} has no parameter or buffer named '{name}'")

@staticmethod
def compute_default_rope_parameters(
config: Optional[ArceeConfig] = None,
Expand Down
14 changes: 14 additions & 0 deletions src/transformers/models/aria/modeling_aria.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,20 @@ def __init__(self, config: AriaTextConfig, device=None):
self.register_buffer("inv_freq", inv_freq, persistent=False)
self.original_inv_freq = inv_freq

# Add a compatibility method so callers expecting PreTrainedModel-like API don't crash.
def get_parameter_or_buffer(self, name: str):
# Prefer direct attribute access (parameters and buffers are attributes)
if hasattr(self, name):
return getattr(self, name)
# Fallback: search named parameters and buffers (non-recursive to keep semantics)
for n, p in self.named_parameters(recurse=False):
if n == name:
return p
for n, b in self.named_buffers(recurse=False):
if n == name:
return b
raise AttributeError(f"{self.__class__.__name__} has no parameter or buffer named '{name}'")

@staticmethod
def compute_default_rope_parameters(
config: Optional[AriaTextConfig] = None,
Expand Down
14 changes: 14 additions & 0 deletions src/transformers/models/bamba/modeling_bamba.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,20 @@ def __init__(self, config: BambaConfig, device=None):
self.register_buffer("inv_freq", inv_freq, persistent=False)
self.original_inv_freq = inv_freq

# Add a compatibility method so callers expecting PreTrainedModel-like API don't crash.
def get_parameter_or_buffer(self, name: str):
# Prefer direct attribute access (parameters and buffers are attributes)
if hasattr(self, name):
return getattr(self, name)
# Fallback: search named parameters and buffers (non-recursive to keep semantics)
for n, p in self.named_parameters(recurse=False):
if n == name:
return p
for n, b in self.named_buffers(recurse=False):
if n == name:
return b
raise AttributeError(f"{self.__class__.__name__} has no parameter or buffer named '{name}'")

@staticmethod
def compute_default_rope_parameters(
config: Optional[BambaConfig] = None,
Expand Down
14 changes: 14 additions & 0 deletions src/transformers/models/bitnet/modeling_bitnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,20 @@ def __init__(self, config: BitNetConfig, device=None):
self.register_buffer("inv_freq", inv_freq, persistent=False)
self.original_inv_freq = inv_freq

# Add a compatibility method so callers expecting PreTrainedModel-like API don't crash.
def get_parameter_or_buffer(self, name: str):
# Prefer direct attribute access (parameters and buffers are attributes)
if hasattr(self, name):
return getattr(self, name)
# Fallback: search named parameters and buffers (non-recursive to keep semantics)
for n, p in self.named_parameters(recurse=False):
if n == name:
return p
for n, b in self.named_buffers(recurse=False):
if n == name:
return b
raise AttributeError(f"{self.__class__.__name__} has no parameter or buffer named '{name}'")

@staticmethod
def compute_default_rope_parameters(
config: Optional[BitNetConfig] = None,
Expand Down
14 changes: 14 additions & 0 deletions src/transformers/models/blt/modeling_blt.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,20 @@ def __init__(self, config: BltConfig, device=None):
self.register_buffer("inv_freq", inv_freq, persistent=False)
self.original_inv_freq = inv_freq

# Add a compatibility method so callers expecting PreTrainedModel-like API don't crash.
def get_parameter_or_buffer(self, name: str):
# Prefer direct attribute access (parameters and buffers are attributes)
if hasattr(self, name):
return getattr(self, name)
# Fallback: search named parameters and buffers (non-recursive to keep semantics)
for n, p in self.named_parameters(recurse=False):
if n == name:
return p
for n, b in self.named_buffers(recurse=False):
if n == name:
return b
raise AttributeError(f"{self.__class__.__name__} has no parameter or buffer named '{name}'")

@staticmethod
def compute_default_rope_parameters(
config: Optional[BltConfig] = None,
Expand Down
14 changes: 14 additions & 0 deletions src/transformers/models/chameleon/modeling_chameleon.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,20 @@ def __init__(self, config: ChameleonConfig, device=None):
self.register_buffer("inv_freq", inv_freq, persistent=False)
self.original_inv_freq = inv_freq

# Add a compatibility method so callers expecting PreTrainedModel-like API don't crash.
def get_parameter_or_buffer(self, name: str):
# Prefer direct attribute access (parameters and buffers are attributes)
if hasattr(self, name):
return getattr(self, name)
# Fallback: search named parameters and buffers (non-recursive to keep semantics)
for n, p in self.named_parameters(recurse=False):
if n == name:
return p
for n, b in self.named_buffers(recurse=False):
if n == name:
return b
raise AttributeError(f"{self.__class__.__name__} has no parameter or buffer named '{name}'")

@staticmethod
def compute_default_rope_parameters(
config: Optional[ChameleonConfig] = None,
Expand Down
14 changes: 14 additions & 0 deletions src/transformers/models/cohere/modeling_cohere.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,20 @@ def __init__(self, config: CohereConfig, device=None):
self.register_buffer("inv_freq", inv_freq, persistent=False)
self.original_inv_freq = inv_freq

# Add a compatibility method so callers expecting PreTrainedModel-like API don't crash.
def get_parameter_or_buffer(self, name: str):
# Prefer direct attribute access (parameters and buffers are attributes)
if hasattr(self, name):
return getattr(self, name)
# Fallback: search named parameters and buffers (non-recursive to keep semantics)
for n, p in self.named_parameters(recurse=False):
if n == name:
return p
for n, b in self.named_buffers(recurse=False):
if n == name:
return b
raise AttributeError(f"{self.__class__.__name__} has no parameter or buffer named '{name}'")

@staticmethod
def compute_default_rope_parameters(
config: Optional[CohereConfig] = None,
Expand Down
14 changes: 14 additions & 0 deletions src/transformers/models/cohere2/modeling_cohere2.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,20 @@ def __init__(self, config: Cohere2Config, device=None):
self.register_buffer("inv_freq", inv_freq, persistent=False)
self.original_inv_freq = inv_freq

# Add a compatibility method so callers expecting PreTrainedModel-like API don't crash.
def get_parameter_or_buffer(self, name: str):
# Prefer direct attribute access (parameters and buffers are attributes)
if hasattr(self, name):
return getattr(self, name)
# Fallback: search named parameters and buffers (non-recursive to keep semantics)
for n, p in self.named_parameters(recurse=False):
if n == name:
return p
for n, b in self.named_buffers(recurse=False):
if n == name:
return b
raise AttributeError(f"{self.__class__.__name__} has no parameter or buffer named '{name}'")

@staticmethod
def compute_default_rope_parameters(
config: Optional[Cohere2Config] = None,
Expand Down
14 changes: 14 additions & 0 deletions src/transformers/models/csm/modeling_csm.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,20 @@ def __init__(self, config: CsmConfig, device=None):
self.register_buffer("inv_freq", inv_freq, persistent=False)
self.original_inv_freq = inv_freq

# Add a compatibility method so callers expecting PreTrainedModel-like API don't crash.
def get_parameter_or_buffer(self, name: str):
# Prefer direct attribute access (parameters and buffers are attributes)
if hasattr(self, name):
return getattr(self, name)
# Fallback: search named parameters and buffers (non-recursive to keep semantics)
for n, p in self.named_parameters(recurse=False):
if n == name:
return p
for n, b in self.named_buffers(recurse=False):
if n == name:
return b
raise AttributeError(f"{self.__class__.__name__} has no parameter or buffer named '{name}'")

@staticmethod
def compute_default_rope_parameters(
config: Optional[CsmConfig] = None,
Expand Down
14 changes: 14 additions & 0 deletions src/transformers/models/cwm/modeling_cwm.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,20 @@ def __init__(self, config: CwmConfig, device=None):
self.register_buffer("inv_freq", inv_freq, persistent=False)
self.original_inv_freq = inv_freq

# Add a compatibility method so callers expecting PreTrainedModel-like API don't crash.
def get_parameter_or_buffer(self, name: str):
# Prefer direct attribute access (parameters and buffers are attributes)
if hasattr(self, name):
return getattr(self, name)
# Fallback: search named parameters and buffers (non-recursive to keep semantics)
for n, p in self.named_parameters(recurse=False):
if n == name:
return p
for n, b in self.named_buffers(recurse=False):
if n == name:
return b
raise AttributeError(f"{self.__class__.__name__} has no parameter or buffer named '{name}'")

@staticmethod
def compute_default_rope_parameters(
config: Optional[CwmConfig] = None,
Expand Down
14 changes: 14 additions & 0 deletions src/transformers/models/dbrx/modeling_dbrx.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,20 @@ def __init__(self, config: DbrxConfig, device=None):
self.register_buffer("inv_freq", inv_freq, persistent=False)
self.original_inv_freq = inv_freq

# Add a compatibility method so callers expecting PreTrainedModel-like API don't crash.
def get_parameter_or_buffer(self, name: str):
# Prefer direct attribute access (parameters and buffers are attributes)
if hasattr(self, name):
return getattr(self, name)
# Fallback: search named parameters and buffers (non-recursive to keep semantics)
for n, p in self.named_parameters(recurse=False):
if n == name:
return p
for n, b in self.named_buffers(recurse=False):
if n == name:
return b
raise AttributeError(f"{self.__class__.__name__} has no parameter or buffer named '{name}'")

@staticmethod
def compute_default_rope_parameters(
config: Optional[DbrxConfig] = None,
Expand Down
14 changes: 14 additions & 0 deletions src/transformers/models/deepseek_v2/modeling_deepseek_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,20 @@ def __init__(self, config: DeepseekV2Config, device=None):
self.register_buffer("inv_freq", inv_freq, persistent=False)
self.original_inv_freq = inv_freq

# Add a compatibility method so callers expecting PreTrainedModel-like API don't crash.
def get_parameter_or_buffer(self, name: str):
# Prefer direct attribute access (parameters and buffers are attributes)
if hasattr(self, name):
return getattr(self, name)
# Fallback: search named parameters and buffers (non-recursive to keep semantics)
for n, p in self.named_parameters(recurse=False):
if n == name:
return p
for n, b in self.named_buffers(recurse=False):
if n == name:
return b
raise AttributeError(f"{self.__class__.__name__} has no parameter or buffer named '{name}'")

@staticmethod
def compute_default_rope_parameters(
config: Optional[DeepseekV2Config] = None,
Expand Down
14 changes: 14 additions & 0 deletions src/transformers/models/deepseek_v3/modeling_deepseek_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,20 @@ def __init__(self, config: DeepseekV3Config, device=None):
self.register_buffer("inv_freq", inv_freq, persistent=False)
self.original_inv_freq = inv_freq

# Add a compatibility method so callers expecting PreTrainedModel-like API don't crash.
def get_parameter_or_buffer(self, name: str):
# Prefer direct attribute access (parameters and buffers are attributes)
if hasattr(self, name):
return getattr(self, name)
# Fallback: search named parameters and buffers (non-recursive to keep semantics)
for n, p in self.named_parameters(recurse=False):
if n == name:
return p
for n, b in self.named_buffers(recurse=False):
if n == name:
return b
raise AttributeError(f"{self.__class__.__name__} has no parameter or buffer named '{name}'")

@staticmethod
def compute_default_rope_parameters(
config: Optional[DeepseekV3Config] = None,
Expand Down
14 changes: 14 additions & 0 deletions src/transformers/models/dia/modeling_dia.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,20 @@ def __init__(self, config: DiaConfig, device=None):
self.register_buffer("inv_freq", inv_freq, persistent=False)
self.original_inv_freq = inv_freq

# Add a compatibility method so callers expecting PreTrainedModel-like API don't crash.
def get_parameter_or_buffer(self, name: str):
# Prefer direct attribute access (parameters and buffers are attributes)
if hasattr(self, name):
return getattr(self, name)
# Fallback: search named parameters and buffers (non-recursive to keep semantics)
for n, p in self.named_parameters(recurse=False):
if n == name:
return p
for n, b in self.named_buffers(recurse=False):
if n == name:
return b
raise AttributeError(f"{self.__class__.__name__} has no parameter or buffer named '{name}'")

@staticmethod
def compute_default_rope_parameters(
config: Optional[DiaConfig] = None,
Expand Down
14 changes: 14 additions & 0 deletions src/transformers/models/diffllama/modeling_diffllama.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,20 @@ def __init__(self, config: DiffLlamaConfig, device=None):
self.register_buffer("inv_freq", inv_freq, persistent=False)
self.original_inv_freq = inv_freq

# Add a compatibility method so callers expecting PreTrainedModel-like API don't crash.
def get_parameter_or_buffer(self, name: str):
# Prefer direct attribute access (parameters and buffers are attributes)
if hasattr(self, name):
return getattr(self, name)
# Fallback: search named parameters and buffers (non-recursive to keep semantics)
for n, p in self.named_parameters(recurse=False):
if n == name:
return p
for n, b in self.named_buffers(recurse=False):
if n == name:
return b
raise AttributeError(f"{self.__class__.__name__} has no parameter or buffer named '{name}'")

@staticmethod
def compute_default_rope_parameters(
config: Optional[DiffLlamaConfig] = None,
Expand Down
14 changes: 14 additions & 0 deletions src/transformers/models/doge/modeling_doge.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,20 @@ def __init__(self, config: DogeConfig, device=None):
self.register_buffer("inv_freq", inv_freq, persistent=False)
self.original_inv_freq = inv_freq

# Add a compatibility method so callers expecting PreTrainedModel-like API don't crash.
def get_parameter_or_buffer(self, name: str):
# Prefer direct attribute access (parameters and buffers are attributes)
if hasattr(self, name):
return getattr(self, name)
# Fallback: search named parameters and buffers (non-recursive to keep semantics)
for n, p in self.named_parameters(recurse=False):
if n == name:
return p
for n, b in self.named_buffers(recurse=False):
if n == name:
return b
raise AttributeError(f"{self.__class__.__name__} has no parameter or buffer named '{name}'")

@staticmethod
def compute_default_rope_parameters(
config: Optional[DogeConfig] = None,
Expand Down
14 changes: 14 additions & 0 deletions src/transformers/models/dots1/modeling_dots1.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,20 @@ def __init__(self, config: Dots1Config, device=None):
self.register_buffer("inv_freq", inv_freq, persistent=False)
self.original_inv_freq = inv_freq

# Add a compatibility method so callers expecting PreTrainedModel-like API don't crash.
def get_parameter_or_buffer(self, name: str):
# Prefer direct attribute access (parameters and buffers are attributes)
if hasattr(self, name):
return getattr(self, name)
# Fallback: search named parameters and buffers (non-recursive to keep semantics)
for n, p in self.named_parameters(recurse=False):
if n == name:
return p
for n, b in self.named_buffers(recurse=False):
if n == name:
return b
raise AttributeError(f"{self.__class__.__name__} has no parameter or buffer named '{name}'")

@staticmethod
def compute_default_rope_parameters(
config: Optional[Dots1Config] = None,
Expand Down
15 changes: 15 additions & 0 deletions src/transformers/models/efficientloftr/modeling_efficientloftr.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,21 @@ def __init__(self, config: EfficientLoFTRConfig, device=None):
self.register_buffer("inv_freq", inv_freq, persistent=False)
self.original_inv_freq = inv_freq

# Add a compatibility method so callers expecting PreTrainedModel-like API don't crash.
# Ignore copy
def get_parameter_or_buffer(self, name: str):
# Prefer direct attribute access (parameters and buffers are attributes)
if hasattr(self, name):
return getattr(self, name)
# Fallback: search named parameters and buffers (non-recursive to keep semantics)
for n, p in self.named_parameters(recurse=False):
if n == name:
return p
for n, b in self.named_buffers(recurse=False):
if n == name:
return b
raise AttributeError(f"{self.__class__.__name__} has no parameter or buffer named '{name}'")

@staticmethod
# Ignore copy
def compute_default_rope_parameters(
Expand Down
Loading