Text Generation
Transformers
Safetensors
English
Arabic
quasar_long
silx-ai
quasar-preview
quasar
foundation-model
Mixture of Experts
18b
2b-active
long-context
bittensor
sn24
decentralized-training
distillation
hybrid-transformer
loop-transformer
safe-nope
drope
conversational
custom_code
Instructions to use silx-ai/Quasar-Preview with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use silx-ai/Quasar-Preview with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="silx-ai/Quasar-Preview", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("silx-ai/Quasar-Preview", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use silx-ai/Quasar-Preview with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "silx-ai/Quasar-Preview" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "silx-ai/Quasar-Preview", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/silx-ai/Quasar-Preview
- SGLang
How to use silx-ai/Quasar-Preview 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 "silx-ai/Quasar-Preview" \ --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": "silx-ai/Quasar-Preview", "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 "silx-ai/Quasar-Preview" \ --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": "silx-ai/Quasar-Preview", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use silx-ai/Quasar-Preview with Docker Model Runner:
docker model run hf.co/silx-ai/Quasar-Preview
| # Copyright (c) 2023-2025, Songlin Yang, Yu Zhang | |
| import torch | |
| from fla.ops.common.fused_recurrent import fused_recurrent | |
| def fused_recurrent_simple_gla( | |
| q: torch.Tensor, | |
| k: torch.Tensor, | |
| v: torch.Tensor, | |
| g: torch.Tensor = None, | |
| g_gamma: torch.Tensor = None, | |
| scale: float | None = None, | |
| initial_state: torch.Tensor | None = None, | |
| output_final_state: bool = False, | |
| reverse: bool = False, | |
| cu_seqlens: torch.LongTensor | None = None, | |
| ) -> tuple[torch.Tensor, torch.Tensor]: | |
| r""" | |
| Args: | |
| q (torch.Tensor): | |
| queries of shape `[B, T, H, K]`. | |
| k (torch.Tensor): | |
| keys of shape `[B, T, H, K]`. | |
| v (torch.Tensor): | |
| values of shape `[B, T, H, V]`. | |
| g (torch.Tensor): | |
| Forget gates of shape `[B, T, H]`. | |
| Compared to GLA, the gating is head-wise instead of elementwise. | |
| g_gamma (torch.Tensor): | |
| Log decay of shape `[H]`. | |
| Head-wise data-independent decay is used if `g_gamma` is provided. | |
| Only one of `g` or `g_gamma` should be provided. | |
| scale (Optional[float]): | |
| Scale factor for the attention scores. | |
| If not provided, it will default to `1 / sqrt(K)`. Default: `None`. | |
| initial_state (Optional[torch.Tensor]): | |
| Initial state of shape `[N, H, K, V]` for `N` input sequences. | |
| For equal-length input sequences, `N` equals the batch size `B`. | |
| Default: `None`. | |
| output_final_state (Optional[bool]): | |
| Whether to output the final state of shape `[N, H, K, V]`. Default: `False`. | |
| reverse (Optional[bool]): | |
| If `True`, process the state passing in reverse order. Default: `False`. | |
| cu_seqlens (torch.LongTensor): | |
| Cumulative sequence lengths of shape `[N+1]` used for variable-length training, | |
| consistent with the FlashAttention API. | |
| Returns: | |
| o (torch.Tensor): | |
| Outputs of shape `[B, T, H, V]`. | |
| final_state (torch.Tensor): | |
| Final state of shape `[N, H, K, V]` if `output_final_state=True` else `None`. | |
| Examples:: | |
| >>> import torch | |
| >>> import torch.nn.functional as F | |
| >>> from einops import rearrange | |
| >>> from fla.ops.simple_gla import fused_recurrent_simple_gla | |
| # inputs with equal lengths | |
| >>> B, T, H, K, V = 4, 2048, 4, 512, 512 | |
| >>> q = torch.randn(B, T, H, K, device='cuda') | |
| >>> k = torch.randn(B, T, H, K, device='cuda') | |
| >>> v = torch.randn(B, T, H, V, device='cuda') | |
| >>> g = F.logsigmoid(torch.randn(B, T, H, K, device='cuda')) | |
| >>> h0 = torch.randn(B, H, K, V, device='cuda') | |
| >>> o, ht = fused_recurrent_simple_gla( | |
| q, k, v, g, | |
| initial_state=h0, | |
| output_final_state=True | |
| ) | |
| # for variable-length inputs, the batch size `B` is expected to be 1 and `cu_seqlens` is required | |
| >>> q, k, v, g = map(lambda x: rearrange(x, 'b t h d -> 1 (b t) h d'), (q, k, v, g)) | |
| # for a batch with 4 sequences, `cu_seqlens` with 5 start/end positions are expected | |
| >>> cu_seqlens = q.new_tensor([0, 2048, 4096, 6144, 8192], dtype=torch.long) | |
| >>> o_var, ht_var = fused_recurrent_simple_gla( | |
| q, k, v, g, | |
| initial_state=h0, | |
| output_final_state=True, | |
| cu_seqlens=cu_seqlens | |
| ) | |
| """ | |
| if cu_seqlens is not None: | |
| if q.shape[0] != 1: | |
| raise ValueError( | |
| f"The batch size is expected to be 1 rather than {q.shape[0]} when using `cu_seqlens`." | |
| f"Please flatten variable-length inputs before processing.", | |
| ) | |
| if initial_state is not None and initial_state.shape[0] != len(cu_seqlens) - 1: | |
| raise ValueError( | |
| f"The number of initial states is expected to be equal to the number of input sequences, " | |
| f"i.e., {len(cu_seqlens) - 1} rather than {initial_state.shape[0]}.", | |
| ) | |
| if scale is None: | |
| scale = k.shape[-1] ** -0.5 | |
| o, final_state = fused_recurrent( | |
| q=q, | |
| k=k, | |
| v=v, | |
| g=g, | |
| g_gamma=g_gamma, | |
| scale=scale, | |
| initial_state=initial_state, | |
| output_final_state=output_final_state, | |
| reverse=reverse, | |
| cu_seqlens=cu_seqlens, | |
| ) | |
| return o, final_state | |