From 7bad84b4f1cfd3e658d9a3153a745ca7936276e6 Mon Sep 17 00:00:00 2001 From: red40maxxer <113548315+red40maxxer@users.noreply.github.com> Date: Mon, 17 Nov 2025 11:48:22 -0500 Subject: [PATCH] perf: clear residuals after computing direction (#15) Co-authored-by: mad-cat-lon <113548315+mad-cat-lon@users.noreply.github.com> --- src/heretic/main.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/heretic/main.py b/src/heretic/main.py index f178469..4a810e7 100644 --- a/src/heretic/main.py +++ b/src/heretic/main.py @@ -39,6 +39,7 @@ from .utils import ( get_trial_parameters, load_prompts, print, + empty_cache, ) @@ -195,6 +196,9 @@ def run(): p=2, dim=1, ) + # we don't need the residuals after computing refusal directions + del good_residuals, bad_residuals + empty_cache() trial_index = 0 start_time = time.perf_counter()