Text Generation
Transformers
Safetensors
k2_horizon
compressed-tensors
quantized
int4
w4a16
Mixture of Experts
mova
k2-horizon
vllm
conversational
custom_code
Instructions to use schoggie/K2-Horizon-MoVA-36B-A4B-W4A16 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use schoggie/K2-Horizon-MoVA-36B-A4B-W4A16 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="schoggie/K2-Horizon-MoVA-36B-A4B-W4A16", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("schoggie/K2-Horizon-MoVA-36B-A4B-W4A16", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use schoggie/K2-Horizon-MoVA-36B-A4B-W4A16 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "schoggie/K2-Horizon-MoVA-36B-A4B-W4A16" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "schoggie/K2-Horizon-MoVA-36B-A4B-W4A16", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/schoggie/K2-Horizon-MoVA-36B-A4B-W4A16
- SGLang
How to use schoggie/K2-Horizon-MoVA-36B-A4B-W4A16 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 "schoggie/K2-Horizon-MoVA-36B-A4B-W4A16" \ --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": "schoggie/K2-Horizon-MoVA-36B-A4B-W4A16", "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 "schoggie/K2-Horizon-MoVA-36B-A4B-W4A16" \ --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": "schoggie/K2-Horizon-MoVA-36B-A4B-W4A16", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use schoggie/K2-Horizon-MoVA-36B-A4B-W4A16 with Docker Model Runner:
docker model run hf.co/schoggie/K2-Horizon-MoVA-36B-A4B-W4A16
| --- k2_horizon_vllm/a/b/k2_horizon_vllm/model.py 2026-09-11 16:37:11.117266779 +0200 | |
| +++ b/k2_horizon_vllm/model.py 2026-09-11 16:37:11.127324227 +0200 | |
| LayerNorms are GROUPED RMSNorm (layernorm_num_groups). Attention has a softplus output gate. | |
| """ | |
| import math | |
| +import os | |
| from collections.abc import Iterable | |
| import torch | |
| # All routed value experts fused into ONE quantized (4-bit Marlin) projection: | |
| # hidden -> [E * kv_dim]. Keeps experts 4-bit (~4 GB, not 15 GB BF16) AND computes | |
| # all experts in a single Marlin GEMM (cudagraph-safe, bandwidth-cheap). | |
| + # IFM's own quantized checkpoints leave MoVA in full precision, so a correct | |
| + # checkpoint has no Marlin qweight here. K2_MOVA_BF16=1 keeps this layer bf16. | |
| + self._mova_bf16 = os.environ.get("K2_MOVA_BF16", "0") == "1" | |
| self.v_experts_fused = MergedColumnParallelLinear( | |
| config.hidden_size, [self.kv_dim] * config.mova_num_experts, bias=False, | |
| - quant_config=quant_config, prefix=f"{prefix}.v_experts_fused") | |
| + quant_config=None if self._mova_bf16 else quant_config, | |
| + prefix=f"{prefix}.v_experts_fused") | |
| self._vq = None # lazy-built per-expert Marlin MoE weights (see _setup_sparse) | |
| def _mova_value(self, hidden_states): | |
| weights = weights * self.router_scaling_factor | |
| weights = weights.to(hidden_states.dtype) | |
| + if getattr(self, "_mova_bf16", False): | |
| + # Dense bf16: compute all experts, then gather the selected top-k. | |
| + T = hidden_states.shape[0] | |
| + E, N = self.mova_num_experts, self.kv_dim | |
| + allv = F.linear(hidden_states, self.v_experts_fused.weight) # [T, E*N] | |
| + allv = F.silu(allv).view(T, E, N) | |
| + idx = selected.unsqueeze(-1).expand(-1, -1, N) # [T, tk, N] | |
| + sel_v = torch.gather(allv, 1, idx) # [T, tk, N] | |
| + v = (sel_v * weights.unsqueeze(-1)).sum(dim=1) # [T, N] | |
| + return v.to(hidden_states.dtype) | |
| + | |
| # SPARSE 4-bit Marlin MoE over only the top-k value experts. Reuses the fused | |
| # Marlin weights (reshaped to per-expert MoE layout). Reads top-4/64 -> fast. | |
| if self._vq is None: | |