Skip to content

[BUG] Quantized load with placement="cpu>accel:0": whole model becomes resident on the accelerator after the first forward (no VRAM saving) #6592

Done

Description

@Qubitium

Summary

docs/weight-loader.md documents "cpu>accel:N" as "Weights stay on CPU; the module executes on accel:N", and lists placement="cpu>accel:0" as a whole-model target. On a quantized load the whole model is moved to the accelerator on the first forward and stays there, so the placement saves no VRAM.

Llama-3.2-1B GPTQ 4-bit (ROCm 7.16, R9700; code path is device-independent), GPTQModel.load(path, placement=..., dtype=float16), then an 8-token greedy generate:

placement allocated after load allocated after generate peak
accel:0 985.6 MiB 985.6 MiB 1066.8 MiB
cpu>accel:0 0.0 MiB 985.6 MiB 1066.8 MiB

(The dense path, after #6582, keeps the weights off the accelerator: TinyLlama cpu>accel:0 peak 206.5 MiB vs 2180.6 MiB resident.)

Root cause

simple_dispatch_model (gptqmodel/utils/model.py) drives every cpu> entry through cpu_offload_with_hook / CpuOffload, which moves the whole module to the execution device on first use and only moves it back when the next module in the chain runs (prev_module_hook). A whole-model cpu> placement is a one-entry chain, so offload() is never called and the model stays resident after the first forward. Multi-entry chains (e.g. per-layer cpu> rules) cycle and stay bounded.

Expected

Per the docs, weights stay on CPU between forwards (or the docs state that a single cpu> entry becomes resident after its first forward and point to per-layer rules / disk> for VRAM savings).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions