Text Generation
Transformers
Safetensors
ouro
looped-language-model
reasoning
recurrent-depth
thinking
chain-of-thought
conversational
custom_code
Instructions to use ByteDance/Ouro-2.6B-Thinking with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ByteDance/Ouro-2.6B-Thinking with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ByteDance/Ouro-2.6B-Thinking", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("ByteDance/Ouro-2.6B-Thinking", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use ByteDance/Ouro-2.6B-Thinking with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ByteDance/Ouro-2.6B-Thinking" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ByteDance/Ouro-2.6B-Thinking", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/ByteDance/Ouro-2.6B-Thinking
- SGLang
How to use ByteDance/Ouro-2.6B-Thinking 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 "ByteDance/Ouro-2.6B-Thinking" \ --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": "ByteDance/Ouro-2.6B-Thinking", "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 "ByteDance/Ouro-2.6B-Thinking" \ --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": "ByteDance/Ouro-2.6B-Thinking", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use ByteDance/Ouro-2.6B-Thinking with Docker Model Runner:
docker model run hf.co/ByteDance/Ouro-2.6B-Thinking
Fix UniversalTransformerCache.get_mask_sizes for batched generation
#8
by KristianS7 - opened
- modeling_ouro.py +22 -0
modeling_ouro.py
CHANGED
|
@@ -195,6 +195,28 @@ class UniversalTransformerCache(Cache):
|
|
| 195 |
return 0
|
| 196 |
return cached.shape[2]
|
| 197 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 198 |
def get_max_length(self) -> Optional[int]:
|
| 199 |
return None
|
| 200 |
|
|
|
|
| 195 |
return 0
|
| 196 |
return cached.shape[2]
|
| 197 |
|
| 198 |
+
def get_mask_sizes(
|
| 199 |
+
self, cache_position: torch.Tensor, layer_idx: int = 0
|
| 200 |
+
) -> tuple[int, int]:
|
| 201 |
+
"""Return (kv_length, kv_offset) for attention mask creation.
|
| 202 |
+
|
| 203 |
+
The inherited ``Cache.get_mask_sizes`` falls back to
|
| 204 |
+
``(cache_position.shape[0], 0)`` when ``layer_idx >= len(self.layers)``.
|
| 205 |
+
Because ``UniversalTransformerCache`` manages its own flat
|
| 206 |
+
``key_cache`` / ``value_cache`` lists and keeps ``self.layers`` empty,
|
| 207 |
+
the fallback always fires. During the prefill step this happens to be
|
| 208 |
+
correct (``cache_position`` spans the full input), but during
|
| 209 |
+
autoregressive decoding ``cache_position`` has length 1, so the mask is
|
| 210 |
+
built for ``kv_length=1`` instead of ``cached_length + 1``. As a
|
| 211 |
+
result the 4D attention mask is too small and padding information is
|
| 212 |
+
lost, corrupting batched generation for every sequence except the
|
| 213 |
+
longest (unpadded) one.
|
| 214 |
+
"""
|
| 215 |
+
query_length = cache_position.shape[0]
|
| 216 |
+
seq_length = self.get_seq_length(layer_idx)
|
| 217 |
+
kv_length = seq_length + query_length
|
| 218 |
+
return kv_length, 0
|
| 219 |
+
|
| 220 |
def get_max_length(self) -> Optional[int]:
|
| 221 |
return None
|
| 222 |
|