Instructions to use Rainy-W-cy/qwen2-0.5b-instruct-rtn-w8a16 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Rainy-W-cy/qwen2-0.5b-instruct-rtn-w8a16 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Rainy-W-cy/qwen2-0.5b-instruct-rtn-w8a16") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Rainy-W-cy/qwen2-0.5b-instruct-rtn-w8a16") model = AutoModelForCausalLM.from_pretrained("Rainy-W-cy/qwen2-0.5b-instruct-rtn-w8a16", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Rainy-W-cy/qwen2-0.5b-instruct-rtn-w8a16 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Rainy-W-cy/qwen2-0.5b-instruct-rtn-w8a16" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Rainy-W-cy/qwen2-0.5b-instruct-rtn-w8a16", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Rainy-W-cy/qwen2-0.5b-instruct-rtn-w8a16
- SGLang
How to use Rainy-W-cy/qwen2-0.5b-instruct-rtn-w8a16 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Rainy-W-cy/qwen2-0.5b-instruct-rtn-w8a16" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Rainy-W-cy/qwen2-0.5b-instruct-rtn-w8a16", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "Rainy-W-cy/qwen2-0.5b-instruct-rtn-w8a16" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Rainy-W-cy/qwen2-0.5b-instruct-rtn-w8a16", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Rainy-W-cy/qwen2-0.5b-instruct-rtn-w8a16 with Docker Model Runner:
docker model run hf.co/Rainy-W-cy/qwen2-0.5b-instruct-rtn-w8a16
Qwen2-0.5B-Instruct RTN W8A16
This repository contains an INT8 weight-only quantized version of Qwen/Qwen2-0.5B-Instruct. The checkpoint was produced with RTN through llm-compressor and saved in the compressed-tensors format.
这是Qwen2-0.5B-Instruct的RTN W8A16版本。Linear权重以INT8保存,激活、Attention和KV Cache保持浮点;它不是动态W8A8模型。
Model Details
| Field | Value |
|---|---|
| Base model | Qwen/Qwen2-0.5B-Instruct |
| Base revision | c540970f9e29518b1d8f06ab8b24cba66ad77b6d |
| Offline algorithm | RTN (round-to-nearest weight quantization) |
| Quantized targets | Linear |
| Weight format | Signed INT8, symmetric |
| Weight granularity | Per-output-channel (strategy=channel, group_size=null) |
| Activation/KV format | Floating point; not quantized by this checkpoint |
| Ignored module | lm_head |
| Resolved model dtype | BF16 |
| Serialization | compressed-tensors, pack-quantized |
| Export provider | llm-compressor==0.12.0 |
| Compression library | compressed-tensors==0.17.1 |
RTN was executed without a calibration dataset. No fine-tuning or additional training was performed.
Usage
Use a Transformers environment that supports the serialized compressed-tensors format. The export environment used Transformers 5.10.1 and compressed-tensors==0.17.1.
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "<your-hf-account>/Qwen2-0.5B-Instruct-RTN-W8A16"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype="auto",
device_map="auto",
)
messages = [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Explain INT8 weight-only quantization briefly."},
]
text = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True,
)
inputs = tokenizer([text], return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=128, do_sample=False)
response = tokenizer.decode(
outputs[0][inputs.input_ids.shape[1]:],
skip_special_tokens=True,
)
print(response)
Quantization Files
config.jsoncontains the effectivecompressed-tensorsquantization configuration.provider_recipe.jsonrecords the requested and resolved provider parameters.recipe.yamlcontains the effective llm-compressor recipe.model.safetensorscontains the compressed model weights.
Evaluation
No formal benchmark results are claimed in this model card yet. The local artifact manifest records software evaluation as not_checked. Before publishing results, evaluate this checkpoint and the BF16 base model with identical task versions, prompts, sample selections, chat templates, generation parameters, and random seeds.
Example with LM Evaluation Harness:
lm-eval run \
--model hf \
--model_args pretrained=<your-hf-account>/Qwen2-0.5B-Instruct-RTN-W8A16,dtype=auto \
--tasks arc_challenge \
--num_fewshot 0 \
--apply_chat_template \
--batch_size 1 \
--log_samples \
--output_path runs/rtn_w8a16/arc_challenge
Intended Use
- Research on INT8 weight-only quantization.
- Software quality comparison against the pinned BF16 base model.
- Input to a separately validated deployment compiler or hardware-runtime workflow.
Limitations
- This is W8A16/weight-only, not end-to-end W8A8 or integer-only inference.
lm_head, activations, Attention operations, and KV Cache are not INT8-quantized by this checkpoint.- Runtime speed depends on backend support; reduced weight storage does not guarantee faster inference on every device.
- The model inherits the capabilities, limitations, and potential biases of the base Qwen2 model.
- No formal accuracy, perplexity, latency, power, or hardware-resource result is bundled yet.
License
The base model is released under the Apache 2.0 license. This quantized derivative follows the same license; users remain responsible for complying with the base model terms.
Citation
@article{qwen2,
title={Qwen2 Technical Report},
author={Yang, An and others},
journal={arXiv preprint arXiv:2407.10671},
year={2024}
}
- Downloads last month
- 129