transformers
8ec9f715 - Exporters: upcast a 16-bit model's small tensors by swapping in f32 copies

Commit
21 days ago
Exporters: upcast a 16-bit model's small tensors by swapping in f32 copies `patch_16bit_model` upcast the norms and other small 16-bit tensors through `.data`, which keeps a view's 16-bit base: `torch.export` replays the view when it fakifies the parameters and fails ("size(-1) must be divisible by 2 to view BFloat16 as Float"). A loaded checkpoint holds such views (EmbeddingGemma2's `layer_scalar`, 504 tensors), so the OpenVINO export of the bf16 model failed while a randomly initialized one passed. Each slot now holds an f32 copy for the trace (one per tensor, so shared tensors stay shared) and gets its original tensor back afterwards.
Committer
Parents
Loading