From 22e7701411509813be4d3022f59e765d4b0ece38 Mon Sep 17 00:00:00 2001 From: Booyaka101 Date: Sat, 6 Jun 2026 18:21:50 +0800 Subject: [PATCH] fix: skip 1-D weights before the norm in DoRA extraction The matched-shape branch computed torch.linalg.norm(tensor_a, dim=1) for every non-4-D tensor, including 1-D weights (e.g. x_pad_token, norm .weight). A 1-D tensor has no dim=1, so this raised 'Dimension out of range ... but got 1' and aborted the whole extraction. The code already skips 1-D tensors a few lines later, so bail out before the norm instead. Fixes #15 --- nodes/dora_extract_wd.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/nodes/dora_extract_wd.py b/nodes/dora_extract_wd.py index 0597bf9..636da34 100644 --- a/nodes/dora_extract_wd.py +++ b/nodes/dora_extract_wd.py @@ -551,6 +551,14 @@ def _process_layer(key): dora_scale = None del tensor_b else: + # 1-D weights (e.g. x_pad_token, norm .weight) have no + # weight-decomposition direction and are skipped below + # anyway; bail out before the norm, which would index + # dim=1 and raise on a 1-D tensor. + if tensor_a.ndim < 2: + del tensor_a, tensor_b + return "skipped", None + # Weight Decomposition calculation is_conv_dim = tensor_a.ndim == 4