An open source implementation of the Kimi K2 Reasoning model architecture in pure PyTorch
Project description
Open-Kimi-K2-Thinking
This repository is a straightforward attempt to implement the base Kimi K2 Reasoning model architecture in pure PyTorch as simply as possible.
Example
from open_kimi.model import KimiK2
import torch
if __name__ == "__main__":
model = KimiK2(
dim=512,
depth=2,
attention_heads=8,
experts=16,
experts_per_token=4,
seq_len=1024,
lite_verison=True,
vocab_size=10000,
)
x = torch.randint(0, 10000, (2, 1024))
out = model(x)
print(out)
Full Example
from open_kimi.model import KimiK2
import torch
if __name__ == "__main__":
model = KimiK2(
dim=7168,
depth=61,
attention_heads=64,
experts=384,
experts_per_token=8,
seq_len=1024,
lite_verison=False,
vocab_size=160000,
)
x = torch.randint(0, 10000, (2, 7168))
out = model(x)
print(out)
Post Training
On the model huggingface page, they mention they use Native INT4 Quantization in the post training phase. So I would say a good post training recipe would include:
- Native INT4 Quantization
- MUON Optimizer
- GRPO
Citation
@misc{moonshot-kimi-k2,
title={Kimi K2 Thinking},
author={Moonshot AI},
year={2024},
howpublished={\url{https://huggingface.co/moonshotai/Kimi-K2-Thinking}}
}
Acknowledgments
This implementation is based on the architecture specifications published by Moonshot AI for the Kimi K2 Thinking model. Special thanks to the Moonshot AI team for making the model architecture details publicly available.
Contact
For questions, issues, or contributions, please open an issue on the repository or contact the maintainers.
Note: This is an independent implementation based on publicly available specifications. It is not affiliated with or endorsed by Moonshot AI. For production use, please refer to the official model repository and weights.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file open_kimi-0.1.0.tar.gz.
File metadata
- Download URL: open_kimi-0.1.0.tar.gz
- Upload date:
- Size: 14.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.12.3 Darwin/24.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba982ac5bcaa4fccf965f30f40c75d662568bd013576c42929415f0513dbae41
|
|
| MD5 |
8006ca9062d5b7cdbe26b610bd87875a
|
|
| BLAKE2b-256 |
1c7b736475ad5c51efff8ff267cc8e3b88d4fdb4c310d2615e0f359bfb7d0d67
|
File details
Details for the file open_kimi-0.1.0-py3-none-any.whl.
File metadata
- Download URL: open_kimi-0.1.0-py3-none-any.whl
- Upload date:
- Size: 16.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.12.3 Darwin/24.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35c50479e66752f26504c2857310ac2ce1cf09e8352c0fdeb582985ec59081bc
|
|
| MD5 |
889739cb5b9e12706d1aa303c2b4c909
|
|
| BLAKE2b-256 |
4b6ea507f652cb4e1bb0a0b7622d578685eeb36343864c28715d2e7a1c4488cc
|