Text Generation
Transformers
Safetensors
inkling_mm_model
image-text-to-text
amd-quark
mxfp4
rocm
tokenspeed
conversational
8-bit precision
quark
Instructions to use biosai-hf/Inkling-MXFP4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use biosai-hf/Inkling-MXFP4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="biosai-hf/Inkling-MXFP4") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("biosai-hf/Inkling-MXFP4") model = AutoModelForMultimodalLM.from_pretrained("biosai-hf/Inkling-MXFP4", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use biosai-hf/Inkling-MXFP4 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "biosai-hf/Inkling-MXFP4" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "biosai-hf/Inkling-MXFP4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/biosai-hf/Inkling-MXFP4
- SGLang
How to use biosai-hf/Inkling-MXFP4 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 "biosai-hf/Inkling-MXFP4" \ --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": "biosai-hf/Inkling-MXFP4", "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 "biosai-hf/Inkling-MXFP4" \ --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": "biosai-hf/Inkling-MXFP4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use biosai-hf/Inkling-MXFP4 with Docker Model Runner:
docker model run hf.co/biosai-hf/Inkling-MXFP4
Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
base_model:
|
| 4 |
+
- thinkingmachines/Inkling
|
| 5 |
+
library_name: transformers
|
| 6 |
+
pipeline_tag: text-generation
|
| 7 |
+
tags:
|
| 8 |
+
- amd-quark
|
| 9 |
+
- mxfp4
|
| 10 |
+
- rocm
|
| 11 |
+
- tokenspeed
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
# Inkling-MXFP4
|
| 15 |
+
|
| 16 |
+
## Model Overview
|
| 17 |
+
|
| 18 |
+
- **Model Architecture:** Thinking Machines Lab Inkling
|
| 19 |
+
- **Input:** Text, Image, Audio
|
| 20 |
+
- **Output:** Text
|
| 21 |
+
- **Inference Engine:** [TokenSpeed](https://github.com/lightseekorg/tokenspeed)
|
| 22 |
+
- **Model Optimizer:** [AMD Quark](https://github.com/amd/quark) (0.12.post1+rocm72.torch2.11)
|
| 23 |
+
- **Quantized layers:** MoE routed experts only
|
| 24 |
+
- **Weight quantization:** OCP MXFP4, static
|
| 25 |
+
- **Activation quantization:** OCP MXFP4, dynamic
|
| 26 |
+
|
| 27 |
+
This model was built by applying AMD Quark MXFP4 quantization to the BF16 Thinking Machines Lab Inkling checkpoint. The quantization targets the MoE routed experts, while attention layers and shared experts are kept in BF16.
|
| 28 |
+
|
| 29 |
+
## Environment
|
| 30 |
+
|
| 31 |
+
The quantization workflow was prepared on an AMD gfx950 system. The inspected container environment was:
|
| 32 |
+
|
| 33 |
+
- **GPU:** AMD MI350/MI355
|
| 34 |
+
- **Target graphics version:** gfx950
|
| 35 |
+
- **ROCm:** 7.2.1
|
| 36 |
+
- **amdgpu driver:** 6.16.13
|
| 37 |
+
- **OS:** Linux 6.8.0-84, x86_64
|
| 38 |
+
- **Python:** 3.12.3
|
| 39 |
+
- **PyTorch:** 2.13.0+rocm7.1
|
| 40 |
+
- **AMD Quark:** 0.12.post1+rocm72.torch2.11
|
| 41 |
+
- **Safetensors:** 0.8.0
|
| 42 |
+
- **Transformers:** 5.13.1
|
| 43 |
+
|
| 44 |
+
Create and activate the Quark environment:
|
| 45 |
+
|
| 46 |
+
```bash
|
| 47 |
+
python3 -m venv ~/.venv-quark
|
| 48 |
+
source ~/.venv-quark/bin/activate
|
| 49 |
+
```
|
| 50 |
+
|
| 51 |
+
Install the required packages:
|
| 52 |
+
|
| 53 |
+
```bash
|
| 54 |
+
python -m pip install torch torchvision --index-url https://download.pytorch.org/whl/rocm7.1
|
| 55 |
+
python -m pip install amd-quark --extra-index-url https://pypi.amd.com/quark/rocm72/simple
|
| 56 |
+
python -m pip install safetensors transformers accelerate tqdm
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
## Model Quantization
|
| 60 |
+
|
| 61 |
+
The model was quantized with the Quark file-to-file flow. This avoids loading the full BF16 checkpoint into GPU memory at once, which is important for very large MoE checkpoints. Run the quantization script:
|
| 62 |
+
|
| 63 |
+
```bash
|
| 64 |
+
python quantize_quark.py \
|
| 65 |
+
--model_dir /path/to/model \
|
| 66 |
+
--output_dir /path/to/output \
|
| 67 |
+
--quant_scheme mxfp4 \
|
| 68 |
+
--file2file_quantization
|
| 69 |
+
```
|
| 70 |
+
|
| 71 |
+
The script applies the model-specific exclusion policy automatically in file-to-file mode. The resulting checkpoint stores MXFP4 routed-expert weights and scales while preserving non-routed-expert components in BF16.
|
| 72 |
+
|
| 73 |
+
## Deployment
|
| 74 |
+
|
| 75 |
+
This model can be served with [TokenSpeed](https://github.com/lightseekorg/tokenspeed):
|
| 76 |
+
|
| 77 |
+
```bash
|
| 78 |
+
tokenspeed serve \
|
| 79 |
+
--model lightseekorg/Inkling-MXFP4 \
|
| 80 |
+
--attn-tp-size 4 \
|
| 81 |
+
--moe-tp-size 4 \
|
| 82 |
+
--max-model-len 81920 \
|
| 83 |
+
--max-num-seqs 16 \
|
| 84 |
+
--max-prefill-tokens 8192 \
|
| 85 |
+
--chunked-prefill-size 8192 \
|
| 86 |
+
--gpu-memory-utilization 0.95 \
|
| 87 |
+
--disable-cuda-graph-padding \
|
| 88 |
+
--trust-remote-code \
|
| 89 |
+
--dtype bfloat16 \
|
| 90 |
+
--disable-kvstore \
|
| 91 |
+
--kvstore-ratio 0 \
|
| 92 |
+
--block-size 128 \
|
| 93 |
+
--host 127.0.0.1 \
|
| 94 |
+
--port 22015
|
| 95 |
+
```
|
| 96 |
+
|
| 97 |
+
## Evaluation
|
| 98 |
+
|
| 99 |
+
The following validation results are placeholders and will be updated before public release.
|
| 100 |
+
|
| 101 |
+
| Benchmark | BF16 Reference | MXFP4 |
|
| 102 |
+
| --- | ---: | ---: |
|
| 103 |
+
| BFCL exact calls | 78.3% | 79.1% |
|
| 104 |
+
| BFCL all-live macro | 75.4% | 75.3% |
|
| 105 |
+
| MMAU | 77.2% | 76.0% |
|
| 106 |
+
| GPQA Diamond | 88.1% | 85.4% |
|
| 107 |
+
| AIME26 | 96.4% | 96.7% |
|