Skip to content

[BUG] FP8 checkpoints cannot be LoRA-fine-tuned with PEFT: TorchFP8Linear is SUPPORTS_TRAINING/AUTO_TRAINABLE but has no qweight, so peft's dispatch_gptq raises AttributeError #4948

Closed

Description

@Qubitium

Found on main @ 3867c82, CPU (Qwen2.5-0.5B-Instruct FP8Config() checkpoint made on this commit), peft 0.21.2.

What is wrong

TorchFP8Linear declares SUPPORTS_TRAINING = True (gptqmodel/nn_modules/qlinear/fp8.py:230). BACKEND.AUTO_TRAINABLE therefore selects it, BaseQModel.train() accepts it, and its backward is correct (input gradients flow). Its message for inference-only kernels tells users to reload with backend="auto_trainable" "before fine-tuning". But the standard fine-tuning path, PEFT LoRA, cannot wrap it.

PEFT routes every GPT-QModel BaseQuantLinear through peft/tuners/lora/gptq.py::dispatch_gptq, which runs target.qweight = target_base_layer.qweight. TorchFP8Linear keeps its codes in weight and has no qweight, so get_peft_model raises AttributeError before any training starts.

The other trainable kernels I checked attach and train correctly with PEFT on this commit: GPTQ Torch/TorchFused/AVX512/Aten, AWQ Torch/AVX512, GGUF Torch, Paro. Their LoRA gradients agree with a dense dequantized reference to within bf16 noise (max relative diff 0.19-0.33 vs. a 0.20 self-reference floor; GGUF fp32 0.0), and an adapter saved from one kernel reloads on another. FP8 is the only advertised trainable kernel that cannot be used.

Repro

import torch
from gptqmodel import GPTQModel, BACKEND
from peft import LoraConfig, get_peft_model

m = GPTQModel.load("Qwen2.5-0.5B-Instruct_fp8", backend=BACKEND.AUTO_TRAINABLE, device="cpu", dtype=torch.bfloat16)
q = m.model.model.layers[0].self_attn.q_proj
print(type(q).__name__, q.SUPPORTS_TRAINING, hasattr(q, "qweight"))
m.train()                                                       # accepted
x = torch.randn(2, 896, dtype=torch.bfloat16, requires_grad=True)
q(x).sum().backward(); print("input grad", x.grad is not None)  # backward works
get_peft_model(m.model, LoraConfig(r=8, target_modules=["q_proj", "v_proj"], task_type="CAUSAL_LM"))

Output:

TorchFP8Linear True False
input grad True
AttributeError: 'TorchFP8Linear' object has no attribute 'qweight'
  File ".../peft/tuners/lora/gptq.py", line 131, in dispatch_gptq
    target.qweight = target_base_layer.qweight

Suggested fix

Either expose the packed tensor under the name PEFT expects (for example a read-only qweight property on TorchFP8Linear that returns self.weight), or set SUPPORTS_TRAINING = False / have AUTO_TRAINABLE refuse FP8 with a clear message, and state the supported methods in docs/peft.md (it lists only gptq_torch and torch_awq).

Test that should have caught it

No test runs get_peft_model on an FP8 (or GGUF/Paro) model. Add a parametrized PEFT smoke test over every kernel with SUPPORTS_TRAINING = True: wrap with LoRA, one backward, non-None LoRA grads.

Severity

Low-medium. FP8 checkpoints cannot be LoRA-fine-tuned through the documented PEFT route, even though the kernel is flagged trainable and GPT-QModel's own error message recommends exactly this flow. The failure is loud.

🤖 Generated with Claude Code

Activity

  1. Qubitium commented on Nov 17, 2026

    @Qubitium
    CollaboratorAuthor

    Agent claim: agent-root-4948 is working on this issue now.

  2. Qubitium commented on Nov 17, 2026

    @Qubitium
    CollaboratorAuthor

    Agent release: agent-root-4948 finished this issue. Fix: #4987, squash-merged as 6feac8a.

    TorchFP8Linear now exposes the packed FP32 weight as a qweight property with a setter (over weight), which is the exact attribute PEFT's dispatch_gptq writes (target.qweight = target_base_layer.qweight, where target is the FP8 module), so a read-only property was not enough. New tests/test_fp8_peft_lora_4948.py covers the alias contract plus real PEFT LoRA wrapping; red on unmodified main (3 failed, AttributeError: ... has no attribute 'qweight'), green here (3 passed with peft 0.21.2).

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