rte_sparse: two-step re-thaw with refreeze; ChainGraphGate record_only_depths (interpretune#936)
Browse filesFiles changed (5)
123456781 unmodified line101112131415# The sparsity chain's two phases for gemma-3-1b-it (26 decoder layers), named as an interpretune module names them# (`model.` is the module's HF model). Phase 0 (sparsity, #698) thaws the final norm and blocks 14-25 with the penalty# on: 0.3 times the normalized attribution ratio plus 3 times the error share. Phase 1 (recovery, #700) keeps them# thawed with a fresh optimizer and the boundary's simplified graph enforced. #700 re-thawed in two steps (blocks 22-25,# then 14-21) from an export; one run cannot narrow a thawed set, so this keeps 14-25 thawed (decided on #899).0:params:- model.model.norm.weight1 unmodified linephase_config: {reg_weight: 0.3, err_weight: 3.0, enforce: false}1:params: []new_optimizer:optimizer_init:class_path: torch.optim.AdamW1234567891 unmodified line111213141516171819202122232425262728# The sparsity chain's three stages for gemma-3-1b-it (26 decoder layers), named as an interpretune module names them# (`model.` is the module's HF model). Phase 0 (sparsity, #698) thaws the final norm and blocks 14-25 with the penalty# on: 0.3 times the normalized attribution ratio plus 3 times the error share. Recovery (#700) then re-thaws in two# steps, as the chain did: phase 1 refreezes blocks 14-21, so the norm and blocks 22-25 train with the boundary's# simplified graph enforced, and phase 2 thaws blocks 14-21 again under the same enforcement (#936). Each recovery phase# starts from the previous phase's best with a fresh optimizer.0:params:- model.model.norm.weight1 unmodified linephase_config: {reg_weight: 0.3, err_weight: 3.0, enforce: false}1:params: []refreeze:- model.model.layers.(1[4-9]|2[01])\..*restore: bestnew_optimizer:optimizer_init:class_path: torch.optim.AdamWinit_args: {weight_decay: 0.0, lr: 1.0e-05}phase_config: {reg_weight: 0.3, err_weight: 3.0, enforce: true}2:params:- model.model.layers.(1[4-9]|2[01])\..*restore: bestnew_optimizer:optimizer_init:class_path: torch.optim.AdamW
12345672 unmodified lines101112131415# The sparsity chain's two phases for GPT-2 small (CPU-sized; `rte_sparse.gemma3.yaml` is the research schedule).# Phase 0 (sparsity) thaws the final norm and blocks 9-11 with the penalty on; phase 1 (recovery) keeps them thawed# with a fresh optimizer and the boundary's simplified graph enforced. `phase_config` is the payload the component's# `ChainApplyPayload` start hook applies.0:params:- model.transformer.ln_f.*2 unmodified linesphase_config: {reg_weight: 0.3, err_weight: 3.0, enforce: false}1:params: []new_optimizer:optimizer_init:class_path: torch.optim.AdamW123456782 unmodified lines11121314151617181920212223242526272829# The sparsity chain's three stages for GPT-2 small (CPU-sized; `rte_sparse.gemma3.yaml` is the research schedule).# Phase 0 (sparsity) thaws the final norm and blocks 9-11 with the penalty on. Recovery re-thaws in two steps: phase 1# refreezes blocks 9 and 10, so the norm and block 11 train with the boundary's simplified graph enforced, and phase 2# thaws blocks 9 and 10 again under the same enforcement. Each recovery phase starts from the previous phase's best with# a fresh optimizer. `phase_config` is the payload the component's `ChainApplyPayload` start hook applies.0:params:- model.transformer.ln_f.*2 unmodified linesphase_config: {reg_weight: 0.3, err_weight: 3.0, enforce: false}1:params: []refreeze:- model.transformer.h.(9|10)\..*restore: bestmax_transition_epoch: 2new_optimizer:optimizer_init:class_path: torch.optim.AdamWinit_args: {weight_decay: 0.0, lr: 3.0e-05}phase_config: {reg_weight: 0.3, err_weight: 3.0, enforce: true}2:params:- model.transformer.h.(9|10)\..*restore: bestnew_optimizer:optimizer_init:class_path: torch.optim.AdamW
1088 unmodified lines108910901091109210931094109510961097109810991100110127 unmodified lines112911301131113211331134113511361088 unmodified lines"""Gate (#709): accept a phase whose graphs keep the median error-node share within ``max_err_points`` points ofthe untuned reference and the median replacement score within ``max_replacement_drop`` of it, over the rows bothmeasured. ``reference`` is a JSON file of per-row untuned measures (``{"rows": {row: {"errors_share": ..,"replacement": ..}}}``), graphed under the same zero-position convention, and ``sha256`` pins it."""def __init__(self, reference: str, sha256: str, max_err_points: float = 5.0, max_replacement_drop: float = 0.10) -> None:self.reference, self.sha256 = reference, sha256self.max_err_points, self.max_replacement_drop = max_err_points, max_replacement_dropdef _load_reference(self) -> dict:import hashlib27 unmodified lines}d_err = 100 * (med["errors_share"][0] - med["errors_share"][1])d_rep = med["replacement"][0] - med["replacement"][1]accept = d_err <= self.max_err_points and d_rep >= -self.max_replacement_droprecord = {"items": len(rows), "d_err_points": d_err, "d_replacement": d_rep, "best_depth": event.best_depth}reason = None if accept else f"error share {d_err:+.1f} points, replacement {d_rep:+.3f} vs untuned"print(f"ChainGraphGate phase {event.depth}: {'accept' if accept else 'VETO'} {record}", flush=True)return GateResult(accept=accept, reason=reason, record=record)1088 unmodified lines1089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111127 unmodified lines11391140114111421143114411451146114711481149115011511088 unmodified lines"""Gate (#709): accept a phase whose graphs keep the median error-node share within ``max_err_points`` points ofthe untuned reference and the median replacement score within ``max_replacement_drop`` of it, over the rows bothmeasured. ``reference`` is a JSON file of per-row untuned measures (``{"rows": {row: {"errors_share": ..,"replacement": ..}}}``), graphed under the same zero-position convention, and ``sha256`` pins it.A phase in ``record_only_depths`` that does not end the run is measured and recorded, with the verdict it wouldhave had, but accepted: an intermediate stage, such as the first step of a two-step re-thaw (#936), is judged onlythrough the phase that follows it."""def __init__(self,reference: str,sha256: str,max_err_points: float = 5.0,max_replacement_drop: float = 0.10,record_only_depths: tuple[int, ...] = (),) -> None:self.reference, self.sha256 = reference, sha256self.max_err_points, self.max_replacement_drop = max_err_points, max_replacement_dropself.record_only_depths = tuple(record_only_depths)def _load_reference(self) -> dict:import hashlib27 unmodified lines}d_err = 100 * (med["errors_share"][0] - med["errors_share"][1])d_rep = med["replacement"][0] - med["replacement"][1]within = d_err <= self.max_err_points and d_rep >= -self.max_replacement_dropjudged = event.final or event.depth not in self.record_only_depthsrecord = {"items": len(rows), "d_err_points": d_err, "d_replacement": d_rep, "best_depth": event.best_depth}record.update(within_bounds=within, judged=judged)reason = None if within else f"error share {d_err:+.1f} points, replacement {d_rep:+.3f} vs untuned"verdict = (("accept" if within else "VETO") if judged else f"recorded ({'within' if within else 'outside'} bounds)")print(f"ChainGraphGate phase {event.depth}: {verdict} {record}", flush=True)return GateResult(accept=within or not judged, reason=reason, record=record)
12345678910111213141516171819203 unmodified lines2425262728293013 unmodified lines444546474849# The sparsity chain (interpretune#698 to #700) as one phased run of gemma-3-1b-it on interpretune's core loop (#899),# about 20 to 25 minutes per seed on one 24 GB GPU, 18.2 GiB at peak (research-class: a reserved window, not CI):## interpretune --run_command train --config hub://speediedan/rte/runs/rte_sparse.gemma3.core.yaml## The chain's training setup: bf16-mixed with two-step accumulation, batch 8, AdamW at 1e-5. Phase 0 calibrates the# penalty's normalizer on 8 dev batches and tunes with the penalty on. At each boundary the best checkpoint is restored,# `ChainBuildGraphs` graphs the restored weights (the 100 #667 pilot items fit the enforcement; the 40 gate items are# measured), `ChainGraphGate` judges the phase against the pinned untuned reference (#709: error share up at most 5# points, replacement down at most 0.10), and phase 1 tunes with the simplified graph enforced and a fresh optimizer.# The final gate judges the global best, whichever phase holds it, and a veto ends the run on phase 0's best (#899 has# the outcome per seed). The reference is graphed at circuit-tracer bd6bc784, and graphs from another circuit-tracer are# not comparable with it. Every phase is judged on `val_task`, the phase-invariant task loss.session_ref: speediedan/rte:rte_sparse.gemma3.coreseed_everything: 0run_cfg:max_epochs: 10precision: bf16-mixedaccumulate_grad_batches: 2# the attribution penalty needs the gap's gradient at validation too3 unmodified linesinit_args:schedule: hub://speediedan/rte/ft_schedules/rte_sparse.gemma3.yamltuning_scheduler_kwargs:max_depth: 1restore_best: truetransition:class_path: finetuning_scheduler.core.transitions.PlateauTransition13 unmodified linesinit_args:reference: hub://speediedan/rte/chain/untuned_reference.jsonsha256: 2f0ad55275106d84c69bda4d84d17aa48cb51bb0141628c457f07e7fdb054eb6rank_zero_only: truephase_hooks:start:1234567891011121314151617181920212223243 unmodified lines2829303132333413 unmodified lines48495051525354# The sparsity chain (interpretune#698 to #700) as one phased run of gemma-3-1b-it on interpretune's core loop (#899,# #936), on one 24 GB GPU (research-class: a reserved window, not CI):## interpretune --run_command train --config hub://speediedan/rte/runs/rte_sparse.gemma3.core.yaml## The chain's training setup: bf16-mixed with two-step accumulation, batch 8, AdamW at 1e-5. Phase 0 calibrates the# penalty's normalizer on 8 dev batches and tunes with the penalty on. Recovery re-thaws in two steps, as #700 did# (`ft_schedules/rte_sparse.gemma3.yaml`): phase 1 refreezes blocks 14-21 and tunes the norm and blocks 22-25 with the# simplified graph enforced, and phase 2 thaws blocks 14-21 again. At each boundary the best checkpoint is restored and# `ChainBuildGraphs` graphs the restored weights (the 40 gate items are measured; at the sparsity boundary the 100 #667# pilot items also fit the enforcement both recovery phases hold). `ChainGraphGate` compares the graphs with the pinned# untuned reference (#709: error share up at most 5 points, replacement down at most 0.10). It judges phase 0 and the# final phase; phase 1, the first step of the re-thaw, is graphed and recorded with the verdict it would have had, but# not judged, so the second step always runs. The final gate judges the global best, whichever phase holds it, and a# veto ends the run on the previous phase's best (#899 and #936 have the outcome per seed). The reference is graphed at# circuit-tracer bd6bc784, and graphs from another circuit-tracer are not comparable with it. Every phase is judged on# `val_task`, the phase-invariant task loss.session_ref: speediedan/rte:rte_sparse.gemma3.coreseed_everything: 0run_cfg:max_epochs: 15precision: bf16-mixedaccumulate_grad_batches: 2# the attribution penalty needs the gap's gradient at validation too3 unmodified linesinit_args:schedule: hub://speediedan/rte/ft_schedules/rte_sparse.gemma3.yamltuning_scheduler_kwargs:max_depth: 2restore_best: truetransition:class_path: finetuning_scheduler.core.transitions.PlateauTransition13 unmodified linesinit_args:reference: hub://speediedan/rte/chain/untuned_reference.jsonsha256: 2f0ad55275106d84c69bda4d84d17aa48cb51bb0141628c457f07e7fdb054eb6record_only_depths: [1]rank_zero_only: truephase_hooks:start:
2 unmodified lines3456789101112131415161 unmodified line181920212223242 unmodified lines# interpretune --run_command train --config hub://speediedan/rte/runs/rte_sparse.gpt2.core.yaml## The session is the component's `rte_sparse.gpt2.core` configuration (GPT-2 with random transcoders) and the schedule# `ft_schedules/rte_sparse.gpt2.yaml`. Phase 0 calibrates the penalty's normalizer and tunes with the penalty on; at the# boundary the best checkpoint is restored, the graph hook builds the enforcement from it, the gate judges the phase,# and phase 1 tunes with the simplified graph enforced and a fresh optimizer. Every phase is judged on `val_task`, the# phase-invariant task loss, since the whole objective changes meaning once enforcement turns on.session_ref: speediedan/rte:rte_sparse.gpt2.coreseed_everything: 0run_cfg:max_epochs: 4# the attribution penalty needs the gap's gradient at validation toovalidate_with_grad: truecallbacks:1 unmodified lineinit_args:schedule: hub://speediedan/rte/ft_schedules/rte_sparse.gpt2.yamltuning_scheduler_kwargs:max_depth: 1restore_best: truetransition:class_path: finetuning_scheduler.core.transitions.PlateauTransition2 unmodified lines345678910111213141516171 unmodified line192021222324252 unmodified lines# interpretune --run_command train --config hub://speediedan/rte/runs/rte_sparse.gpt2.core.yaml## The session is the component's `rte_sparse.gpt2.core` configuration (GPT-2 with random transcoders) and the schedule# `ft_schedules/rte_sparse.gpt2.yaml`. Phase 0 calibrates the penalty's normalizer and tunes with the penalty on; at its# boundary the best checkpoint is restored and the graph hook builds the enforcement from it. Recovery re-thaws in two# steps (#936), each from the previous phase's best with a fresh optimizer and the simplified graph enforced: phase 1# refreezes blocks 9 and 10, and phase 2 thaws them again. Every phase is judged on `val_task`, the phase-invariant task# loss, since the whole objective changes meaning once enforcement turns on.session_ref: speediedan/rte:rte_sparse.gpt2.coreseed_everything: 0run_cfg:max_epochs: 5# the attribution penalty needs the gap's gradient at validation toovalidate_with_grad: truecallbacks:1 unmodified lineinit_args:schedule: hub://speediedan/rte/ft_schedules/rte_sparse.gpt2.yamltuning_scheduler_kwargs:max_depth: 2restore_best: truetransition:class_path: finetuning_scheduler.core.transitions.PlateauTransition
ft_schedules/rte_sparse.gemma3.yaml+17-4
ft_schedules/rte_sparse.gpt2.yaml+18-4
rte_boolq.py+21-6
runs/rte_sparse.gemma3.core.yaml+16-11
runs/rte_sparse.gpt2.core.yaml+7-6