[Quantization] - Layerwise reloading of Attention/KV quantized models (#38995)

Signed-off-by: Josephasafg <ajgard7@gmail.com>
This commit is contained in:
Asaf Gardin
2026-04-15 18:03:32 -07:00
committed by GitHub
parent 03f8d3a548
commit 19fa90ed0d
4 changed files with 98 additions and 27 deletions
@@ -1364,8 +1364,8 @@ def default_weight_loader(param: torch.Tensor, loaded_weight: torch.Tensor) -> N
if param.numel() == 1 and loaded_weight.numel() == 1:
# Sometimes scalar values aren't considered tensors with shapes
# so if both param and loaded_weight are a scalar,
# "broadcast" instead of copy
param.data.fill_(loaded_weight.item())
# reshape to match before copying
param.data.copy_(loaded_weight.view(param.shape))
else:
assert param.size() == loaded_weight.size(), (
f"Attempted to load weight ({loaded_weight.size()}) "