From 82287b06ee04ad321aea800c2aa3d26bee593b4a Mon Sep 17 00:00:00 2001 From: Pablo Monteagudo Lago Date: Mon, 13 Jan 2025 22:11:05 +0000 Subject: [PATCH] Cast rotation matrix to the weight dtype --- src/brevitas/graph/equalize.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/brevitas/graph/equalize.py b/src/brevitas/graph/equalize.py index b1b52c85c..57882b40b 100644 --- a/src/brevitas/graph/equalize.py +++ b/src/brevitas/graph/equalize.py @@ -1350,6 +1350,9 @@ def _apply_rotate( print("Skipping layers") continue + # Cast rotation matrix to the weight dtype + dtype = next(model.parameters()).dtype + rot_mat = rot_mat.to(dtype=dtype) # If the rotation is not fused, redefine as a Parameter, to enable its optimization if not insert_rotation_module and not fuse_rotations: rot_mat = torch.nn.Parameter(rot_mat)