Downloads · 30 days
138
40% of all-time downloads
prithivMLmods/Qwen-Image-2.1-PE-T2I-FP8
Qwen-Image-2.1-PE-T2I-FP8 is a text generation model from prithivMLmods. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as other.
Qwen-Image-2.1-PE-T2I-FP8 is an FP8 dynamic-quantized build of Qwen/Qwen-Image-2.1-PE-T2I, the text-to-image prompt rewriting model for Qwen-Image-2.1. The base model is a fine-tuned Qwen3.5-VL 9B that turns a brief i…
Downloads · 30 days
138
40% of all-time downloads
All-time downloads
342
Public
Parameters
9.4B
13.5 GB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors13.5 GB · 100%
How the weights are stored.
F8_E4M35.3B · 56%
From the Hugging Face model README
Qwen-Image-2.1-PE-T2I-FP8 is an FP8 dynamic-quantized build of Qwen/Qwen-Image-2.1-PE-T2I, the text-to-image prompt rewriting model for Qwen-Image-2.1. The base model is a fine-tuned Qwen3.5-VL 9B that turns a brief image request in any language into a detailed English prompt plus a recommended aspect ratio. This checkpoint was compressed with llm-compressor using the FP8_DYNAMIC scheme, stored in the compressed-tensors format, and is intended to be served with vLLM. The Linear layers are quantized to FP8 weights with dynamic per-token FP8 activations, which lowers weight memory and improves serving throughput relative to the BF16 original. The lm_head, embedding layers, vision modules, and linear attention layers are excluded and kept in their original precision. No calibration data is required, because activation scales are computed at runtime.
[!NOTE] System Prompt — https://huggingface.co/Qwen/Qwen-Image-2.1-PE-T2I/blob/main/system_prompt.txt
| Property | Value |
|---|---|
| Base model | Qwen/Qwen-Image-2.1-PE-T2I |
| Architecture | Qwen3.5-VL 9B (fine-tuned) |
| Quantization tool | llm-compressor |
| Modifier | QuantizationModifier |
| Scheme | FP8_DYNAMIC |
| Checkpoint format | compressed-tensors |
| Quantized modules | Linear layers |
| Excluded modules | lm_head, embed_tokens, visual, linear_attn |
| Calibration data | Not required |
| Inference engine | vLLM |
default_stage:
default_modifiers:
QuantizationModifier:
targets: [Linear]
ignore: ['re:.*lm_head', 're:.*embed_tokens$', 're:.*visual.*', 're:.*model.visual.*',
're:.*linear_attn.*']
scheme: FP8_DYNAMIC
bypass_divisibility_checks: false
requires_calibration_data: false
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from llmcompressor import oneshot
model_id = "Qwen/Qwen-Image-2.1-PE-T2I"
save_dir = "Qwen-Image-2.1-PE-T2I-FP8"
model = AutoModelForCausalLM.from_pretrained(
model_id, dtype=torch.bfloat16, device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained(model_id)
# recipe.yaml is the recipe shown above
oneshot(model=model, recipe="recipe.yaml")
model.save_pretrained(save_dir, save_compressed=True)
tokenizer.save_pretrained(save_dir)
pip install vllm openai huggingface_hub
Use a recent vLLM release with support for Qwen3.5-VL and compressed-tensors FP8 checkpoints. Native FP8 compute requires a GPU with compute capability 8.9 or higher (Ada Lovelace, Hopper, Blackwell). On older GPUs vLLM falls back to weight-only FP8 kernels.
vllm serve prithivMLmods/Qwen-Image-2.1-PE-T2I-FP8 \
--max-model-len 32768
Do not enable a reasoning parser, so the thinking block is returned in the response content and can be split from the JSON answer as shown below.
import json
import huggingface_hub
from openai import OpenAI
model_id = "prithivMLmods/Qwen-Image-2.1-PE-T2I-FP8"
client = OpenAI(base_url="http://localhost:8000/v1", api_key="EMPTY")
# System prompt shipped with the base model
sys_prompt_path = huggingface_hub.hf_hub_download(
"Qwen/Qwen-Image-2.1-PE-T2I", "system_prompt.txt"
)
system_prompt = open(sys_prompt_path).read().strip()
user_prompt = "一只在雨中弹吉他的柯基"
response = client.chat.completions.create(
model=model_id,
messages=[
{"role": "system", "content": system_prompt},
{"role": "user", "content": user_prompt},
],
max_tokens=16256,
temperature=1.0,
top_p=0.95,
seed=42,
extra_body={"top_k": 20},
)
gen = response.choices[0].message.content
# Split thinking from the answer
thinking, _, answer = gen.partition("</think>")
result = json.loads(answer.strip())
print(result)
# {"rewritten_prompt": "<long detailed English prompt>", "wh_ratio": "16:9"}
import torch
from diffusers import QwenImage21Pipeline
WH_RATIO_TO_SIZE = {
"1:1": (2048, 2048), "4:3": (2400, 1792), "3:4": (1792, 2400),
"3:2": (2528, 1696), "2:3": (1696, 2528), "16:9": (2752, 1536),
"9:16": (1536, 2752),
}
# `result` from the vLLM call above
prompt = result["rewritten_prompt"]
width, height = WH_RATIO_TO_SIZE.get(result["wh_ratio"], (2048, 2048))
pipe = QwenImage21Pipeline.from_pretrained(
"Qwen/Qwen-Image-2.1", torch_dtype=torch.bfloat16
).to("cuda")
image = pipe(
prompt=prompt,
width=width, height=height,
num_inference_steps=40,
generator=torch.Generator("cuda").manual_seed(42),
).images[0]
image.save("rewritten_t2i.png")
The model emits a JSON object after a <think> reasoning block:
{
"rewritten_prompt": "<long detailed English prompt describing the finished image>",
"wh_ratio": "16:9"
}
| Field | Description |
|---|---|
rewritten_prompt | Expanded English prompt to pass to the image generation model |
wh_ratio | Recommended aspect ratio for rendering |
The aspect ratios used in the Diffusers example map to the following output sizes:
wh_ratio | Width x Height |
|---|---|
1:1 | 2048 x 2048 |
4:3 | 2400 x 1792 |
3:4 | 1792 x 2400 |
3:2 | 2528 x 1696 |
2:3 | 1696 x 2528 |
16:9 | 2752 x 1536 |
9:16 | 1536 x 2752 |
temperature=1.0 can occasionally produce invalid JSON.This model inherits the license of the base model and is distributed under the Qwen Research License Agreement.
Base model by the Qwen team: Qwen/Qwen-Image-2.1-PE-T2I. Quantization with llm-compressor. Serving with vLLM. See the Qwen-Image-2.1 GitHub repo and blog for details on the full pipeline.