Instructions to use XHToken/Spark-X2.6-4B-Base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use XHToken/Spark-X2.6-4B-Base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="XHToken/Spark-X2.6-4B-Base", 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("XHToken/Spark-X2.6-4B-Base", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use XHToken/Spark-X2.6-4B-Base with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "XHToken/Spark-X2.6-4B-Base" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "XHToken/Spark-X2.6-4B-Base", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/XHToken/Spark-X2.6-4B-Base
- SGLang
How to use XHToken/Spark-X2.6-4B-Base 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 "XHToken/Spark-X2.6-4B-Base" \ --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": "XHToken/Spark-X2.6-4B-Base", "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 "XHToken/Spark-X2.6-4B-Base" \ --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": "XHToken/Spark-X2.6-4B-Base", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use XHToken/Spark-X2.6-4B-Base with Docker Model Runner:
docker model run hf.co/XHToken/Spark-X2.6-4B-Base
CMF build of Spark-X2.6-4B for cortiq (Metal / Vulkan / CPU, single file)
Hi XHToken team, thanks for Spark-X2.6!
I've added Spark-X2.6-4B support to cortiq, a Rust inference engine with no Python and no ML framework, and published the converted weights of Spark-X2.6-4B (the post-trained model built on this base) as single CMF files: https://huggingface.co/infosave/Spark-X2.6-4B-cmf
The whole architecture runs natively: 9 full-attention + 27 sliding-window (512) layers, exact-GELU FFN, tied head, 1M-token context, thinking mode and tool calling through the embedded chat template. GPUs: NVIDIA / AMD / Intel through Vulkan or DX12, Apple silicon through Metal; the CPU as well.
Files (quantized from the bf16 checkpoint)
| file | size | wikitext-2 ppl |
|---|---|---|
spark-x2.6-4b-q8_2f.cmf (8-bit, default) |
4.14 GB | 10.71 |
spark-x2.6-4b-q4tp.cmf (4-bit) |
2.16 GB | 11.88 |
ppl: first 4096 tokens of wikitext-2 test, BOS in front, cortiq ppl --tokens 4096.
Decode speed, one stream, tok/s
| hardware | backend | q8_2f | q4tp |
|---|---|---|---|
| RTX 2000 Ada 16 GB | Vulkan | 41.5 | 67.2 |
| Mac mini M4 24 GB | Metal | 20.1 | 34.8 |
| Xeon E5-2699 v4, 6 cores | CPU | 4.5 | 4.8 |
Prompt processing at 1,000 tokens: 370 / 351 tok/s on the RTX 2000 Ada, 286 / 244 tok/s on the M4 (q8_2f / q4tp).
Long context: the sliding layers keep only their window, so the KV state is ~72 KB per token (1.24 GiB at 16k tokens). cortiq serve exposes an OpenAI-compatible API, and each chat turn prefills only what changed: with a 2,300-token history the next turn starts in ~0.6 s on the M4.
Try it
cargo install cortiq-cli
hf download infosave/Spark-X2.6-4B-cmf spark-x2.6-4b-q8_2f.cmf --local-dir .
cortiq run spark-x2.6-4b-q8_2f.cmf --prompt "Explain quicksort in three sentences." --no-think
Prebuilt binaries for Linux, macOS and Windows: https://github.com/infosave2007/cmf/releases (cortiq 0.8.43 or later). The weights stay under your Apache-2.0 terms.
Feedback welcome!