Skip to content
This repository was archived by the owner on Jun 22, 2026. It is now read-only.

fix(loader): cast model to fp16 before moving it to the device#56

Merged
danieljtrujillo merged 1 commit into
mainfrom
fix/loader-cast-fp16-before-device
Jun 10, 2026
Merged

fix(loader): cast model to fp16 before moving it to the device#56
danieljtrujillo merged 1 commit into
mainfrom
fix/loader-cast-fp16-before-device

Conversation

@danieljtrujillo

Copy link
Copy Markdown
Collaborator

load_diffusion_cond moved the full fp32 model onto the GPU and then halved it to fp16. Casting to fp16 on the CPU first means only the fp16 model is transferred to the device.

Measured A/B on the medium model, same seed through both orderings: output is bit-identical (max|new-old| = 0.0 across two runs); the torch-reported peak load allocation is 4.65 GB with the new order vs 9.35 GB with the old. fp32->fp16 rounds identically on CPU or GPU, so generation seems unchanged.

load_diffusion_cond moved the full fp32 model onto the GPU and then
halved it to fp16. Casting to fp16 on the CPU first means only the
fp16 model is transferred to the device.

Measured A/B on the medium model, same seed through both orderings:
output is bit-identical (max|new-old| = 0.0 across two runs); the
torch-reported peak load allocation is 4.65 GB with the new order vs
9.35 GB with the old. fp32->fp16 rounds identically on CPU or GPU, so
generation is unchanged.
@danieljtrujillo
danieljtrujillo merged commit fa1c12f into main Jun 10, 2026
1 check passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant