Text Generation
Transformers
Safetensors
raon1_mini
raon
mxfp8
fp8
w8a8
calibrated-kv-cache
custom-code
conversational
custom_code
Instructions to use cbert33/Raon-1-mini-preview-Calibrated with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use cbert33/Raon-1-mini-preview-Calibrated with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="cbert33/Raon-1-mini-preview-Calibrated", 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("cbert33/Raon-1-mini-preview-Calibrated", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use cbert33/Raon-1-mini-preview-Calibrated with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "cbert33/Raon-1-mini-preview-Calibrated" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "cbert33/Raon-1-mini-preview-Calibrated", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/cbert33/Raon-1-mini-preview-Calibrated
- SGLang
How to use cbert33/Raon-1-mini-preview-Calibrated 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 "cbert33/Raon-1-mini-preview-Calibrated" \ --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": "cbert33/Raon-1-mini-preview-Calibrated", "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 "cbert33/Raon-1-mini-preview-Calibrated" \ --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": "cbert33/Raon-1-mini-preview-Calibrated", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use cbert33/Raon-1-mini-preview-Calibrated with Docker Model Runner:
docker model run hf.co/cbert33/Raon-1-mini-preview-Calibrated
Download calibration-code/latent_observer.py from cbert33/Raon-1-mini-preview-Calibrated: direct link, hf CLI and curl.
- Browser
- Download file 2.55 kB
-
https://huggingface.co/cbert33/Raon-1-mini-preview-Calibrated/resolve/main/calibration-code/latent_observer.py
- Command line
-
hf download hf://cbert33/Raon-1-mini-preview-Calibrated/calibration-code/latent_observer.py
-
curl -L -o latent_observer.py https://huggingface.co/cbert33/Raon-1-mini-preview-Calibrated/resolve/main/calibration-code/latent_observer.py
2.55 kB
| """Observe the compressed MLA cache, never expanded attention K/V or RDA state.""" | |
| import torch | |
| class LatentCacheObserver: | |
| def __init__(self, attention): | |
| self.attention = attention | |
| self.maximum = 0.0 | |
| self.rows = 0 | |
| self.calls = 0 | |
| self._tail = None | |
| self.worst_row = None | |
| self.handles = [attention.kv_a_proj_with_mqa.register_forward_hook(self._projected), | |
| attention.kv_a_layernorm.register_forward_hook(self._normalized)] | |
| def _projected(self, module, inputs, output): | |
| assert output.shape[-1] == self.attention.kv_lora_rank + self.attention.qk_pe | |
| self._tail = output[..., self.attention.kv_lora_rank:] | |
| def _normalized(self, module, inputs, output): | |
| assert self._tail is not None, 'KV normalization without preceding KV projection' | |
| assert output.shape[-1] == self.attention.kv_lora_rank | |
| latent = torch.cat([output, self._tail], dim=-1) | |
| self._tail = None | |
| assert torch.isfinite(latent).all().item(), 'Nonfinite latent during calibration' | |
| flat = latent.reshape(-1, latent.shape[-1]) | |
| row_max = flat.float().abs().amax(dim=-1) | |
| value, index = row_max.max(dim=0) | |
| current = value.item() | |
| if self.worst_row is None or current > self.maximum: | |
| self.worst_row = flat[index].detach().cpu().clone() | |
| self.maximum = max(self.maximum, current) | |
| self.rows += flat.shape[0] | |
| self.calls += 1 | |
| def scale(self): | |
| assert self.calls and self._tail is None, 'Incomplete calibration observation' | |
| assert self.maximum > 0, 'No positive latent magnitude observed; refusing unit fallback' | |
| return self.maximum / torch.finfo(torch.float8_e4m3fn).max | |
| def numerical_evidence(self): | |
| scale = self.scale() | |
| original = self.worst_row.float() | |
| quantized = (original / scale).to(torch.float8_e4m3fn) | |
| restored = quantized.float() * scale | |
| assert torch.isfinite(restored).all().item() | |
| error = restored-original | |
| return {'rows': self.rows, 'calls': self.calls, 'amax': self.maximum, | |
| 'scale': scale, 'max_abs_error': error.abs().max().item(), | |
| 'mean_squared_error': error.square().mean().item(), | |
| 'clipped_values': int(((original/scale).abs() > torch.finfo(torch.float8_e4m3fn).max).sum().item())} | |
| def close(self): | |
| for handle in self.handles: | |
| handle.remove() | |
| self.handles.clear() | |
| self._tail = None | |