--- language: - multilingual base_model: - Qwen/Qwen3-8B pipeline_tag: text-generation tags: - qwen - qwen3 - fp8 - vllm - conversational - text-generation-inference - llm-compressor license: apache-2.0 --- ## Model Overview - **Model Architecture:** Qwen3ForCausalLM - **Input:** Text - **Output:** Text - **Model Optimizations:** - **Activation quantization:** FP8 - **Weight quantization:** FP8 - **Intended Use Cases:** Intended for commercial and research use. Similarly to the base model, this quantized version is intended for assistant-like chat and multilingual text generation across 100+ languages. - **Out-of-scope:** Use in any manner that violates applicable laws or regulations (including trade compliance laws). - **Version:** 1.0 - **Model Developers:** RedHat (Neural Magic) ### Model Optimizations This model was obtained by quantizing activations and weights of [Qwen/Qwen3-8B](https://huggingface.co/Qwen/Qwen3-8B) to FP8 data type. This optimization reduces the number of bits used to represent weights and activations from 16 to 8, reducing GPU memory requirements (by approximately 50%) and increasing matrix-multiply compute throughput (by approximately 2x). Weight quantization also reduces disk size requirements by approximately 50%. Only weights and activations of the linear operators within transformers blocks are quantized. Weights are quantized with a symmetric static per-channel scheme, whereas activations are quantized with a symmetric dynamic per-token scheme. The [llm-compressor](https://github.com/vllm-project/llm-compressor) library is used for quantization. ## Deployment This model can be deployed efficiently using the [vLLM](https://docs.vllm.ai/en/latest/) backend, as shown in the example below. ```python from vllm import LLM, SamplingParams from transformers import AutoTokenizer model_id = "inference-optimization/Qwen3-8B-FP8-Dynamic" number_gpus = 1 sampling_params = SamplingParams(temperature=0.6, top_p=0.95, top_k=20, min_p=0, max_tokens=256) tokenizer = AutoTokenizer.from_pretrained(model_id) messages = [{"role": "user", "content": "Give me a short introduction to large language model."}] prompts = tokenizer.apply_chat_template(messages, add_generation_prompt=True, tokenize=False) llm = LLM(model=model_id, tensor_parallel_size=number_gpus) outputs = llm.generate(prompts, sampling_params) generated_text = outputs[0].outputs[0].text print(generated_text) ``` ## Creation
Creation details This model was created with [llm-compressor](https://github.com/vllm-project/llm-compressor) by running the code snippet below. ```python from compressed_tensors.offload import dispatch_model from transformers import AutoModelForCausalLM, AutoTokenizer from llmcompressor import oneshot from llmcompressor.modifiers.quantization import QuantizationModifier MODEL_ID = "Qwen/Qwen3-8B" # Load model. model = AutoModelForCausalLM.from_pretrained( MODEL_ID, low_cpu_mem_usage=True, ) tokenizer = AutoTokenizer.from_pretrained(MODEL_ID) recipe = QuantizationModifier( targets=["Linear"], scheme="FP8_DYNAMIC", ignore=["lm_head"], ) # Apply quantization. oneshot(model=model, recipe=recipe) print("========== SAMPLE GENERATION ==============") dispatch_model(model) input_ids = tokenizer("Hello my name is", return_tensors="pt").input_ids.to(model.device) output = model.generate(input_ids, max_new_tokens=20) print(tokenizer.decode(output[0])) print("==========================================") SAVE_DIR = MODEL_ID.rstrip("/").split("/")[-1] + "-FP8-Dynamic" model.save_pretrained(SAVE_DIR) tokenizer.save_pretrained(SAVE_DIR) ```