transformers - 💡(How to fix) Fix Error running Qwen-3-8B-NVFP4 [2 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
huggingface/transformers#44292Fetched 2026-04-08 00:29:19
View on GitHub
Comments
2
Participants
3
Timeline
10
Reactions
0
Author
Timeline (top)
mentioned ×3subscribed ×3commented ×2closed ×1

Error Message

Traceback (most recent call last): File "/raid/yilegu/diagnosis_agent_demo/drivers/driver_hf_v2.py", line 372, in <module> main() File "/raid/yilegu/diagnosis_agent_demo/drivers/driver_hf_v2.py", line 356, in main _ = generate_text( ^^^^^^^^^^^^^^ File "/raid/yilegu/diagnosis_agent_demo/drivers/driver_hf_v2.py", line 138, in generate_text output_ids = model.generate(**inputs, **gen_kwargs, return_dict_in_generate=True, output_scores=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/torch/utils/_contextlib.py", line 124, in decorate_context return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/transformers/generation/utils.py", line 2566, in generate result = decoding_method( ^^^^^^^^^^^^^^^^ File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/transformers/generation/utils.py", line 2786, in _sample outputs = self(**model_inputs, return_dict=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1776, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1787, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/transformers/utils/generic.py", line 918, in wrapper output = func(self, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/transformers/models/qwen3/modeling_qwen3.py", line 480, in forward outputs: BaseModelOutputWithPast = self.model( ^^^^^^^^^^^ File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1776, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1787, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/transformers/utils/generic.py", line 1072, in wrapper outputs = func(self, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/transformers/models/qwen3/modeling_qwen3.py", line 410, in forward hidden_states = decoder_layer( ^^^^^^^^^^^^^^ File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/transformers/modeling_layers.py", line 94, in call return super().call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1776, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1787, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/transformers/utils/deprecation.py", line 172, in wrapped_func return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/transformers/models/qwen3/modeling_qwen3.py", line 260, in forward hidden_states, _ = self.self_attn( ^^^^^^^^^^^^^^^ File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1776, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1787, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/transformers/utils/deprecation.py", line 172, in wrapped_func return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/transformers/models/qwen3/modeling_qwen3.py", line 200, in forward query_states = self.q_norm(self.q_proj(hidden_states).view(hidden_shape)).transpose(1, 2) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1776, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1787, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/compressed_tensors/quantization/lifecycle/forward.py", line 387, in wrapped_forward output = forward_func_orig.get(module, module.class)( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/compressed_tensors/linear/compressed_linear.py", line 103, in forward weight_data = self.compressor.decompress_module(self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/compressed_tensors/compressors/base.py", line 188, in decompress_module return self.decompress_weight( ^^^^^^^^^^^^^^^^^^^^^^^ File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/compressed_tensors/compressors/quantized_compressors/fp4_quantized.py", line 126, in decompress_weight scale = compressed_data["weight_scale"] ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^ KeyError: 'weight_scale'

Code Example

Traceback (most recent call last):
  File "/raid/yilegu/diagnosis_agent_demo/drivers/driver_hf_v2.py", line 372, in <module>
    main()
  File "/raid/yilegu/diagnosis_agent_demo/drivers/driver_hf_v2.py", line 356, in main
    _ = generate_text(
        ^^^^^^^^^^^^^^
  File "/raid/yilegu/diagnosis_agent_demo/drivers/driver_hf_v2.py", line 138, in generate_text
    output_ids = model.generate(**inputs, **gen_kwargs, return_dict_in_generate=True, output_scores=False)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/torch/utils/_contextlib.py", line 124, in decorate_context
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/transformers/generation/utils.py", line 2566, in generate
    result = decoding_method(
             ^^^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/transformers/generation/utils.py", line 2786, in _sample
    outputs = self(**model_inputs, return_dict=True)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1776, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1787, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/transformers/utils/generic.py", line 918, in wrapper
    output = func(self, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/transformers/models/qwen3/modeling_qwen3.py", line 480, in forward
    outputs: BaseModelOutputWithPast = self.model(
                                       ^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1776, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1787, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/transformers/utils/generic.py", line 1072, in wrapper
    outputs = func(self, *args, **kwargs)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/transformers/models/qwen3/modeling_qwen3.py", line 410, in forward
    hidden_states = decoder_layer(
                    ^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/transformers/modeling_layers.py", line 94, in __call__
    return super().__call__(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1776, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1787, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/transformers/utils/deprecation.py", line 172, in wrapped_func
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/transformers/models/qwen3/modeling_qwen3.py", line 260, in forward
    hidden_states, _ = self.self_attn(
                       ^^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1776, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1787, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/transformers/utils/deprecation.py", line 172, in wrapped_func
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/transformers/models/qwen3/modeling_qwen3.py", line 200, in forward
    query_states = self.q_norm(self.q_proj(hidden_states).view(hidden_shape)).transpose(1, 2)
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1776, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1787, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/compressed_tensors/quantization/lifecycle/forward.py", line 387, in wrapped_forward
    output = forward_func_orig.__get__(module, module.__class__)(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/compressed_tensors/linear/compressed_linear.py", line 103, in forward
    weight_data = self.compressor.decompress_module(self)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/compressed_tensors/compressors/base.py", line 188, in decompress_module
    return self.decompress_weight(
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/compressed_tensors/compressors/quantized_compressors/fp4_quantized.py", line 126, in decompress_weight
    scale = compressed_data["weight_scale"]
            ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
KeyError: 'weight_scale'

---

Using Python 3.12.3 environment at: uv_venvs/transformers-v4576
Package                  Version
------------------------ ---------
accelerate               1.12.0
annotated-types          0.7.0
certifi                  2026.1.4
charset-normalizer       3.4.4
compressed-tensors       0.13.0
cuda-bindings            12.9.4
cuda-pathfinder          1.3.4
filelock                 3.24.3
fsspec                   2026.2.0
hf-xet                   1.2.0
huggingface-hub          0.36.2
idna                     3.11
jinja2                   3.1.6
loguru                   0.7.3
markupsafe               3.0.3
mpmath                   1.3.0
networkx                 3.6.1
numpy                    2.4.2
nvidia-cublas-cu12       12.8.4.1
nvidia-cuda-cupti-cu12   12.8.90
nvidia-cuda-nvrtc-cu12   12.8.93
nvidia-cuda-runtime-cu12 12.8.90
nvidia-cudnn-cu12        9.10.2.21
nvidia-cufft-cu12        11.3.3.83
nvidia-cufile-cu12       1.13.1.3
nvidia-curand-cu12       10.3.9.90
nvidia-cusolver-cu12     11.7.3.90
nvidia-cusparse-cu12     12.5.8.93
nvidia-cusparselt-cu12   0.7.1
nvidia-nccl-cu12         2.27.5
nvidia-nvjitlink-cu12    12.8.93
nvidia-nvshmem-cu12      3.4.5
nvidia-nvtx-cu12         12.8.90
packaging                26.0
psutil                   7.2.2
pydantic                 2.12.5
pydantic-core            2.41.5
pyyaml                   6.0.3
regex                    2026.2.19
requests                 2.32.5
safetensors              0.7.0
setuptools               82.0.0
sympy                    1.14.0
tokenizers               0.22.2
torch                    2.10.0
tqdm                     4.67.3
transformers             4.57.6
triton                   3.6.0
typing-extensions        4.15.0
typing-inspection        0.4.2
urllib3                  2.6.3

---

import torch
from transformers import AutoTokenizer, AutoModelForCausalLM

MODEL_ID = "RedHatAI/Qwen3-8B-NVFP4"
DEVICE = "cuda:0" if torch.cuda.is_available() else "cpu"

print("Torch:", torch.__version__)
print("CUDA available:", torch.cuda.is_available())
if torch.cuda.is_available():
    print("GPU:", torch.cuda.get_device_name(0))

# Load tokenizer and model
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
model = AutoModelForCausalLM.from_pretrained(MODEL_ID)
model.eval()
model.to(DEVICE)

# Single request
prompt = "Say hello in one sentence."
inputs = tokenizer(prompt, return_tensors="pt").to(DEVICE)

with torch.no_grad():
    outputs = model.generate(
        **inputs,
        max_new_tokens=32,
        do_sample=False
    )

generated = outputs[:, inputs["input_ids"].shape[1]:]
text = tokenizer.decode(generated[0], skip_special_tokens=False)

print("\n=== OUTPUT ===")
print(text)
RAW_BUFFERClick to expand / collapse

System Info

Hi,

I encountered the following error while running Qwen-3-8B-NVFP4 model.

Is NVFP4 not supported on transformers? My package info is also shared at the bottom.

Traceback (most recent call last):
  File "/raid/yilegu/diagnosis_agent_demo/drivers/driver_hf_v2.py", line 372, in <module>
    main()
  File "/raid/yilegu/diagnosis_agent_demo/drivers/driver_hf_v2.py", line 356, in main
    _ = generate_text(
        ^^^^^^^^^^^^^^
  File "/raid/yilegu/diagnosis_agent_demo/drivers/driver_hf_v2.py", line 138, in generate_text
    output_ids = model.generate(**inputs, **gen_kwargs, return_dict_in_generate=True, output_scores=False)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/torch/utils/_contextlib.py", line 124, in decorate_context
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/transformers/generation/utils.py", line 2566, in generate
    result = decoding_method(
             ^^^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/transformers/generation/utils.py", line 2786, in _sample
    outputs = self(**model_inputs, return_dict=True)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1776, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1787, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/transformers/utils/generic.py", line 918, in wrapper
    output = func(self, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/transformers/models/qwen3/modeling_qwen3.py", line 480, in forward
    outputs: BaseModelOutputWithPast = self.model(
                                       ^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1776, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1787, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/transformers/utils/generic.py", line 1072, in wrapper
    outputs = func(self, *args, **kwargs)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/transformers/models/qwen3/modeling_qwen3.py", line 410, in forward
    hidden_states = decoder_layer(
                    ^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/transformers/modeling_layers.py", line 94, in __call__
    return super().__call__(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1776, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1787, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/transformers/utils/deprecation.py", line 172, in wrapped_func
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/transformers/models/qwen3/modeling_qwen3.py", line 260, in forward
    hidden_states, _ = self.self_attn(
                       ^^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1776, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1787, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/transformers/utils/deprecation.py", line 172, in wrapped_func
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/transformers/models/qwen3/modeling_qwen3.py", line 200, in forward
    query_states = self.q_norm(self.q_proj(hidden_states).view(hidden_shape)).transpose(1, 2)
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1776, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1787, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/compressed_tensors/quantization/lifecycle/forward.py", line 387, in wrapped_forward
    output = forward_func_orig.__get__(module, module.__class__)(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/compressed_tensors/linear/compressed_linear.py", line 103, in forward
    weight_data = self.compressor.decompress_module(self)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/compressed_tensors/compressors/base.py", line 188, in decompress_module
    return self.decompress_weight(
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/raid/yilegu/uv_venvs/transformers-v4576/lib/python3.12/site-packages/compressed_tensors/compressors/quantized_compressors/fp4_quantized.py", line 126, in decompress_weight
    scale = compressed_data["weight_scale"]
            ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
KeyError: 'weight_scale'

Package Info

Using Python 3.12.3 environment at: uv_venvs/transformers-v4576
Package                  Version
------------------------ ---------
accelerate               1.12.0
annotated-types          0.7.0
certifi                  2026.1.4
charset-normalizer       3.4.4
compressed-tensors       0.13.0
cuda-bindings            12.9.4
cuda-pathfinder          1.3.4
filelock                 3.24.3
fsspec                   2026.2.0
hf-xet                   1.2.0
huggingface-hub          0.36.2
idna                     3.11
jinja2                   3.1.6
loguru                   0.7.3
markupsafe               3.0.3
mpmath                   1.3.0
networkx                 3.6.1
numpy                    2.4.2
nvidia-cublas-cu12       12.8.4.1
nvidia-cuda-cupti-cu12   12.8.90
nvidia-cuda-nvrtc-cu12   12.8.93
nvidia-cuda-runtime-cu12 12.8.90
nvidia-cudnn-cu12        9.10.2.21
nvidia-cufft-cu12        11.3.3.83
nvidia-cufile-cu12       1.13.1.3
nvidia-curand-cu12       10.3.9.90
nvidia-cusolver-cu12     11.7.3.90
nvidia-cusparse-cu12     12.5.8.93
nvidia-cusparselt-cu12   0.7.1
nvidia-nccl-cu12         2.27.5
nvidia-nvjitlink-cu12    12.8.93
nvidia-nvshmem-cu12      3.4.5
nvidia-nvtx-cu12         12.8.90
packaging                26.0
psutil                   7.2.2
pydantic                 2.12.5
pydantic-core            2.41.5
pyyaml                   6.0.3
regex                    2026.2.19
requests                 2.32.5
safetensors              0.7.0
setuptools               82.0.0
sympy                    1.14.0
tokenizers               0.22.2
torch                    2.10.0
tqdm                     4.67.3
transformers             4.57.6
triton                   3.6.0
typing-extensions        4.15.0
typing-inspection        0.4.2
urllib3                  2.6.3

Who can help?

@ArthurZucker @SunMarc @MekkCyber

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

import torch
from transformers import AutoTokenizer, AutoModelForCausalLM

MODEL_ID = "RedHatAI/Qwen3-8B-NVFP4"
DEVICE = "cuda:0" if torch.cuda.is_available() else "cpu"

print("Torch:", torch.__version__)
print("CUDA available:", torch.cuda.is_available())
if torch.cuda.is_available():
    print("GPU:", torch.cuda.get_device_name(0))

# Load tokenizer and model
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
model = AutoModelForCausalLM.from_pretrained(MODEL_ID)
model.eval()
model.to(DEVICE)

# Single request
prompt = "Say hello in one sentence."
inputs = tokenizer(prompt, return_tensors="pt").to(DEVICE)

with torch.no_grad():
    outputs = model.generate(
        **inputs,
        max_new_tokens=32,
        do_sample=False
    )

generated = outputs[:, inputs["input_ids"].shape[1]:]
text = tokenizer.decode(generated[0], skip_special_tokens=False)

print("\n=== OUTPUT ===")
print(text)

Expected behavior

No error

extent analysis

Problem Summary

The issue is caused by a KeyError when trying to decompress a weight in the Qwen-3-8B-NVFP4 model. The error occurs because the 'weight_scale' key is missing from the compressed data.

Root Cause Analysis

The root cause is likely due to a mismatch between the compressed tensors library and the model's requirements. The Qwen-3-8B-NVFP4 model is using FP4 quantization, but the compressed tensors library is not properly configured to handle this type of quantization.

Fix Plan

To fix this issue, you need to update the compressed tensors library to support FP4 quantization. Here are the steps:

Step 1: Update the compressed tensors library

Update the compressed-tensors library to the latest version that supports FP4 quantization.

pip install --upgrade compressed-tensors

Step 2: Update the model's configuration

Update the model's configuration to use the correct quantization scheme. In this case, you need to set the quantization parameter to fp4 when loading the model.

from transformers import AutoModelForCausalLM

MODEL_ID = "RedHatAI/Qwen3-8B-NVFP4"
DEVICE = "cuda:0" if torch.cuda.is_available() else "cpu"

# Load tokenizer and model with FP4 quantization
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
model = AutoModelForCausalLM.from_pretrained(MODEL_ID, quantization="fp4")
model.eval()
model.to(DEVICE)

Step 3: Verify the fix

Run the reproduction script again to verify that the fix works.

# Single request
prompt = "Say hello in one sentence."
inputs = tokenizer(prompt, return_tensors="pt").to(DEVICE)

with torch.no_grad():
    outputs = model.generate(
        **inputs

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

No error

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING