Instructions to use uzairkhn/Qwen3.8-27B-FP4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use uzairkhn/Qwen3.8-27B-FP4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="uzairkhn/Qwen3.8-27B-FP4") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("uzairkhn/Qwen3.8-27B-FP4") model = AutoModelForCausalLM.from_pretrained("uzairkhn/Qwen3.8-27B-FP4", 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 uzairkhn/Qwen3.8-27B-FP4 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "uzairkhn/Qwen3.8-27B-FP4" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "uzairkhn/Qwen3.8-27B-FP4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/uzairkhn/Qwen3.8-27B-FP4
- SGLang
How to use uzairkhn/Qwen3.8-27B-FP4 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 "uzairkhn/Qwen3.8-27B-FP4" \ --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": "uzairkhn/Qwen3.8-27B-FP4", "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 "uzairkhn/Qwen3.8-27B-FP4" \ --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": "uzairkhn/Qwen3.8-27B-FP4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use uzairkhn/Qwen3.8-27B-FP4 with Docker Model Runner:
docker model run hf.co/uzairkhn/Qwen3.8-27B-FP4
Model Card for uzairkhanux/Qwen3.8-27B-FP4
Model Details
Model Description
This model is a fine-tuned and 4-bit (FP4) quantized version of the Qwen/Qwen3.8-27B large language model. Following the fine-tuning process on the main model, it was quantized on-the-fly using the bitsandbytes library and pushed directly to the Hugging Face Hub. The quantization reduces the model's memory footprint from approximately 54GB (in native 16-bit) down to roughly 14GB, making it strictly accessible for deployment and inference on hardware with constrained VRAM limits, such as a single 16GB GPU or Kaggle 2x T4 setups.
- Developed by: uzairkhanux (Fine-tuning and Quantization) / Original base model by Qwen Team
- Shared by: uzairkhanux
- Model type: Causal Language Model (Transformer-based, Fine-tuned, FP4 Quantized)
- Language(s) (NLP): Multilingual (including English, Chinese, and others supported by the base model)
- License: Governed by the license of the original
Qwen/Qwen3.8-27Bbase model. - Finetuned from model:
Qwen/Qwen3.8-27B
Model Sources
- Repository: https://huggingface.co/uzairkhanux/Qwen3.8-27B-FP4
- Base Model: https://huggingface.co/Qwen/Qwen3.8-27B
Uses
Direct Use
This model is intended for direct text generation, zero-shot/few-shot prompting, and conversational inference tailored to the specific domain it was fine-tuned on. It is designed to be loaded directly via the Hugging Face transformers ecosystem utilizing bitsandbytes for 4-bit loading.
Out-of-Scope Use
Because this specific version relies on CPU offloading to bypass memory spikes during initialization across 2x T4 GPUs, highly latency-sensitive production environments should avoid using it without dedicated high-VRAM hardware (such as A100s), as CPU-to-GPU memory swapping heavily degrades tokens-per-second throughput.
Bias, Risks, and Limitations
Like all foundational Large Language Models, this model inherits the biases present in its original training data and any data used during the fine-tuning phase. It may generate inaccurate, biased, or objectionable content. Furthermore, the 4-bit (FP4) quantization process is lossy; users should expect a slight degradation in complex reasoning compared to the native 16-bit/BF16 weights.
Recommendations
Users evaluating this model for specific downstream tasks should conduct rigorous testing against the unquantized baseline to measure the impact of FP4 precision loss. Always deploy appropriate safety guardrails if integrating this into user-facing applications.
How to Get Started with the Model
Use the ready-to-paste Python code below to load this model and run inference. This configuration specifically accounts for memory limitations by offloading excess weights to system RAM, preventing CUDA Out of Memory exceptions.
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
model_id = "uzairkhanux/Qwen3.8-27B-FP4"
# Configure FP4 Quantization WITH CPU Offloading capability
quantization_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="fp4",
bnb_4bit_compute_dtype=torch.float16,
bnb_4bit_use_double_quant=False,
llm_int8_enable_fp32_cpu_offload=True
)
# Apply safety buffers to prevent CUDA Out Of Memory spikes (e.g., for Kaggle 2x T4)
memory_limits = {
0: "12GB",
1: "12GB",
"cpu": "25GB"
}
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
quantization_config=quantization_config,
device_map="auto",
max_memory=memory_limits,
low_cpu_mem_usage=True
)
# Inference generation
prompt = "Explain the core mechanics of a transformer neural network."
messages = [
{"role": "system", "content": "You are a highly capable AI assistant."},
{"role": "user", "content": prompt}
]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
with torch.no_grad():
generated_ids = model.generate(
**model_inputs,
max_new_tokens=512,
temperature=0.7,
top_p=0.9,
do_sample=True,
pad_token_id=tokenizer.eos_token_id
)
generated_ids = [
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
]
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
print(response)
- Downloads last month
- -
Model tree for uzairkhn/Qwen3.8-27B-FP4
Base model
Qwen/Qwen3.8-27B