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.
This commit is contained in:
CalamitousFelicitousness
2026-08-15 21:30:52 +01:00
parent 4a2d9c9720
commit 79ea00257d
2 changed files with 4 additions and 1 deletions
+1 -1
View File
@@ -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:
+3
View File
@@ -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()}')