You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[PERF] Regression from #4915 (fix of #4863): FP8 checkpoints loaded on cuda:0 keep every packed weight on CPU (int ordinal 0 is falsy in _restore_checkpoint_buffers); decode 4x slower, VRAM 0.25 vs 0.59 GiB #4964
Found on main @ 3867c82, RTX 4090 (CUDA 13.2, torch 2.15) and AMD R9700 (ROCm 10.1).
What is wrong
Since #4915 (fix of #4863), every FP8 checkpoint loaded onto cuda:0 keeps its packed FP8 weight on the CPU. Only the scales and biases reach the GPU. TorchFP8Linear then copies the weight host-to-device on every forward (nn_modules/qlinear/fp8.py:599), so decode is about 4x slower and the reported VRAM is a fraction of the checkpoint size. The output is still correct, so nothing fails.
For cuda:0, mapped_device() now returns 0, which is falsy. The expression falls through to slot.device, which is cpu. cuda:1 (ordinal 1) would still work, so only the default single-GPU case is affected, which is the common one.
Bisect
Archive-based, loading the same saved Qwen2.5-0.5B-Instruct FP8 checkpoint with each commit:
3a5a5bea1 (parent): {'cuda:0': 460 tensors}, weight on cuda:0;
Alternatively, normalize ints with torch.device("cuda", n) inside mapped_device. Audit any other device_map[...] or ... patterns that now see int ordinals.
Test that should have caught it
tests/test_load_device_context_4863.py checks only CUDA contexts, and only for cuda:1.
Add an FP8 save/reload test on cuda:0 that asserts every quantized module's weight.device == scale.device == cuda:0, and that memory_allocated() is at least the packed checkpoint size.
Severity
High for FP8 users: silent 3.6-4x inference slowdown on the default single-GPU path, the VRAM report is wrong, and the checkpoint stays pinned in host RAM.
Fixed by #4983 (squash-merged, 56f87e9f5). _restore_checkpoint_buffers no longer tests the map value for truthiness: the resolver is a module-level _device_map_target() returning a torch.device (or None for absent/disk/meta), with an int ordinal normalized to torch.device("cuda", n). Ordinal 0 now places the packed FP8 weight on the GPU exactly like ordinal 1.
Regression test: on unmodified main the behavioural node fails at assert model.weight.device == torch.device("cuda:0") with the actual device(type='cpu') — the packed weight stayed on the CPU slot; with the fix it lands on cuda:0. The resolver table also pins int 0/1, the string and torch.device forms, disk/meta/absent, and longest-prefix selection.
Activity
Qubitium commentedon Nov 17, 2026
Agent claim:
agent-root-4964is working on this issue now.Qubitium commentedon Nov 17, 2026
Fixed by #4983 (squash-merged,
56f87e9f5)._restore_checkpoint_buffersno longer tests the map value for truthiness: the resolver is a module-level_device_map_target()returning atorch.device(orNonefor absent/disk/meta), with an int ordinal normalized totorch.device("cuda", n). Ordinal0now places the packed FP8 weight on the GPU exactly like ordinal1.Regression test: on unmodified main the behavioural node fails at
assert model.weight.device == torch.device("cuda:0")with the actualdevice(type='cpu')— the packed weight stayed on the CPU slot; with the fix it lands oncuda:0. The resolver table also pins int 0/1, the string andtorch.deviceforms,disk/meta/absent, and longest-prefix selection.Merge origin/main into transformers5-local-models
fix(load): never test an int-ordinal device map for truthiness (Model…