From 79ea00257d73219b5c05e9838c8ae1cea891eefc Mon Sep 17 00:00:00 2001 From: CalamitousFelicitousness Date: Sat, 15 Aug 2026 21:30:52 +0100 Subject: [PATCH] fix(framepack): route placement through the offload dispatcher The loader applied balanced offload directly, which places nothing when the offload mode is not balanced, leaving every component on cpu where the load parked it. The dispatcher places them under whichever mode is configured, and the vae seams pair the balanced call with an on-demand sweep so the vae returns to cpu once its outputs are materialized. --- modules/framepack/framepack_load.py | 2 +- modules/framepack/framepack_worker.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/framepack/framepack_load.py b/modules/framepack/framepack_load.py index 74e853a52..5b3f09769 100644 --- a/modules/framepack/framepack_load.py +++ b/modules/framepack/framepack_load.py @@ -196,7 +196,7 @@ def load_model(variant: str | None = None, pipeline: str | None = None, text_enc diffusers.loaders.peft._SET_ADAPTER_SCALE_FN_MAPPING['HunyuanVideoTransformer3DModelPacked'] = lambda model_cls, weights: weights # pylint: disable=protected-access log.info(f'FramePack load: model={shared.sd_model.__class__.__name__} variant="{variant}" type={shared.sd_model_type} time={t1-t0:.2f}') - sd_models.apply_balanced_offload(shared.sd_model) + sd_models.set_diffuser_offload(shared.sd_model) devices.torch_gc(force=True, reason='load') except Exception as e: diff --git a/modules/framepack/framepack_worker.py b/modules/framepack/framepack_worker.py index 5a0388336..29fb1006b 100644 --- a/modules/framepack/framepack_worker.py +++ b/modules/framepack/framepack_worker.py @@ -130,6 +130,7 @@ def worker( else: end_latent = None sd_models.apply_balanced_offload(shared.sd_model) + sd_models.offload_ondemand(shared.sd_model, reason='vae encode') # group offload returns the vae through its on-demand placement rather than the balanced seam timer.process.add('encode', time.time()-t0) shared.state.end(jobid) return start_latent, end_latent @@ -317,6 +318,7 @@ def worker( current_pixels = framepack_vae.vae_decode(real_history_latents[:, :, :section_latent_frames], vae_type=vae_type).cpu() history_pixels = utils.soft_append_bcthw(current_pixels, history_pixels, overlapped_frames) sd_models.apply_balanced_offload(shared.sd_model) + sd_models.offload_ondemand(shared.sd_model, reason='vae decode') timer.process.add('vae', time.time()-t_vae) if is_last_section: @@ -376,6 +378,7 @@ def worker( errors.display(e, 'FramePack') sd_models.apply_balanced_offload(shared.sd_model) + sd_models.offload_ondemand(shared.sd_model, reason='finish') stream.output_queue.push(('end', None)) t1 = time.time() log.info(f'Processed: frames={total_generated_frames} fps={total_generated_frames/(t1-t0):.2f} its={(shared.state.sampling_step)/(t1-t0):.3f} time={t1-t0:.2f} timers={timer.process.dct()} memory={memstats.memory_stats()}')