Skip to content

[BUG] Dense load with whole-model placement="cpu>accel:0" keeps every weight on the accelerator; "disk>accel:0" raises at load #6581

Done

Description

@Qubitium

Summary

A whole-model offload placement on a dense (unquantized) load does not offload:

  • GPTQModel.load(model_id, placement="cpu>accel:0") (documented in docs/weight-loader.md: "Weights stay on CPU; the module executes on accel:N") puts every weight on the accelerator. TinyLlama-1.1B: 2100 MiB allocated after load, all parameters on cuda:0, identical to placement="accel:0".
  • GPTQModel.load(model_id, placement="disk>accel:0", offload_dir=...) fails during load:
    ValueError: weight is on the meta device, a value is required to place it on cuda:0. (weight_loader/hooks.py init_hook via WeightLoader.dispatch).

Root cause

WeightLoader.dispatch (gptqmodel/weight_loader/loader.py) computes _subtree_targets; with one root rule the whole model is a single uniform subtree, so the result is {"": target} and no child has an entry. dispatch adds the root AlignDevicesHook and then visits the children, which find no target, recurse to the leaves and give every tensor-owning leaf a resident AlignDevicesHook(execution_device). For cpu> that moves the weights onto the accelerator; for disk> it tries to place meta tensors and raises. Placements that name sub-trees (e.g. {"": "accel:0", "model.layers.[8:]": "cpu>accel:0"}) are not affected.

Repro (ROCm 7.16 R9700; the code path is device-independent)

m = GPTQModel.load("TinyLlama/TinyLlama-1.1B-Chat-v1.0", placement="cpu>accel:0", dtype=torch.float16)
print({p.device for p in m.model.parameters()}, torch.cuda.memory_allocated())  # {cuda:0}, ~2.1 GiB
GPTQModel.load("TinyLlama/TinyLlama-1.1B-Chat-v1.0", placement="disk>accel:0", offload_dir=d, dtype=torch.float16)  # ValueError

Expected

Weights stay on CPU / in offload_dir (meta in the module) and are onloaded per forward, as for sub-tree cpu>/disk> rules and as the quantized path (simple_dispatch_model) already does.

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