Text Generation
Transformers
Safetensors
glm_moe_dsa
compressed-tensors
llm-compressor
nvfp4
mtp
speculative-decoding
conversational
8-bit precision
Instructions to use soyrsoyr/GLM-5.3-MTP-NVFP4-Test-Fixture with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use soyrsoyr/GLM-5.3-MTP-NVFP4-Test-Fixture with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="soyrsoyr/GLM-5.3-MTP-NVFP4-Test-Fixture") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("soyrsoyr/GLM-5.3-MTP-NVFP4-Test-Fixture") model = AutoModelForCausalLM.from_pretrained("soyrsoyr/GLM-5.3-MTP-NVFP4-Test-Fixture", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.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=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use soyrsoyr/GLM-5.3-MTP-NVFP4-Test-Fixture with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "soyrsoyr/GLM-5.3-MTP-NVFP4-Test-Fixture" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "soyrsoyr/GLM-5.3-MTP-NVFP4-Test-Fixture", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/soyrsoyr/GLM-5.3-MTP-NVFP4-Test-Fixture
- SGLang
How to use soyrsoyr/GLM-5.3-MTP-NVFP4-Test-Fixture 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 "soyrsoyr/GLM-5.3-MTP-NVFP4-Test-Fixture" \ --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": "soyrsoyr/GLM-5.3-MTP-NVFP4-Test-Fixture", "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 "soyrsoyr/GLM-5.3-MTP-NVFP4-Test-Fixture" \ --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": "soyrsoyr/GLM-5.3-MTP-NVFP4-Test-Fixture", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use soyrsoyr/GLM-5.3-MTP-NVFP4-Test-Fixture with Docker Model Runner:
docker model run hf.co/soyrsoyr/GLM-5.3-MTP-NVFP4-Test-Fixture
Replace fixture with GLM-5.3-derived NVFP4 MTP model
Browse files- README.md +67 -23
- chat_template.jinja +160 -24
- config.json +56 -24
- generation_config.json +0 -2
- model.safetensors +2 -2
- model.safetensors.index.json +0 -0
- model_mtp.safetensors +2 -2
- recipe.yaml +8 -1
README.md
CHANGED
|
@@ -1,8 +1,9 @@
|
|
| 1 |
---
|
| 2 |
-
base_model:
|
| 3 |
library_name: transformers
|
| 4 |
pipeline_tag: text-generation
|
| 5 |
license: other
|
|
|
|
| 6 |
tags:
|
| 7 |
- compressed-tensors
|
| 8 |
- llm-compressor
|
|
@@ -12,44 +13,87 @@ tags:
|
|
| 12 |
- speculative-decoding
|
| 13 |
---
|
| 14 |
|
| 15 |
-
# GLM-5.3
|
| 16 |
|
| 17 |
-
This is a
|
| 18 |
-
`
|
| 19 |
-
`
|
| 20 |
-
|
| 21 |
-
meets vLLM's FP8 Cutlass alignment requirement. The backbone remains BF16 so the
|
| 22 |
-
fixture isolates MTP compression behavior.
|
| 23 |
|
| 24 |
-
|
|
|
|
|
|
|
| 25 |
|
| 26 |
## Compression Recipe
|
| 27 |
|
|
|
|
|
|
|
|
|
|
| 28 |
```python
|
|
|
|
|
|
|
|
|
|
| 29 |
from llmcompressor import oneshot
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
oneshot(
|
| 32 |
-
model=
|
| 33 |
-
recipe=
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
mtp_scheme="NVFP4",
|
| 36 |
-
precision="bfloat16",
|
| 37 |
)
|
| 38 |
```
|
| 39 |
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
|
| 44 |
## Validation
|
| 45 |
|
| 46 |
-
- All
|
| 47 |
-
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
|
|
|
|
|
|
| 53 |
|
| 54 |
## vLLM
|
| 55 |
|
|
|
|
| 1 |
---
|
| 2 |
+
base_model: zai-org/GLM-5.3
|
| 3 |
library_name: transformers
|
| 4 |
pipeline_tag: text-generation
|
| 5 |
license: other
|
| 6 |
+
license_name: glm-5.3
|
| 7 |
tags:
|
| 8 |
- compressed-tensors
|
| 9 |
- llm-compressor
|
|
|
|
| 13 |
- speculative-decoding
|
| 14 |
---
|
| 15 |
|
| 16 |
+
# GLM-5.3 Tiny NVFP4 MTP Test Fixture
|
| 17 |
|
| 18 |
+
This is a deterministic, random-weight architecture and serving fixture derived
|
| 19 |
+
directly from the released `zai-org/GLM-5.3` config and tokenizer. It uses the
|
| 20 |
+
`GlmMoeDsaForCausalLM` architecture, four small backbone layers, eight experts,
|
| 21 |
+
and one MTP layer in the released `model.layers.4` tensor layout.
|
|
|
|
|
|
|
| 22 |
|
| 23 |
+
The checkpoint does not inherit GLM-5.3 model weights and is not suitable for
|
| 24 |
+
quality evaluation. Its purpose is to test end-to-end NVFP4 compression and vLLM
|
| 25 |
+
MTP speculative decoding without downloading the full GLM-5.3 checkpoint.
|
| 26 |
|
| 27 |
## Compression Recipe
|
| 28 |
|
| 29 |
+
The backbone is calibrated and quantized inside `oneshot`. The `mtp_scheme`
|
| 30 |
+
argument asks the same call to compress the MTP weights during post-processing.
|
| 31 |
+
|
| 32 |
```python
|
| 33 |
+
from datasets import Dataset
|
| 34 |
+
from transformers import AutoModelForCausalLM
|
| 35 |
+
|
| 36 |
from llmcompressor import oneshot
|
| 37 |
+
from llmcompressor.modifiers.quantization import QuantizationModifier
|
| 38 |
+
from llmcompressor.utils import load_context
|
| 39 |
+
|
| 40 |
+
model_id = "/path/to/glm-5.3-tiny-mtp-source"
|
| 41 |
+
dataset = Dataset.from_dict(
|
| 42 |
+
{
|
| 43 |
+
"text": [
|
| 44 |
+
"Explain why speculative decoding can reduce inference latency.",
|
| 45 |
+
"Write a short Python function that adds two integers.",
|
| 46 |
+
"Summarize the benefits of mixture-of-experts language models.",
|
| 47 |
+
"What is the capital of France?",
|
| 48 |
+
"List three considerations when deploying a language model.",
|
| 49 |
+
"Describe the difference between weights and activations.",
|
| 50 |
+
"Complete the sequence: one, two, three, four.",
|
| 51 |
+
"Give a concise definition of quantization calibration.",
|
| 52 |
+
]
|
| 53 |
+
}
|
| 54 |
+
)
|
| 55 |
+
|
| 56 |
+
recipe = QuantizationModifier(
|
| 57 |
+
targets="Linear",
|
| 58 |
+
scheme="NVFP4",
|
| 59 |
+
ignore=[
|
| 60 |
+
"lm_head",
|
| 61 |
+
r"re:.*mlp\.gate$",
|
| 62 |
+
r"re:.*self_attn\.indexer\.(?:weights_proj|wk)$",
|
| 63 |
+
],
|
| 64 |
+
)
|
| 65 |
+
|
| 66 |
+
with load_context(AutoModelForCausalLM):
|
| 67 |
+
model = AutoModelForCausalLM.from_pretrained(model_id, dtype="bfloat16")
|
| 68 |
+
model.generation_config.top_p = None
|
| 69 |
|
| 70 |
oneshot(
|
| 71 |
+
model=model,
|
| 72 |
+
recipe=recipe,
|
| 73 |
+
dataset=dataset,
|
| 74 |
+
output_dir="GLM-5.3-MTP-NVFP4-Test-Fixture",
|
| 75 |
+
max_seq_length=128,
|
| 76 |
+
num_calibration_samples=len(dataset),
|
| 77 |
+
moe_calibrate_all_experts=True,
|
| 78 |
mtp_scheme="NVFP4",
|
|
|
|
| 79 |
)
|
| 80 |
```
|
| 81 |
|
| 82 |
+
Transformers does not construct the MTP layer, so it cannot observe MTP
|
| 83 |
+
activations during calibration. The MTP group is therefore weight-only NVFP4;
|
| 84 |
+
the backbone remains calibrated W4A4 NVFP4.
|
| 85 |
|
| 86 |
## Validation
|
| 87 |
|
| 88 |
+
- All 562 indexed tensors are present, with no missing or unindexed tensors.
|
| 89 |
+
- 105 backbone linears have NVFP4 packed weights, block scales, global scales,
|
| 90 |
+
and calibrated input global scales.
|
| 91 |
+
- 33 MTP projections have NVFP4 packed weights, block scales, and global scales
|
| 92 |
+
in `model_mtp.safetensors`; no uncalibrated MTP activation scales are stored.
|
| 93 |
+
- The same generated architecture passed vLLM MTP speculative decoding on H100
|
| 94 |
+
using an FP8 Dynamic proxy and one speculative token.
|
| 95 |
+
- Native NVFP4 speculative serving requires Blackwell and remains the final
|
| 96 |
+
hardware smoke test.
|
| 97 |
|
| 98 |
## vLLM
|
| 99 |
|
chat_template.jinja
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
[gMASK]<sop>
|
| 2 |
-
{%- set effective_reasoning_effort =
|
| 3 |
-
{%- if
|
|
|
|
| 4 |
{%- if tools -%}
|
| 5 |
{%- macro tool_to_json(tool) -%}
|
| 6 |
{%- set ns_tool = namespace(first=true) -%}
|
|
@@ -14,6 +15,20 @@
|
|
| 14 |
{%- endfor -%}
|
| 15 |
{{- '}' -}}
|
| 16 |
{%- endmacro -%}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
<|system|>
|
| 18 |
# Tools
|
| 19 |
|
|
@@ -47,10 +62,67 @@ For each function call, output the function name and arguments within the follow
|
|
| 47 |
{{- "<reminder>You are unable to process this " ~ media_type ~ " because you don't have multi-modal input ability. Try different methods.</reminder>" }}
|
| 48 |
{%- endif -%}
|
| 49 |
{%- endfor -%}
|
| 50 |
-
{%-
|
| 51 |
{{- content }}
|
| 52 |
{%- endif -%}
|
| 53 |
{%- endmacro -%}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
{%- set ns = namespace(last_user_index=-1) -%}
|
| 55 |
{%- for m in messages %}
|
| 56 |
{%- if m.role == 'user' %}
|
|
@@ -68,7 +140,7 @@ For each function call, output the function name and arguments within the follow
|
|
| 68 |
{%- set reasoning_content = content.split('</think>')[0].split('<think>')[-1] %}
|
| 69 |
{%- set content = content.split('</think>')[-1] %}
|
| 70 |
{%- endif %}
|
| 71 |
-
{%- if (
|
| 72 |
{{ '<think>' + reasoning_content + '</think>'}}
|
| 73 |
{%- else -%}
|
| 74 |
{{ '<think></think>' }}
|
|
@@ -87,33 +159,97 @@ For each function call, output the function name and arguments within the follow
|
|
| 87 |
{%- elif m.role == 'tool' -%}
|
| 88 |
{%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}
|
| 89 |
{{- '<|observation|>' -}}
|
| 90 |
-
{%-
|
| 91 |
-
{%-
|
| 92 |
-
{
|
| 93 |
-
{%-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
{%- endif -%}
|
| 100 |
-
|
| 101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
{%- endif -%}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
{%- endfor -%}
|
| 104 |
-
{%-
|
| 105 |
-
{
|
| 106 |
-
{%-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
{%-
|
| 111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
{% endif -%}
|
| 113 |
{%- elif m.role == 'system' -%}
|
| 114 |
<|system|>{{ visible_text(m.content) }}
|
| 115 |
{%- endif -%}
|
| 116 |
{%- endfor -%}
|
| 117 |
{%- if add_generation_prompt -%}
|
| 118 |
-
<|assistant|>{{- '<think>
|
| 119 |
{%- endif -%}
|
|
|
|
| 1 |
[gMASK]<sop>
|
| 2 |
+
{%- set effective_reasoning_effort = reasoning_effort if reasoning_effort is defined and reasoning_effort in ['low', 'high'] else 'max' -%}
|
| 3 |
+
{%- if effective_reasoning_effort is not none -%}<|system|>Reasoning Effort: {{ effective_reasoning_effort | capitalize }}{%- endif -%}
|
| 4 |
+
{%- set clear_thinking = clear_thinking if clear_thinking is defined else false -%}
|
| 5 |
{%- if tools -%}
|
| 6 |
{%- macro tool_to_json(tool) -%}
|
| 7 |
{%- set ns_tool = namespace(first=true) -%}
|
|
|
|
| 15 |
{%- endfor -%}
|
| 16 |
{{- '}' -}}
|
| 17 |
{%- endmacro -%}
|
| 18 |
+
{%- macro tool_references_to_response(refs) -%}
|
| 19 |
+
{{- '<tool_response><tools>\n' -}}
|
| 20 |
+
{%- for tr in refs -%}
|
| 21 |
+
{%- for tool in tools -%}
|
| 22 |
+
{%- if 'function' in tool -%}
|
| 23 |
+
{%- set tool = tool['function'] -%}
|
| 24 |
+
{%- endif -%}
|
| 25 |
+
{%- if tool.name == tr.name -%}
|
| 26 |
+
{{- tool_to_json(tool) + '\n' -}}
|
| 27 |
+
{%- endif -%}
|
| 28 |
+
{%- endfor -%}
|
| 29 |
+
{%- endfor -%}
|
| 30 |
+
{{- '</tools></tool_response>' -}}
|
| 31 |
+
{%- endmacro -%}
|
| 32 |
<|system|>
|
| 33 |
# Tools
|
| 34 |
|
|
|
|
| 62 |
{{- "<reminder>You are unable to process this " ~ media_type ~ " because you don't have multi-modal input ability. Try different methods.</reminder>" }}
|
| 63 |
{%- endif -%}
|
| 64 |
{%- endfor -%}
|
| 65 |
+
{%- elif content is not none -%}
|
| 66 |
{{- content }}
|
| 67 |
{%- endif -%}
|
| 68 |
{%- endmacro -%}
|
| 69 |
+
{%- macro tool_response(text) -%}
|
| 70 |
+
{{- '<tool_response>' + text + '</tool_response>' -}}
|
| 71 |
+
{%- endmacro -%}
|
| 72 |
+
{%- macro render_tool_response(m) -%}
|
| 73 |
+
{%- if m.content is string -%}
|
| 74 |
+
{{- tool_response(m.content) -}}
|
| 75 |
+
{%- elif m.content and m.content is not mapping and m.content.0.type == "tool_reference" -%}
|
| 76 |
+
{{- tool_references_to_response(m.content) -}}
|
| 77 |
+
{%- elif is_list_of_outputs(m) -%}
|
| 78 |
+
{%- for tr in m.content -%}
|
| 79 |
+
{%- if tr.output is iterable and tr.output is not string and tr.output is not mapping and tr.output and tr.output.0.type == "tool_reference" -%}
|
| 80 |
+
{{- tool_references_to_response(tr.output) -}}
|
| 81 |
+
{%- else -%}
|
| 82 |
+
{{- tool_response(visible_text(tr.output)) -}}
|
| 83 |
+
{%- endif -%}
|
| 84 |
+
{%- endfor -%}
|
| 85 |
+
{%- else -%}
|
| 86 |
+
{{- tool_response(visible_text(m.content)) -}}
|
| 87 |
+
{%- endif -%}
|
| 88 |
+
{%- endmacro -%}
|
| 89 |
+
{%- macro id_of(obj) -%}
|
| 90 |
+
{%- if obj.tool_call_id -%}
|
| 91 |
+
{{- obj.tool_call_id -}}
|
| 92 |
+
{%- elif obj.id -%}
|
| 93 |
+
{{- obj.id -}}
|
| 94 |
+
{%- endif -%}
|
| 95 |
+
{%- endmacro -%}
|
| 96 |
+
{%- macro is_list_of_outputs(m) -%}
|
| 97 |
+
{%- if m.content and m.content.0.output is defined -%}1{%- endif -%}
|
| 98 |
+
{%- endmacro -%}
|
| 99 |
+
{%- macro has_dup_tool_result_id(lo, hi, target) -%}
|
| 100 |
+
{%- set ns_cnt = namespace(n=0) -%}
|
| 101 |
+
{%- for k in range(lo, hi + 1) -%}
|
| 102 |
+
{%- set m = messages[k] -%}
|
| 103 |
+
{%- if is_list_of_outputs(m) -%}
|
| 104 |
+
{%- for entry in m.content -%}
|
| 105 |
+
{%- if id_of(entry) == target -%}
|
| 106 |
+
{%- set ns_cnt.n = ns_cnt.n + 1 -%}
|
| 107 |
+
{%- endif -%}
|
| 108 |
+
{%- endfor -%}
|
| 109 |
+
{%- elif id_of(m) == target -%}
|
| 110 |
+
{%- set ns_cnt.n = ns_cnt.n + 1 -%}
|
| 111 |
+
{%- endif -%}
|
| 112 |
+
{%- if ns_cnt.n > 1 -%}{%- break -%}{%- endif -%}
|
| 113 |
+
{%- endfor -%}
|
| 114 |
+
{%- if ns_cnt.n > 1 -%}1{%- endif -%}
|
| 115 |
+
{%- endmacro -%}
|
| 116 |
+
{%- macro tc_id_exists(tcs, target) -%}
|
| 117 |
+
{%- set ns_f = namespace(found=false) -%}
|
| 118 |
+
{%- for tc in tcs -%}
|
| 119 |
+
{%- if id_of(tc) == target -%}
|
| 120 |
+
{%- set ns_f.found = true -%}
|
| 121 |
+
{%- break -%}
|
| 122 |
+
{%- endif -%}
|
| 123 |
+
{%- endfor -%}
|
| 124 |
+
{%- if ns_f.found -%}1{%- endif -%}
|
| 125 |
+
{%- endmacro -%}
|
| 126 |
{%- set ns = namespace(last_user_index=-1) -%}
|
| 127 |
{%- for m in messages %}
|
| 128 |
{%- if m.role == 'user' %}
|
|
|
|
| 140 |
{%- set reasoning_content = content.split('</think>')[0].split('<think>')[-1] %}
|
| 141 |
{%- set content = content.split('</think>')[-1] %}
|
| 142 |
{%- endif %}
|
| 143 |
+
{%- if (not clear_thinking or loop.index0 > ns.last_user_index) and reasoning_content is defined -%}
|
| 144 |
{{ '<think>' + reasoning_content + '</think>'}}
|
| 145 |
{%- else -%}
|
| 146 |
{{ '<think></think>' }}
|
|
|
|
| 159 |
{%- elif m.role == 'tool' -%}
|
| 160 |
{%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}
|
| 161 |
{{- '<|observation|>' -}}
|
| 162 |
+
{%- set block_start = loop.index0 -%}
|
| 163 |
+
{%- set ns_blk = namespace(end=block_start) -%}
|
| 164 |
+
{%- for j in range(block_start, messages|length) -%}
|
| 165 |
+
{%- if messages[j].role == 'tool' -%}
|
| 166 |
+
{%- set ns_blk.end = j -%}
|
| 167 |
+
{%- else -%}
|
| 168 |
+
{%- break -%}
|
| 169 |
+
{%- endif -%}
|
| 170 |
+
{%- endfor -%}
|
| 171 |
+
{%- set ns_a = namespace(tool_calls=none) -%}
|
| 172 |
+
{%- if block_start > 0 and messages[block_start - 1].role == 'assistant' and messages[block_start - 1].tool_calls -%}
|
| 173 |
+
{%- set ns_a.tool_calls = messages[block_start - 1].tool_calls -%}
|
| 174 |
+
{%- endif -%}
|
| 175 |
+
{%- set ns_chk = namespace(can_sort=true) -%}
|
| 176 |
+
{%- if not ns_a.tool_calls -%}
|
| 177 |
+
{%- set ns_chk.can_sort = false -%}
|
| 178 |
+
{%- else -%}
|
| 179 |
+
{%- for k in range(block_start, ns_blk.end + 1) -%}
|
| 180 |
+
{%- if not ns_chk.can_sort -%}{%- break -%}{%- endif -%}
|
| 181 |
+
{%- set m = messages[k] -%}
|
| 182 |
+
{%- if is_list_of_outputs(m) -%}
|
| 183 |
+
{%- for entry in m.content -%}
|
| 184 |
+
{%- if not ns_chk.can_sort -%}{%- break -%}{%- endif -%}
|
| 185 |
+
{%- set eid = id_of(entry) -%}
|
| 186 |
+
{%- if not eid -%}
|
| 187 |
+
{%- set ns_chk.can_sort = false -%}
|
| 188 |
+
{%- elif has_dup_tool_result_id(block_start, ns_blk.end, eid) -%}
|
| 189 |
+
{%- set ns_chk.can_sort = false -%}
|
| 190 |
+
{%- elif not tc_id_exists(ns_a.tool_calls, eid) -%}
|
| 191 |
+
{%- set ns_chk.can_sort = false -%}
|
| 192 |
+
{%- endif -%}
|
| 193 |
+
{%- endfor -%}
|
| 194 |
+
{%- else -%}
|
| 195 |
+
{%- set tk_id = id_of(m) -%}
|
| 196 |
+
{%- if not tk_id -%}
|
| 197 |
+
{%- set ns_chk.can_sort = false -%}
|
| 198 |
+
{%- elif has_dup_tool_result_id(block_start, ns_blk.end, tk_id) -%}
|
| 199 |
+
{%- set ns_chk.can_sort = false -%}
|
| 200 |
+
{%- elif not tc_id_exists(ns_a.tool_calls, tk_id) -%}
|
| 201 |
+
{%- set ns_chk.can_sort = false -%}
|
| 202 |
+
{%- endif -%}
|
| 203 |
{%- endif -%}
|
| 204 |
+
{%- endfor -%}
|
| 205 |
+
{%- for i in range(ns_a.tool_calls | length) -%}
|
| 206 |
+
{%- if not ns_chk.can_sort -%}{%- break -%}{%- endif -%}
|
| 207 |
+
{%- set tc_id = id_of(ns_a.tool_calls[i]) -%}
|
| 208 |
+
{%- if not tc_id -%}
|
| 209 |
+
{%- set ns_chk.can_sort = false -%}
|
| 210 |
{%- endif -%}
|
| 211 |
+
{%- for j in range(i + 1, ns_a.tool_calls | length) -%}
|
| 212 |
+
{%- if id_of(ns_a.tool_calls[j]) == tc_id -%}
|
| 213 |
+
{%- set ns_chk.can_sort = false -%}
|
| 214 |
+
{%- break -%}
|
| 215 |
+
{%- endif -%}
|
| 216 |
+
{%- endfor -%}
|
| 217 |
{%- endfor -%}
|
| 218 |
+
{%- endif -%}
|
| 219 |
+
{%- if ns_chk.can_sort -%}
|
| 220 |
+
{%- for tc in ns_a.tool_calls -%}
|
| 221 |
+
{%- set tc_id = id_of(tc) -%}
|
| 222 |
+
{%- for k in range(block_start, ns_blk.end + 1) -%}
|
| 223 |
+
{%- set m = messages[k] -%}
|
| 224 |
+
{%- if is_list_of_outputs(m) -%}
|
| 225 |
+
{%- for entry in m.content -%}
|
| 226 |
+
{%- set eid = id_of(entry) -%}
|
| 227 |
+
{%- if eid == tc_id -%}
|
| 228 |
+
{%- if entry.output is iterable and entry.output is not string and entry.output is not mapping and entry.output and entry.output.0.type == "tool_reference" -%}
|
| 229 |
+
{{- tool_references_to_response(entry.output) -}}
|
| 230 |
+
{%- else -%}
|
| 231 |
+
{{- tool_response(visible_text(entry.output)) -}}
|
| 232 |
+
{%- endif -%}
|
| 233 |
+
{%- endif -%}
|
| 234 |
+
{%- endfor -%}
|
| 235 |
+
{%- else -%}
|
| 236 |
+
{%- set tk_id = id_of(m) -%}
|
| 237 |
+
{%- if tk_id == tc_id -%}
|
| 238 |
+
{{- render_tool_response(m) -}}
|
| 239 |
+
{%- endif -%}
|
| 240 |
+
{%- endif -%}
|
| 241 |
+
{%- endfor -%}
|
| 242 |
+
{%- endfor -%}
|
| 243 |
+
{%- else -%}
|
| 244 |
+
{%- for k in range(block_start, ns_blk.end + 1) -%}
|
| 245 |
+
{{- render_tool_response(messages[k]) -}}
|
| 246 |
+
{%- endfor -%}
|
| 247 |
+
{%- endif -%}
|
| 248 |
{% endif -%}
|
| 249 |
{%- elif m.role == 'system' -%}
|
| 250 |
<|system|>{{ visible_text(m.content) }}
|
| 251 |
{%- endif -%}
|
| 252 |
{%- endfor -%}
|
| 253 |
{%- if add_generation_prompt -%}
|
| 254 |
+
<|assistant|>{{- '<think>' -}}
|
| 255 |
{%- endif -%}
|
config.json
CHANGED
|
@@ -22,12 +22,7 @@
|
|
| 22 |
"index_skip_topk_offset": 3,
|
| 23 |
"index_topk": 2048,
|
| 24 |
"index_topk_freq": 4,
|
| 25 |
-
"index_topk_pattern":
|
| 26 |
-
"F",
|
| 27 |
-
"S",
|
| 28 |
-
"S",
|
| 29 |
-
"S"
|
| 30 |
-
],
|
| 31 |
"indexer_rope_interleave": true,
|
| 32 |
"indexer_types": [
|
| 33 |
"full",
|
|
@@ -57,11 +52,11 @@
|
|
| 57 |
"moe_layer_freq": 1,
|
| 58 |
"moe_router_dtype": "float32",
|
| 59 |
"n_group": 1,
|
| 60 |
-
"n_routed_experts":
|
| 61 |
"n_shared_experts": 1,
|
| 62 |
"norm_topk_prob": true,
|
| 63 |
"num_attention_heads": 8,
|
| 64 |
-
"num_experts_per_tok":
|
| 65 |
"num_hidden_layers": 4,
|
| 66 |
"num_key_value_heads": 8,
|
| 67 |
"num_nextn_predict_layers": 1,
|
|
@@ -71,25 +66,11 @@
|
|
| 71 |
"qk_head_dim": 256,
|
| 72 |
"qk_nope_head_dim": 192,
|
| 73 |
"qk_rope_head_dim": 64,
|
| 74 |
-
"rms_norm_eps": 1e-05,
|
| 75 |
-
"rope_interleave": true,
|
| 76 |
-
"rope_parameters": {
|
| 77 |
-
"rope_theta": 8000000,
|
| 78 |
-
"rope_type": "default"
|
| 79 |
-
},
|
| 80 |
-
"routed_scaling_factor": 2.5,
|
| 81 |
-
"scoring_func": "sigmoid",
|
| 82 |
-
"tie_word_embeddings": false,
|
| 83 |
-
"topk_group": 1,
|
| 84 |
-
"topk_method": "noaux_tc",
|
| 85 |
-
"transformers_version": "5.16.1",
|
| 86 |
-
"use_cache": true,
|
| 87 |
-
"v_head_dim": 256,
|
| 88 |
-
"vocab_size": 154880,
|
| 89 |
"quantization_config": {
|
| 90 |
"version": "0.18.1.dev17+g1a127f3",
|
| 91 |
"quant_method": "compressed-tensors",
|
| 92 |
"transform_config": {},
|
|
|
|
| 93 |
"config_groups": {
|
| 94 |
"mtp_group": {
|
| 95 |
"targets": [
|
|
@@ -110,12 +91,63 @@
|
|
| 110 |
"observer_kwargs": {}
|
| 111 |
},
|
| 112 |
"format": "nvfp4-pack-quantized"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
}
|
| 114 |
},
|
| 115 |
"format": "nvfp4-pack-quantized",
|
| 116 |
"quantization_status": "compressed",
|
| 117 |
"ignore": [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
"re:^model\\.layers\\.(?:4)\\.(?:eh_proj|mlp\\.gate|self_attn\\.indexer\\.wk_weights_proj)$"
|
| 119 |
]
|
| 120 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
}
|
|
|
|
| 22 |
"index_skip_topk_offset": 3,
|
| 23 |
"index_topk": 2048,
|
| 24 |
"index_topk_freq": 4,
|
| 25 |
+
"index_topk_pattern": null,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
"indexer_rope_interleave": true,
|
| 27 |
"indexer_types": [
|
| 28 |
"full",
|
|
|
|
| 52 |
"moe_layer_freq": 1,
|
| 53 |
"moe_router_dtype": "float32",
|
| 54 |
"n_group": 1,
|
| 55 |
+
"n_routed_experts": 8,
|
| 56 |
"n_shared_experts": 1,
|
| 57 |
"norm_topk_prob": true,
|
| 58 |
"num_attention_heads": 8,
|
| 59 |
+
"num_experts_per_tok": 2,
|
| 60 |
"num_hidden_layers": 4,
|
| 61 |
"num_key_value_heads": 8,
|
| 62 |
"num_nextn_predict_layers": 1,
|
|
|
|
| 66 |
"qk_head_dim": 256,
|
| 67 |
"qk_nope_head_dim": 192,
|
| 68 |
"qk_rope_head_dim": 64,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
"quantization_config": {
|
| 70 |
"version": "0.18.1.dev17+g1a127f3",
|
| 71 |
"quant_method": "compressed-tensors",
|
| 72 |
"transform_config": {},
|
| 73 |
+
"sparsity_config": {},
|
| 74 |
"config_groups": {
|
| 75 |
"mtp_group": {
|
| 76 |
"targets": [
|
|
|
|
| 91 |
"observer_kwargs": {}
|
| 92 |
},
|
| 93 |
"format": "nvfp4-pack-quantized"
|
| 94 |
+
},
|
| 95 |
+
"group_0": {
|
| 96 |
+
"targets": [
|
| 97 |
+
"Linear"
|
| 98 |
+
],
|
| 99 |
+
"weights": {
|
| 100 |
+
"num_bits": 4,
|
| 101 |
+
"type": "float",
|
| 102 |
+
"symmetric": true,
|
| 103 |
+
"group_size": 16,
|
| 104 |
+
"strategy": "tensor_group",
|
| 105 |
+
"dynamic": false,
|
| 106 |
+
"scale_dtype": "torch.float8_e4m3fn",
|
| 107 |
+
"zp_dtype": null,
|
| 108 |
+
"observer": "memoryless_minmax",
|
| 109 |
+
"observer_kwargs": {}
|
| 110 |
+
},
|
| 111 |
+
"input_activations": {
|
| 112 |
+
"num_bits": 4,
|
| 113 |
+
"type": "float",
|
| 114 |
+
"symmetric": true,
|
| 115 |
+
"group_size": 16,
|
| 116 |
+
"strategy": "tensor_group",
|
| 117 |
+
"dynamic": "local",
|
| 118 |
+
"scale_dtype": "torch.float8_e4m3fn",
|
| 119 |
+
"zp_dtype": null,
|
| 120 |
+
"observer": "static_minmax",
|
| 121 |
+
"observer_kwargs": {}
|
| 122 |
+
},
|
| 123 |
+
"format": "nvfp4-pack-quantized"
|
| 124 |
}
|
| 125 |
},
|
| 126 |
"format": "nvfp4-pack-quantized",
|
| 127 |
"quantization_status": "compressed",
|
| 128 |
"ignore": [
|
| 129 |
+
"model.layers.0.self_attn.indexer.wk",
|
| 130 |
+
"model.layers.0.self_attn.indexer.weights_proj",
|
| 131 |
+
"model.layers.1.mlp.gate",
|
| 132 |
+
"model.layers.2.mlp.gate",
|
| 133 |
+
"model.layers.3.mlp.gate",
|
| 134 |
+
"lm_head",
|
| 135 |
"re:^model\\.layers\\.(?:4)\\.(?:eh_proj|mlp\\.gate|self_attn\\.indexer\\.wk_weights_proj)$"
|
| 136 |
]
|
| 137 |
+
},
|
| 138 |
+
"rms_norm_eps": 1e-05,
|
| 139 |
+
"rope_interleave": true,
|
| 140 |
+
"rope_parameters": {
|
| 141 |
+
"rope_theta": 8000000,
|
| 142 |
+
"rope_type": "default"
|
| 143 |
+
},
|
| 144 |
+
"routed_scaling_factor": 2.5,
|
| 145 |
+
"scoring_func": "sigmoid",
|
| 146 |
+
"tie_word_embeddings": false,
|
| 147 |
+
"topk_group": 1,
|
| 148 |
+
"topk_method": "noaux_tc",
|
| 149 |
+
"transformers_version": "5.16.1",
|
| 150 |
+
"use_cache": true,
|
| 151 |
+
"v_head_dim": 256,
|
| 152 |
+
"vocab_size": 154880
|
| 153 |
}
|
generation_config.json
CHANGED
|
@@ -1,6 +1,5 @@
|
|
| 1 |
{
|
| 2 |
"_from_model_config": true,
|
| 3 |
-
"do_sample": true,
|
| 4 |
"eos_token_id": [
|
| 5 |
154820,
|
| 6 |
154827,
|
|
@@ -8,6 +7,5 @@
|
|
| 8 |
],
|
| 9 |
"pad_token_id": 154820,
|
| 10 |
"temperature": 1.0,
|
| 11 |
-
"top_p": 0.95,
|
| 12 |
"transformers_version": "5.16.1"
|
| 13 |
}
|
|
|
|
| 1 |
{
|
| 2 |
"_from_model_config": true,
|
|
|
|
| 3 |
"eos_token_id": [
|
| 4 |
154820,
|
| 5 |
154827,
|
|
|
|
| 7 |
],
|
| 8 |
"pad_token_id": 154820,
|
| 9 |
"temperature": 1.0,
|
|
|
|
| 10 |
"transformers_version": "5.16.1"
|
| 11 |
}
|
model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:28ef236e1fb28b88e403b08ba627d8167909a4b514d6275f33325f5328f8c39f
|
| 3 |
+
size 14446256
|
model.safetensors.index.json
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
model_mtp.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d835ac0316030e6aba391e8afc58b9bbb94cfc92693827601b20bb5fe358be7a
|
| 3 |
+
size 1195556
|
recipe.yaml
CHANGED
|
@@ -1 +1,8 @@
|
|
| 1 |
-
default_stage:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
default_stage:
|
| 2 |
+
default_modifiers:
|
| 3 |
+
QuantizationModifier:
|
| 4 |
+
targets: [Linear]
|
| 5 |
+
ignore: [lm_head, 're:.*mlp\.gate$', 're:.*self_attn\.indexer\.(?:weights_proj|wk)$']
|
| 6 |
+
scheme: NVFP4
|
| 7 |
+
bypass_divisibility_checks: false
|
| 8 |
+
requires_calibration_data: true
|