Skip to content
Open
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
9 changes: 4 additions & 5 deletions angelslim/compressor/transform/rotation/spin.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ def _get(key, default):

def silent_run(self):
"""only set linears and Rotations"""
self._untie_word_embeddings()
self._apply_fused_ln()
if "R1" in self.spin_config.rotation:
self._apply_r1(no_transform=True)
Expand All @@ -167,11 +168,11 @@ def silent_run(self):
self._apply_r4(no_transform=True)

def run(self):
self._untie_word_embeddings()
# fuse norm
self._apply_fused_ln()
# add rotation
if "R1" in self.spin_config.rotation:
self._untie_word_embeddings()
# fuse norm
self._apply_fused_ln()
self._apply_r1()
if "R2" in self.spin_config.rotation:
self._apply_r2()
Expand Down Expand Up @@ -389,8 +390,6 @@ def _apply_fused_ln(self):
"""
self.logger.info("Applying fused layer norm to a linear layer")

self._untie_word_embeddings()

norm_layers = self.quant_model.get_rotation_mapping_layers(
None,
norm_mapping=self.norm_mapping,
Expand Down