Clear velocity-bias/rescue memory on Studio session reset
VELOCITY_BIAS_MEMORY is an in-process dict, so reset_session (which only removed on-disk enhancement files via clear_refinement_data) left stale good-trajectory memory behind — rescue and velocity bias would keep steering toward the previous session's content. Add clear_velocity_bias_memory(key) in samplers.py (drops global averages + prompt clusters for that key) and call it from clear_refinement_data. Key matches: refine_v2 and the velocity key default both resolve to the same effective refinement key. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
237daf1b54
commit
e1801fdb3e
@@ -217,6 +217,17 @@ def clear_refinement_data(refinement_key):
|
||||
os.remove(path)
|
||||
except Exception as e:
|
||||
print(f"[FunPackEnhancements] Cleanup failed for {path}: {e}")
|
||||
# Velocity-bias / rescue trajectory memory is in-process (not a file), so clear
|
||||
# it here too — otherwise a session reset leaves stale good-trajectory memory that
|
||||
# rescue and velocity bias would keep steering toward.
|
||||
try:
|
||||
try:
|
||||
from .samplers import clear_velocity_bias_memory
|
||||
except ImportError:
|
||||
from samplers import clear_velocity_bias_memory
|
||||
clear_velocity_bias_memory(refinement_key)
|
||||
except Exception as e:
|
||||
print(f"[FunPackEnhancements] Velocity memory cleanup failed: {e}")
|
||||
|
||||
|
||||
def bless_attention_maps(refinement_key):
|
||||
|
||||
+15
@@ -148,6 +148,21 @@ def _apply_motion_pulse(x, sigma, sigma_next, pulse_noise, noise_sampler):
|
||||
return x + noise_sampler(sigma, sigma_next) * (pulse_noise * sigma_delta)
|
||||
|
||||
|
||||
def clear_velocity_bias_memory(refinement_key):
|
||||
"""Drop all stored velocity-bias / rescue trajectory memory (global averages and
|
||||
prompt clusters) for a key. Called on Studio session reset so rescue and velocity
|
||||
bias start from a clean slate instead of steering toward last session's content."""
|
||||
norm = str(refinement_key or "default").strip() or "default"
|
||||
removed = [k for k in list(VELOCITY_BIAS_MEMORY)
|
||||
if isinstance(k, tuple) and k and k[0] == norm]
|
||||
for k in removed:
|
||||
VELOCITY_BIAS_MEMORY.pop(k, None)
|
||||
if removed:
|
||||
print(f"[FunPack rescue] cleared {len(removed)} velocity-bias memory bucket(s) "
|
||||
f"for key '{norm}' (session reset)")
|
||||
return len(removed)
|
||||
|
||||
|
||||
def _velocity_bias_enabled(mode, action):
|
||||
mode = (mode or "off").lower()
|
||||
if mode == "capture_and_apply":
|
||||
|
||||
Reference in New Issue
Block a user