Text Generation
Transformers
Safetensors
qwen3
sparse
2:4
semi-structured-sparsity
openwebtext
conversational
text-generation-inference
Instructions to use SparseMindAI/qwen3-8b-24sst-sparse-adamw with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use SparseMindAI/qwen3-8b-24sst-sparse-adamw with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="SparseMindAI/qwen3-8b-24sst-sparse-adamw") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("SparseMindAI/qwen3-8b-24sst-sparse-adamw") model = AutoModelForCausalLM.from_pretrained("SparseMindAI/qwen3-8b-24sst-sparse-adamw", 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=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use SparseMindAI/qwen3-8b-24sst-sparse-adamw with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "SparseMindAI/qwen3-8b-24sst-sparse-adamw" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "SparseMindAI/qwen3-8b-24sst-sparse-adamw", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/SparseMindAI/qwen3-8b-24sst-sparse-adamw
- SGLang
How to use SparseMindAI/qwen3-8b-24sst-sparse-adamw 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 "SparseMindAI/qwen3-8b-24sst-sparse-adamw" \ --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": "SparseMindAI/qwen3-8b-24sst-sparse-adamw", "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 "SparseMindAI/qwen3-8b-24sst-sparse-adamw" \ --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": "SparseMindAI/qwen3-8b-24sst-sparse-adamw", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use SparseMindAI/qwen3-8b-24sst-sparse-adamw with Docker Model Runner:
docker model run hf.co/SparseMindAI/qwen3-8b-24sst-sparse-adamw
Qwen3-8B-24SST-Sparse-AdamW
Qwen3-8B-24SST-Sparse-AdamW is a 2:4 semi-structured sparse version of Qwen3-8B, retrained with 24SST dynamic sparse training so it keeps high accuracy while retaining only half of the weights.
Model details
- Base model: Qwen/Qwen3-8B
- Architecture: Qwen3ForCausalLM (36 layers, hidden size 4096, 32 attention heads, 8 KV heads)
- Sparsity pattern: 2:4 semi-structured (at most 2 non-zero weights in every group of 4 consecutive weights)
- Training data: OpenWebText (OWT)
- Training method: CHTsnm dynamic sparse training (24SST)
- Optimizer: AdamW
Why sparsity?
2:4 semi-structured sparsity keeps only 2 of every 4 weights, which gives:
- ~2ร faster matrix multiplies on hardware with sparse tensor cores (e.g. NVIDIA Ampere and later), which skip the zeroed weights in hardware.
- ~1.8ร smaller weight storage โ each group of 4 weights is stored as 2 values plus 2 compact 2-bit indices instead of 4 full values.
- Lower energy per token at inference, since fewer multiply-accumulate operations are executed.
Unlike one-shot pruning, retraining the sparse network lets the remaining weights adapt, so the model keeps much more of the dense model's quality.
Usage
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained("SparseMindAI/qwen3-8b-24sst-sparse-adamw", torch_dtype="auto")
tokenizer = AutoTokenizer.from_pretrained("SparseMindAI/qwen3-8b-24sst-sparse-adamw")
messages = [{"role": "user", "content": "Hello!"}]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(text, return_tensors="pt")
outputs = model.generate(**inputs, max_new_tokens=128)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
Reference
Original dense model: Qwen/Qwen3-8B
- Downloads last month
- 46