-
Notifications
You must be signed in to change notification settings - Fork 12.4k
Model : Add support for Kimi-K2 #14654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
38d5910
bf674c3
d80d7fc
f8a6430
7e5d0ee
5d10e3a
30c5840
273ea09
4def063
b023e53
ecb345f
6fda4fe
29c1532
6ef6aa1
02f4a63
5a730ae
73dcb44
d2211e0
a57870d
0a5704b
459df19
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{%- if tools -%} | ||
<|im_system|>tool_declare<|im_middle|>{{ tools | tojson }}<|im_end|> | ||
{%- endif -%} | ||
{%- for message in messages -%} | ||
{%- if loop.first and messages[0]['role'] != 'system' -%} | ||
<|im_system|>system<|im_middle|>You are a helpful assistant<|im_end|> | ||
{%- endif -%} | ||
{%- if message['role'] == 'system' -%} | ||
<|im_system|>system<|im_middle|> | ||
{%- elif message['role'] == 'user' -%} | ||
<|im_user|>user<|im_middle|> | ||
{%- elif message['role'] == 'assistant' -%} | ||
<|im_assistant|>assistant<|im_middle|> | ||
{%- elif message['role'] == 'tool' -%} | ||
<|im_system|>tool<|im_middle|> | ||
{%- endif -%} | ||
{%- if message['role'] == 'assistant' and message.get('tool_calls') -%} | ||
{%- if message['content'] -%}{{ message['content'] }}{%- endif -%} | ||
<|tool_calls_section_begin|> | ||
{%- for tool_call in message['tool_calls'] -%} | ||
{%- set func_name = tool_call['function']['name'] -%} | ||
{%- set formatted_id = 'functions.' + func_name + ':' + loop.index0|string -%} | ||
<|tool_call_begin|>{{ formatted_id }}<|tool_call_argument_begin|>{{ tool_call['function']['arguments'] | tojson}}<|tool_call_end|> | ||
{%- endfor -%} | ||
<|tool_calls_section_end|> | ||
{%- elif message['role'] == 'tool' -%} | ||
## Return of {{ message.tool_call_id }}\n{{ message['content'] }} | ||
{%- elif message['content'] is string -%} | ||
{{ message['content'] }} | ||
{%- elif message['content'] is not none -%} | ||
{% for content in message['content'] -%} | ||
{% if content['type'] == 'image' or 'image' in content or 'image_url' in content -%} | ||
<|media_start|>image<|media_content|><|media_pad|><|media_end|> | ||
{% else -%} | ||
{{ content['text'] }} | ||
{%- endif -%} | ||
{%- endfor -%} | ||
{%- endif -%} | ||
<|im_end|> | ||
{%- endfor -%} | ||
{%- if add_generation_prompt -%} | ||
<|im_assistant|>assistant<|im_middle|> | ||
{%- endif -%} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
|
||
// bump if necessary | ||
#define LLAMA_MAX_LAYERS 512 | ||
#define LLAMA_MAX_EXPERTS 256 // DeepSeekV3 | ||
#define LLAMA_MAX_EXPERTS 384 // Kimi-K2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By the way does @CISC or @gabriellarson not sure if you know, does this affect perf? I don't think so from first glance, but does it change things inside of llama.cpp's MoE handling? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assumed not, given that it says "bump if necessary", I'm not 100% sure though There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's fine, it has no other runtime implication than passing an assert. |
||
|
||
enum llama_expert_gating_func_type { | ||
LLAMA_EXPERT_GATING_FUNC_TYPE_NONE = 0, | ||
|
Uh oh!
There was an error while loading. Please reload this page.