Run this model with HF Jobs
Run KRAFTON/Raon-1-mini-preview on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/KRAFTON/Raon-1-mini-preview. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/KRAFTON/Raon-1-mini-preview on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/KRAFTON/Raon-1-mini-preview. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/KRAFTON/Raon-1-mini-preview. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use KRAFTON/Raon-1-mini-preview with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use KRAFTON/Raon-1-mini-preview with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="KRAFTON/Raon-1-mini-preview", 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("KRAFTON/Raon-1-mini-preview", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use KRAFTON/Raon-1-mini-preview with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "KRAFTON/Raon-1-mini-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": "KRAFTON/Raon-1-mini-preview", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/KRAFTON/Raon-1-mini-preview
- SGLang
How to use KRAFTON/Raon-1-mini-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 "KRAFTON/Raon-1-mini-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": "KRAFTON/Raon-1-mini-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 "KRAFTON/Raon-1-mini-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": "KRAFTON/Raon-1-mini-preview", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use KRAFTON/Raon-1-mini-preview with Docker Model Runner:
docker model run hf.co/KRAFTON/Raon-1-mini-preview
hyogon.ryu Codex commited on
Commit ·
2ef2eb1
1
Parent(s): 8d2ced8
Support Transformers CPU offload and RTX 5090 inference
Browse filesUse forward hooks for CPU offload and add RTX 5090 instructions.
Co-authored-by: Codex <noreply@openai.com>
Signed-off-by: hyogon.ryu <hyogon.ryu@krafton.com>
Files changed (2)
- README.md+36-2
- modeling_raon1_mini.py+46-15
210 unmodified lines21121221321421521668 unmodified lines28528628728828929029129229329429529634 unmodified lines3313323333343353367 unmodified lines344345346347348349350210 unmodified lines```<summary><strong>Transformers</strong></summary>Use Hugging Face Transformers to load Raon-1 mini and generate68 unmodified linesFor coding and math, set `presence_penalty` to `0.0`.<details><summary><strong>vLLM (beta)</strong></summary>Use vLLM to serve Raon-1 mini through an OpenAI-compatible APIwith tool calling and DFlash2 speculative decoding.Tested on NVIDIA B300.Install from our fork and start the server:34 unmodified lines`KRAFTON/Raon-1-mini-preview-nvfp4` in the same command.It runs on a single GPU (tensor parallel size 1).Send a request from another terminal:```bash7 unmodified lines"content": "Tell me about KRAFTON AI."}],"max_tokens": 32768,"temperature": 1.0,"top_p": 0.95,"top_k": 20,210 unmodified lines21121221321421521621768 unmodified lines28628728828929029129229329429529629729829930030130234 unmodified lines3373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693707 unmodified lines378379380381382383384210 unmodified lines```<details><summary><strong>Transformers</strong></summary>Use Hugging Face Transformers to load Raon-1 mini and generate68 unmodified linesFor coding and math, set `presence_penalty` to `0.0`.On a 32 GB GPU, use the base MXFP8 model with `device_map="auto"`and CPU offload.</details><details><summary><strong>vLLM (beta)</strong></summary>Use vLLM to serve Raon-1 mini through an OpenAI-compatible APIwith tool calling and DFlash2 speculative decoding.Tested on NVIDIA B300. The RTX 5090 NVFP4 profile is documented below.Install from our fork and start the server:34 unmodified lines`KRAFTON/Raon-1-mini-preview-nvfp4` in the same command.It runs on a single GPU (tensor parallel size 1).### RTX 5090 (32 GB)Use the NVFP4 checkpoint with the following settings.CUDA Toolkit 13 with `nvcc` on `PATH` is required.```bash# WSL2export VLLM_WSL2_ENABLE_PIN_MEMORY=1vllm serve KRAFTON/Raon-1-mini-preview-nvfp4 \--host 127.0.0.1 --port 8000 \--served-model-name Raon-1-mini-preview \--max-model-len 32768 \--max-num-batched-tokens 2048 \--max-num-seqs 8 \--gpu-memory-utilization 0.85 \--kv-cache-dtype fp8_e4m3 \--kv-cache-memory 3221225472 \--enable-prefix-caching --async-scheduling \--spec-method dflash \--spec-model KRAFTON/Raon-1-mini-preview-dflash2 \--spec-tokens 7 \--reasoning-parser raon_1 \--enable-auto-tool-choice --tool-call-parser raon_1 \--default-chat-template-kwargs '{"enable_thinking":true,"truncate_history_thinking":false}'```Send a request from another terminal:```bash7 unmodified lines"content": "Tell me about KRAFTON AI."}],"max_tokens": 8192,"temperature": 1.0,"top_p": 0.95,"top_k": 20,
30 unmodified lines31323334353689 unmodified lines12612712812913013121 unmodified lines1531541551561571581591601611621631641651661671681 unmodified line170171172173174175176423 unmodified lines60060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963030 unmodified linesfrom torch import nnfrom transformers import initialization as initfrom transformers.generation import GenerationMixinfrom transformers.masking_utils import create_causal_maskfrom transformers.modeling_outputs import (BaseModelOutputWithPast,89 unmodified linesself.b_z = nn.Parameter(torch.zeros(m))self.eta = nn.Parameter(torch.zeros((), dtype=torch.float32))class RaonMHC(nn.Module):"""One Raon_mHC site (attention or MLP): selects the branch input from the streams and writes back.21 unmodified linesdef route(self, stream: torch.Tensor) -> tuple[torch.Tensor, torch.Tensor, torch.Tensor]:n = self.num_streamsrows = stream.shape[0] * stream.shape[1]flat = stream.reshape(rows, n * stream.shape[-1])weight = torch.cat([self.phi_pre, self.phi_post, self.res.phi_z], dim=0)# RMS scale applied AFTER the (model-dtype) selector GEMM, as in training.inv = torch.rsqrt(flat.float().pow(2).mean(-1, keepdim=True) + self.eps)z = F.linear(flat, weight.to(flat.dtype)).float() * invt_pre = self.alpha_pre.float() * z[:, :n] + self.b_pre.float()t_post = self.alpha_post.float() * z[:, n : 2 * n] + self.b_post.float()t_z = self.res.alpha_z.float() * z[:, 2 * n :] + self.res.b_z.float()h_pre = torch.sigmoid(t_pre)h_post = self.post_factor * torch.sigmoid(t_post)nm = n - 11 unmodified linee = torch.einsum("im,bmk,jk->bij", helmert, t_z.reshape(rows, nm, nm), helmert)rho = (-e / chart_b).amax(dim=(-2, -1)).clamp_min(0.0)phi = chart_b + e / (1.0 + rho)[:, None, None]gamma = torch.sigmoid(self.res.eta.float())h_res = (1.0 - gamma) * eye + gamma * phireturn h_pre, h_post, h_res423 unmodified linesreturn F.linear(hidden, weight)class Raon1MiniExpert(nn.Module):"""One routed SiTU-GLU expert: ``down_proj(situ_glu(gate_proj(x), up_proj(x)))``."""def __init__(self, config: Raon1MiniConfig) -> None:super().__init__()self.gate_proj = nn.Linear(config.hidden_size, config.moe_intermediate_size, bias=False)self.up_proj = nn.Linear(config.hidden_size, config.moe_intermediate_size, bias=False)self.down_proj = nn.Linear(config.moe_intermediate_size, config.hidden_size, bias=False)self.gate_beta = config.activation_situ_betaself.value_beta = config.activation_situ_linear_betadef forward(self, hidden: torch.Tensor) -> torch.Tensor:act = situ_glu(routed_linear(self.gate_proj, hidden),routed_linear(self.up_proj, hidden),self.gate_beta,self.value_beta,)return routed_linear(self.down_proj, act.to(hidden.dtype))class Raon1MiniRouter(nn.Module):30 unmodified lines313233343536373889 unmodified lines12812913013113213313413513621 unmodified lines1581591601611621631641651661671681691701711721731741751761771781791 unmodified line181182183184185186187423 unmodified lines61161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066130 unmodified linesfrom torch import nnfrom transformers import initialization as initfrom transformers.generation import GenerationMixinfrom transformers.integrations.finegrained_fp8 import FP8Linearfrom transformers.utils.quantization_config import FineGrainedFP8Configfrom transformers.masking_utils import create_causal_maskfrom transformers.modeling_outputs import (BaseModelOutputWithPast,89 unmodified linesself.b_z = nn.Parameter(torch.zeros(m))self.eta = nn.Parameter(torch.zeros((), dtype=torch.float32))def forward(self) -> tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor]:return self.phi_z, self.alpha_z, self.b_z, self.etaclass RaonMHC(nn.Module):"""One Raon_mHC site (attention or MLP): selects the branch input from the streams and writes back.21 unmodified linesdef route(self, stream: torch.Tensor) -> tuple[torch.Tensor, torch.Tensor, torch.Tensor]:return self(stream)def forward(self, stream: torch.Tensor) -> tuple[torch.Tensor, torch.Tensor, torch.Tensor]:phi_z, alpha_z, b_z, eta = self.res()n = self.num_streamsrows = stream.shape[0] * stream.shape[1]flat = stream.reshape(rows, n * stream.shape[-1])weight = torch.cat([self.phi_pre, self.phi_post, phi_z], dim=0)# RMS scale applied AFTER the (model-dtype) selector GEMM, as in training.inv = torch.rsqrt(flat.float().pow(2).mean(-1, keepdim=True) + self.eps)z = F.linear(flat, weight.to(flat.dtype)).float() * invt_pre = self.alpha_pre.float() * z[:, :n] + self.b_pre.float()t_post = self.alpha_post.float() * z[:, n : 2 * n] + self.b_post.float()t_z = alpha_z.float() * z[:, 2 * n :] + b_z.float()h_pre = torch.sigmoid(t_pre)h_post = self.post_factor * torch.sigmoid(t_post)nm = n - 11 unmodified linee = torch.einsum("im,bmk,jk->bij", helmert, t_z.reshape(rows, nm, nm), helmert)rho = (-e / chart_b).amax(dim=(-2, -1)).clamp_min(0.0)phi = chart_b + e / (1.0 + rho)[:, None, None]gamma = torch.sigmoid(eta.float())h_res = (1.0 - gamma) * eye + gamma * phireturn h_pre, h_post, h_res423 unmodified linesreturn F.linear(hidden, weight)class Raon1MiniRoutedLinear(nn.Linear):def forward(self, hidden: torch.Tensor) -> torch.Tensor:return routed_linear(self, hidden)class Raon1MiniMXFP8Linear(FP8Linear):def forward(self, hidden: torch.Tensor) -> torch.Tensor:return routed_linear(self, hidden)def _routed_projection(config: Raon1MiniConfig, in_features: int, out_features: int) -> nn.Linear:quantization = getattr(config, "quantization_config", None)if isinstance(quantization, dict):quantization = FineGrainedFP8Config.from_dict(quantization)if getattr(quantization, "quant_method", None) == "mxfp8":if not quantization.dequantize:return Raon1MiniMXFP8Linear(in_features, out_features,block_size=quantization.weight_block_size,activation_scheme=quantization.activation_scheme,scale_fmt="ue8m0",has_bias=False,)return Raon1MiniRoutedLinear(in_features, out_features, bias=False)class Raon1MiniExpert(nn.Module):"""One routed SiTU-GLU expert: ``down_proj(situ_glu(gate_proj(x), up_proj(x)))``."""def __init__(self, config: Raon1MiniConfig) -> None:super().__init__()self.gate_proj = _routed_projection(config, config.hidden_size, config.moe_intermediate_size)self.up_proj = _routed_projection(config, config.hidden_size, config.moe_intermediate_size)self.down_proj = _routed_projection(config, config.moe_intermediate_size, config.hidden_size)self.gate_beta = config.activation_situ_betaself.value_beta = config.activation_situ_linear_betadef forward(self, hidden: torch.Tensor) -> torch.Tensor:act = situ_glu(self.gate_proj(hidden),self.up_proj(hidden),self.gate_beta,self.value_beta,)return self.down_proj(act.to(hidden.dtype))class Raon1MiniRouter(nn.Module):
README.md+36-2
modeling_raon1_mini.py+46-15