Instructions to use tiny-random/kimi-k3.1-pro with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use tiny-random/kimi-k3.1-pro with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="tiny-random/kimi-k3.1-pro", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForSeq2SeqLM model = AutoModelForSeq2SeqLM.from_pretrained("tiny-random/kimi-k3.1-pro", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use tiny-random/kimi-k3.1-pro with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "tiny-random/kimi-k3.1-pro" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "tiny-random/kimi-k3.1-pro", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/tiny-random/kimi-k3.1-pro
- SGLang
How to use tiny-random/kimi-k3.1-pro 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 "tiny-random/kimi-k3.1-pro" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "tiny-random/kimi-k3.1-pro", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "tiny-random/kimi-k3.1-pro" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "tiny-random/kimi-k3.1-pro", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use tiny-random/kimi-k3.1-pro with Docker Model Runner:
docker model run hf.co/tiny-random/kimi-k3.1-pro
Pack MXFP4 nibbles along the row, not across groups
#2
by akopytko - opened
- .meta/create_model.py +1 -0
.meta/create_model.py
CHANGED
|
@@ -307,6 +307,7 @@ def create_model(source_model_id: str, source_revision: str, save_folder: str) -
|
|
| 307 |
normalized = (blocks / scales.unsqueeze(-1)).clamp(-6, 6)
|
| 308 |
codes = torch.bucketize(normalized.abs(), fp4_boundaries)
|
| 309 |
codes += normalized.signbit() * 8
|
|
|
|
| 310 |
state_dict[name.removesuffix(".weight") + ".weight_packed"] = (codes[:, ::2] | (codes[:, 1::2] << 4)).to(
|
| 311 |
torch.uint8
|
| 312 |
)
|
|
|
|
| 307 |
normalized = (blocks / scales.unsqueeze(-1)).clamp(-6, 6)
|
| 308 |
codes = torch.bucketize(normalized.abs(), fp4_boundaries)
|
| 309 |
codes += normalized.signbit() * 8
|
| 310 |
+
codes = codes.view(out_features, in_features)
|
| 311 |
state_dict[name.removesuffix(".weight") + ".weight_packed"] = (codes[:, ::2] | (codes[:, 1::2] << 4)).to(
|
| 312 |
torch.uint8
|
| 313 |
)
|