mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 01:04:32 +02:00
fix(sdnq): reset dynamo caches at model unload
Dynamo tracks a lifetime recompile counter per compiled function that freed models leave climbing while their graphs and guards die, and the compiled dequant runs fullgraph, so crossing the accumulated limit is a hard FailOnRecompileLimitHit instead of an eager fallback; enough model or quant switches in one process got there. unload_model_weights now calls reset_compile_caches when the compiled dequant is active, dropping the dead graphs and the counters in the same sweep as the unload gc. Raised limits only move the wall; the reset removes it. - scoped to the model unload branch: the reset is global and must only run when the graphs' owner is being discarded - regression test trips the wall under a lowered limit and recovers through the same helper the unload path calls
This commit is contained in:
@@ -1573,6 +1573,8 @@ def unload_model_weights(op='model'):
|
||||
disable_offload(model_data.sd_model)
|
||||
move_model(model_data.sd_model, 'meta')
|
||||
model_data.sd_model = None
|
||||
from modules.sdnq.common import reset_compile_caches
|
||||
reset_compile_caches() # dead compiled-dequant graphs and their lifetime recompile counters otherwise accumulate across switches
|
||||
devices.torch_gc(force=True, reason='unload')
|
||||
log.debug(f'Unload {op}: {memory_stats()} fn={fn}')
|
||||
elif (op == 'refiner') and model_data.sd_refiner:
|
||||
|
||||
Reference in New Issue
Block a user