mirror of
https://github.com/wassname/evil_MoE.git
synced 2026-08-03 12:50:20 +08:00
fix: drop nested save_file import so the closure can find it on cache-hit
The redundant `from safetensors.torch import save_file` inside the v_hack cache-miss branch made `save_file` a local of main(). Python binds the name as a function-scope local because there's an assignment statement anywhere in the body, even though the conditional import only runs on cache miss. The top-level import at line 75 was shadowed for the whole function. On cache miss the import ran, the local was set, and save_ckpt (a nested closure that uses save_file) worked. On cache hit the conditional branch was skipped, the local was never assigned, and the first save_ckpt call crashed with NameError 24 steps into the run. #54 hit this. #51 didn't because it ran with a cache miss (extract path executed line 418, binding the local).
This commit is contained in:
@@ -415,7 +415,6 @@ def main(cfg: Config) -> int:
|
||||
if not v_hack_path.exists():
|
||||
from .extract_vhack_grad import extract_v_hack
|
||||
from .pairs import PAIRS as VHACK_PAIRS
|
||||
from safetensors.torch import save_file
|
||||
logger.info(f"v_hack cache miss at {v_hack_path}; extracting (~5min)...")
|
||||
model.eval() # match standalone extract: deterministic backward, no dropout
|
||||
v_hack_cpu_dict, raw_grads, _diag = extract_v_hack(
|
||||
|
||||
Reference in New Issue
Block a user