Instructions to use Jackmin108/Qwen3-30B-A3B-Base-Fast with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Jackmin108/Qwen3-30B-A3B-Base-Fast with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Jackmin108/Qwen3-30B-A3B-Base-Fast", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Jackmin108/Qwen3-30B-A3B-Base-Fast", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("Jackmin108/Qwen3-30B-A3B-Base-Fast", trust_remote_code=True, 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 Jackmin108/Qwen3-30B-A3B-Base-Fast with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Jackmin108/Qwen3-30B-A3B-Base-Fast" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Jackmin108/Qwen3-30B-A3B-Base-Fast", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Jackmin108/Qwen3-30B-A3B-Base-Fast
- SGLang
How to use Jackmin108/Qwen3-30B-A3B-Base-Fast 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 "Jackmin108/Qwen3-30B-A3B-Base-Fast" \ --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": "Jackmin108/Qwen3-30B-A3B-Base-Fast", "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 "Jackmin108/Qwen3-30B-A3B-Base-Fast" \ --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": "Jackmin108/Qwen3-30B-A3B-Base-Fast", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Jackmin108/Qwen3-30B-A3B-Base-Fast with Docker Model Runner:
docker model run hf.co/Jackmin108/Qwen3-30B-A3B-Base-Fast
Commit ·
9fbf0f6
1
Parent(s): 96e2301
add custom sdpa path that works with cp
Browse files- modeling_qwen3_moe.py +24 -16
modeling_qwen3_moe.py
CHANGED
|
@@ -167,23 +167,31 @@ class Qwen3MoeAttention(nn.Module):
|
|
| 167 |
cache_kwargs = {"sin": sin, "cos": cos, "cache_position": cache_position}
|
| 168 |
key_states, value_states = past_key_value.update(key_states, value_states, self.layer_idx, cache_kwargs)
|
| 169 |
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 185 |
|
| 186 |
-
|
| 187 |
attn_output = self.o_proj(attn_output)
|
| 188 |
return attn_output, attn_weights
|
| 189 |
|
|
|
|
| 167 |
cache_kwargs = {"sin": sin, "cos": cos, "cache_position": cache_position}
|
| 168 |
key_states, value_states = past_key_value.update(key_states, value_states, self.layer_idx, cache_kwargs)
|
| 169 |
|
| 170 |
+
if self.config._attn_implementation == "sdpa":
|
| 171 |
+
key_states = key_states.repeat_interleave(self.num_key_value_groups, dim=1)
|
| 172 |
+
value_states = value_states.repeat_interleave(self.num_key_value_groups, dim=1)
|
| 173 |
+
out = F.scaled_dot_product_attention(query_states, key_states, value_states, is_causal=True)
|
| 174 |
+
out = out.transpose(1, 2).contiguous() #.view(out.shape[0], out.shape[1], -1)
|
| 175 |
+
attn_output = out.view(out.shape[0], out.shape[1], -1)
|
| 176 |
+
attn_weights = None
|
| 177 |
+
else:
|
| 178 |
+
attention_interface: Callable = eager_attention_forward
|
| 179 |
+
if self.config._attn_implementation != "eager":
|
| 180 |
+
attention_interface = ALL_ATTENTION_FUNCTIONS[self.config._attn_implementation]
|
| 181 |
+
|
| 182 |
+
attn_output, attn_weights = attention_interface(
|
| 183 |
+
self,
|
| 184 |
+
query_states,
|
| 185 |
+
key_states,
|
| 186 |
+
value_states,
|
| 187 |
+
attention_mask,
|
| 188 |
+
dropout=0.0 if not self.training else self.attention_dropout,
|
| 189 |
+
scaling=self.scaling,
|
| 190 |
+
sliding_window=self.sliding_window, # diff with Llama
|
| 191 |
+
**kwargs,
|
| 192 |
+
)
|
| 193 |
|
| 194 |
+
attn_output = attn_output.reshape(*input_shape, -1).contiguous()
|
| 195 |
attn_output = self.o_proj(attn_output)
|
| 196 |
return attn_output, attn_weights
|
| 197 |
|