Instructions to use JetLM/SDAR-1.7B-Chat with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use JetLM/SDAR-1.7B-Chat with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="JetLM/SDAR-1.7B-Chat", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("JetLM/SDAR-1.7B-Chat", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use JetLM/SDAR-1.7B-Chat with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "JetLM/SDAR-1.7B-Chat" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "JetLM/SDAR-1.7B-Chat", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/JetLM/SDAR-1.7B-Chat
- SGLang
How to use JetLM/SDAR-1.7B-Chat 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 "JetLM/SDAR-1.7B-Chat" \ --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": "JetLM/SDAR-1.7B-Chat", "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 "JetLM/SDAR-1.7B-Chat" \ --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": "JetLM/SDAR-1.7B-Chat", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use JetLM/SDAR-1.7B-Chat with Docker Model Runner:
docker model run hf.co/JetLM/SDAR-1.7B-Chat
Force SDPA path (flash_attn had v5 compat issue with different Q/K seq lengths)
Browse files- modeling_sdar.py +11 -21
modeling_sdar.py
CHANGED
|
@@ -277,27 +277,17 @@ class SDARAttention(nn.Module):
|
|
| 277 |
value_states = torch.cat([past_value_states, value_states], dim=-2)
|
| 278 |
|
| 279 |
attention_mask = attention_mask.bool() if attention_mask is not None else None
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
else: # prefilling
|
| 292 |
-
attn_output = F.scaled_dot_product_attention(
|
| 293 |
-
query=query_states,
|
| 294 |
-
key=key_states,
|
| 295 |
-
value=value_states,
|
| 296 |
-
attn_mask=attention_mask,
|
| 297 |
-
is_causal=False,
|
| 298 |
-
scale=self.scaling,
|
| 299 |
-
enable_gqa=True)
|
| 300 |
-
attn_output = attn_output.transpose(1, 2).contiguous()
|
| 301 |
|
| 302 |
attn_output = attn_output.reshape(*input_shape, -1).contiguous()
|
| 303 |
attn_output = self.o_proj(attn_output)
|
|
|
|
| 277 |
value_states = torch.cat([past_value_states, value_states], dim=-2)
|
| 278 |
|
| 279 |
attention_mask = attention_mask.bool() if attention_mask is not None else None
|
| 280 |
+
# Always use SDPA (flash_attn path had a v5 compatibility issue that produced
|
| 281 |
+
# identical outputs across query positions when Q and K seq lengths differed).
|
| 282 |
+
attn_output = F.scaled_dot_product_attention(
|
| 283 |
+
query=query_states,
|
| 284 |
+
key=key_states,
|
| 285 |
+
value=value_states,
|
| 286 |
+
attn_mask=attention_mask,
|
| 287 |
+
is_causal=False,
|
| 288 |
+
scale=self.scaling,
|
| 289 |
+
enable_gqa=True)
|
| 290 |
+
attn_output = attn_output.transpose(1, 2).contiguous()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 291 |
|
| 292 |
attn_output = attn_output.reshape(*input_shape, -1).contiguous()
|
| 293 |
attn_output = self.o_proj(attn_output)
|