[Bug Report] NormMatchedPlacebo silently loses norm matching and produces float16 NaNs
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 75/100
Hướng nghiên cứu
Start in transformer_lens/tools/analysis/interchange.py at NormMatchedPlacebo.__call__. Reproduce with the provided torch script to see float16 NaNs and zero-projection silence. Edit to preserve zero-reference rows, normalize at safe precision, and raise on zero placebo projection with nonzero reference. Run the focused regression tests (8 failing) until they pass and new identity/error cases hold.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
NormMatchedPlacebo promises to match the reference intervention's displacement in a different subspace, but a zero projection silently produces no displacement in float32 even when the reference moves. In float16, the 1e-8 denominator clamp rounds to zero and produces NaNs, including when source and base are identical. This can occur with the documented random-neuron control excluding the reference neurons, not just a degenerate dense random basis.
Code example
import torch
from transformer_lens.tools.analysis.interchange import (
NormMatchedPlacebo, SubspaceInterchange, neuron_basis, random_neuron_basis,
)
for dtype in (torch.float32, torch.float16):
base = torch.zeros(2, 4, dtype=dtype)
source = base.clone()
source[0, 0] = 2
reference = SubspaceInterchange(neuron_basis(4, [0]))
control_basis = random_neuron_basis(4, 1, seed=0, exclude=[0])
result = NormMatchedPlacebo(reference, control_basis)(base, source)
print(dtype, (reference(base, source) - base).norm(dim=-1), result)
The reference displacement norms are [2, 0]. Float32 returns two unchanged rows, so the first row is not norm-matched. Float16 returns NaNs in both rows; the second row should simply be an identity control. The current implementation also forms a potentially overflowing low-precision scale factor before multiplying by the direction.
Expected behavior: safely preserve rows with zero reference displacement, normalize nonzero projected directions at safe precision, and explicitly reject a zero placebo projection when the reference displacement is nonzero rather than silently returning an unmatched control. This keeps the existing projected-direction definition without inventing a fallback direction.
System Info
Source checkout at dev commit a7b3213a, Windows, Python 3.12, existing uv project environment, CPU. No model loading or downloads are required. Focused regression tests on this base: 8 failed, 14 passed, 38 deselected, covering float16, bfloat16, float32 and float64. Four failures assert the proposed explicit-error contract; the other four expose current float16 NaNs.
Additional context
The affected implementation is transformer_lens/tools/analysis/interchange.py, NormMatchedPlacebo.__call__. Existing random dense float32 tests cover ordinary nonzero projections, but not the zero-projection or float16 identity cases. This concerns the numerical validity of the control; no pretrained-model accuracy claim is involved.
Checklist
- I have checked that there is no similar issue in the repo.
- Ngôn ngữ chính
- Python
- Star
- 3.9k
- Fork
- 708
- Merge trung bình
- 1 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 84
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của TransformerLensOrg/TransformerLens
-
[Bug Report] `TransformerBridge.boot_*` methods are invisible to static type checkersCó thể đã có người làm @koriyoshi2041 đã nhận 1 ngày trước. Đang mởbug complexity-simple TransformerBridge
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
TransformerLensOrg/TransformerLens#1980 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug Report] detect_head fails with a list of sequences and a custom tensor detection patternCó thể đã có người làm @koriyoshi2041 đã nhận hôm nay. Đang mởbug complexity-moderate TransformerBridge
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
TransformerLensOrg/TransformerLens#1979 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Proposal] Demo or helper for statistical audits of activation-patching results on TransformerBridgeĐang mởcomplexity-moderate enhancement TransformerBridge
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 28/100
TransformerLensOrg/TransformerLens#1988 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug Report] Residual-decomposition APIs raise KeyError on SSM / hybrid bridges (Qwen3.5, Mamba-2, NemotronH, GraniteMoeHybrid)Có thể đã có người làm @SBrouck đã nhận hôm nay. Đang mởcomplexity-moderate enhancement TransformerBridge
TransformerLensOrg/TransformerLens#1986 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Proposal] Demo: auditing a published LLM-written weight edit (Weight-Space Programming, Qwen3.5-0.8B loop fix) with TransformerBridgeCó thể đã có người làm @emerardd đã nhận 1 ngày trước. Đang mởcomplexity-moderate demo TransformerBridge
TransformerLensOrg/TransformerLens#1978 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của TransformerLensOrg/TransformerLens
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
cline/mcp-marketplace#3576 ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
griptape-ai/griptape-nodes-library-elevenlabs#30 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
docs: Release playbookĐang mởdocumentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
awslabs/social-messaging-agent-runtime-toolkit#140 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
subtask
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
fga-eps-mds/2026.2-MeasureSoftGram-DOC#187 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
NSPG13/agent-bounties#1747 ·
Maintainer thường phản hồi trong vòng 1 ngày