fix: set all_tied_weights_keys for transformers 5.6 compatibility
Browse files
modeling_spatial_embeddings.py
CHANGED
|
@@ -143,10 +143,15 @@ class EmbeddingProjector(nn.Module):
|
|
| 143 |
|
| 144 |
class SpatialEmbeddingsModel(PreTrainedModel):
|
| 145 |
config_class = SpatialEmbeddingsConfig
|
|
|
|
| 146 |
|
| 147 |
def __init__(self, config: SpatialEmbeddingsConfig):
|
| 148 |
super().__init__(config)
|
| 149 |
self.config = config
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
|
| 151 |
# Initialize backbone from config rather than from_pretrained.
|
| 152 |
# Calling from_pretrained inside __init__ is an anti-pattern in transformers ≥5:
|
|
|
|
| 143 |
|
| 144 |
class SpatialEmbeddingsModel(PreTrainedModel):
|
| 145 |
config_class = SpatialEmbeddingsConfig
|
| 146 |
+
_tied_weights_keys = []
|
| 147 |
|
| 148 |
def __init__(self, config: SpatialEmbeddingsConfig):
|
| 149 |
super().__init__(config)
|
| 150 |
self.config = config
|
| 151 |
+
# transformers ≥5.6 accesses all_tied_weights_keys before tie_weights() is called
|
| 152 |
+
# for custom trust_remote_code models; set it here since we have no tied weights.
|
| 153 |
+
if not hasattr(self, "all_tied_weights_keys"):
|
| 154 |
+
self.all_tied_weights_keys = {}
|
| 155 |
|
| 156 |
# Initialize backbone from config rather than from_pretrained.
|
| 157 |
# Calling from_pretrained inside __init__ is an anti-pattern in transformers ≥5:
|