Add new model: Kimi2-6
Author: zucchini-nlp
Pull request: yes
Labels: name: New model

<!-- ci-dashboard-badge:start -->
[![CI](https://transformers-ci.lor-e.huggingface.cool/badge/pr?pr=45630)](https://transformers-ci.lor-e.huggingface.cool/d/pytest-observability-by-pr/pytest-observability-branch?var-pr=45630)
<!-- ci-dashboard-badge:end -->

# What does this PR do?

The moonshot team is not very active and haven't yet replied, so I kept all the `model_type` naming to match the remote code. That allows us to load a model with local code. There are still a few problems such as tokenizer needing conversion and jinja chat template being non-consistent though

They have saved a tiktoken tokeninzer and tbh I am not sure if we can convert it, and nudge them to update. So as a workaround we convert from tiktoken at load-time

Tested with below script but uses a smaller/dummy model. Logits and eager generation are equivalent with official implementation.

```python
import torch
from transformers import AutoProcessor, AutoTokenizer, AutoModelForImageTextToText

processor = AutoProcessor.from_pretrained('moonshotai/Kimi-K2.6', trust_remote_code=False)
model = AutoModelForImageTextToText.from_pretrained(
    'moonshotai/Kimi-K2.6',
    dtype=torch.bfloat16,
    device_map="cuda:0",
    trust_remote_code=False,
    attn_implementation="eager",
)


messages = [
    {
        "role": "user",
        "content": [
            {"type": "image", "image": "image.png"},
            # {"type": "video", "video_url":{"url"  "video.mp4"}}, # note that videos need different layout due to jinja template
            {"type": "text", "text": "What is shown in this image?"},
        ],
    }
]

inputs = processor.apply_chat_template(
    messages,
    tokenize=True,
    add_generation_prompt=True,
    return_tensors="pt",
    return_dict=True,
).to(device=model.device, dtype=torch.bfloat16)

generated_ids = model.generate(**inputs, max_new_tokens=64)
generated_text = processor.batch_decode(generated_ids[:, inputs["input_ids"].shape[-1]:], skip_special_tokens=True)[0]
print(generated_text)
```

Comments:
Oke, I think the model part looks same as the custom code, though I didn't test it. Also we need to check what is the exact chat template format and how to add `placeholder` tokens per modality, again with the real checkpoint

Kimi team might reply on Monday, coming back then

View the CircleCI Test Summary for this PR:

https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=45630&sha=db102b

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_45630). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

run-slow: kimi_k25

[Workflow Run ⚙️](https://github.com/huggingface/transformers/actions/runs/28656414524)

This comment contains `run-slow`, running the specified jobs: 

models: ["models/kimi_k25"]
quantizations: []

run-slow: kimi_k25


run-slow: kimi_k25



run-slow: kimi_k25

[Workflow Run ⚙️](https://github.com/huggingface/transformers/actions/runs/28665319247)

This comment contains `run-slow`, running the specified jobs: 

models: ["models/kimi_k25"]
quantizations: []

## CI Results
[Workflow Run ⚙️](https://github.com/huggingface/transformers/actions/runs/28665319247)

### Commit Info
| Context | Commit | Description |
|---------|--------|-------------|
| RUN | [487da00f](https://github.com/huggingface/transformers/commit/487da00f4207d01c7654af91f692dbdf7843a58f) | workflow commit (merge commit) |
| PR | [0a1fcd4d](https://github.com/zucchini-nlp/transformers/commit/0a1fcd4dcfccdc860fa093a7ebb321ce66d7afce) | branch commit (from PR) |
| main | [5d063058](https://github.com/huggingface/transformers/commit/5d063058dc2ddae5e31e4fab1985701d5cf50133) | base commit (on `main`) |

### Model CI Report

❌ **[4 new failed tests from this PR](https://huggingface.co/datasets/hf-internal-testing/transformers_pr_ci/raw/669433019b8eadcda8a0429e8e79eae3421e4efc/2026-07-03/runs/37272-28665319247/ci_results_run_models_gpu/new_failures_with_bad_commit.json)** 😭

- [kimi_k25](https://github.com/huggingface/transformers/actions/runs/28665319247/job/85016657516):
    tests/models/kimi_k25/test_modeling_kimi_k25.py::Kimi_K25ModelTest::test_generate_compilation_all_outputs (✅ ⟹ ❌)
    tests/models/kimi_k25/test_modeling_kimi_k25.py::Kimi_K25ModelTest::test_generate_compile_model_forward_fullgraph (✅ ⟹ ❌)
    tests/models/kimi_k25/test_modeling_kimi_k25.py::Kimi_K25ModelTest::test_generate_from_inputs_embeds_with_static_cache (✅ ⟹ ❌)
    tests/models/kimi_k25/test_modeling_kimi_k25.py::Kimi_K25ModelTest::test_generate_with_static_cache (✅ ⟹ ❌)



<!-- ci-dashboard-recap:start -->

---

### CI recap

**Dashboard:** [View test results in Grafana](https://transformers-ci.lor-e.huggingface.cool/d/pytest-observability-by-pr/pytest-observability-branch?var-pr=45630)
**Latest run:** [28667688910:1](https://github.com/huggingface/transformers/actions/runs/28667688910)
**Result:** `failure` | **Jobs:** 15 | **Tests:** 171,114 | **Failures:** 1 | **Duration:** 25h 54m

<!-- ci-dashboard-recap:end -->

**[For maintainers]** Suggested jobs to run (before merge)

run-slow: auto, kimi_k25