remove dead code: _road_matrix, callable(m) clause, silent git fallback

- delete _road_matrix in variants/road.py (zero callers)
- drop redundant callable(m) clause in is_linear_like (every nn.Module is callable)
- remove try/except in current_git_commit so missing git crashes loudly
  instead of writing "unknown" into the results TSV

Co-Authored-By: Claudypoo <noreply@anthropic.com>
This commit is contained in:
wassname
2026-05-19 19:11:32 +08:00
parent 19888fbb82
commit 56937e1b18
3 changed files with 1 additions and 21 deletions
+1 -4
View File
@@ -457,10 +457,7 @@ def print_final_report(row: dict[str, Any], result_path: Path, mode: str) -> Non
def current_git_commit() -> str: def current_git_commit() -> str:
try: return subprocess.check_output(["git", "rev-parse", "HEAD"], text=True).strip()
return subprocess.check_output(["git", "rev-parse", "HEAD"], text=True).strip()
except (subprocess.CalledProcessError, FileNotFoundError):
return "unknown"
def append_results_row( def append_results_row(
-1
View File
@@ -13,7 +13,6 @@ def is_linear_like(m: nn.Module) -> bool:
hasattr(m, "in_features") hasattr(m, "in_features")
and hasattr(m, "out_features") and hasattr(m, "out_features")
and hasattr(m, "weight") and hasattr(m, "weight")
and callable(m)
) )
-16
View File
@@ -92,22 +92,6 @@ def _apply_road(
return y * first_col + rotate_half_y * second_col return y * first_col + rotate_half_y * second_col
def _road_matrix(
road_variant: str,
group_size: int,
road_theta: torch.Tensor,
road_alpha: torch.Tensor,
) -> torch.Tensor:
"""Explicit PEFT merge matrix. Used for tests and small-debug inspection."""
first_col, second_col = _prepare_cols(road_variant, group_size, road_theta, road_alpha)
size = second_col.shape[0]
output = torch.diag(first_col)
swapped_second_col = second_col.reshape(-1, 2, group_size // 2)[:, [1, 0], :].flatten()
rotated_diag_second_col = torch.diag(swapped_second_col).reshape(-1, 2, group_size // 2, size)[:, [1, 0], :, :]
rotated_diag_second_col[:, 0, :, :] *= -1
return output + rotated_diag_second_col.reshape(size, size)
@register @register
class ROAD: class ROAD:
name = "road" name = "road"