research: publish AttnRes forward training study

This commit is contained in:
wuyang
2026-07-30 18:41:18 +08:00
parent 7ea91caabb
commit f177fa676d
47 changed files with 192164 additions and 192 deletions
+11 -4
View File
@@ -170,9 +170,6 @@ class ForwardInterventionLanguageModel(parent.GradientLanguageModel):
def forward(
self, input_ids: torch.Tensor, capture: bool = False
) -> tuple[torch.Tensor, parent.ActivationTrace | None]:
if not self.selected_indices:
return super().forward(input_ids, capture)
self.forward_calls += 1
embedded = self.embed(input_ids)
trace = parent.ActivationTrace([], [], [], [], []) if capture else None
@@ -276,11 +273,13 @@ def build_intervention_audit(
str(index): (
source_counts[str(index)]
== [study_manifest["selected_source_counts"][str(index)]]
== [EXPECTED_SOURCE_COUNTS[index]]
)
for index in selected
}
visit_gate = (
all(value == model.forward_calls for value in model.depth_visits)
model.forward_calls > 0
and all(value == model.forward_calls for value in model.depth_visits)
and model.output_visits == model.forward_calls
)
selected_parameter_gate = all(
@@ -415,6 +414,14 @@ def main() -> None:
)
if expected != VARIANTS[variant]:
raise ValueError("study manifest selector drift")
for index, source_count in EXPECTED_SOURCE_COUNTS.items():
if (
study_manifest["selected_source_counts"].get(str(index))
!= source_count
):
raise ValueError(
f"study manifest source-count drift at depth index {index}"
)
output_value = argument_value("--output")
if output_value is None: