Shoolife commited on
Commit
f6e5219
·
verified ·
1 Parent(s): ab4c70d

Add files using upload-large-folder tool

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ base_model: microsoft/Phi-4-mini-instruct
4
+ pipeline_tag: text-generation
5
+ library_name: tensorrt-llm
6
+ tags:
7
+ - phi
8
+ - phi-4
9
+ - tensorrt-llm
10
+ - text-generation
11
+ - fp8
12
+ - checkpoint
13
+ ---
14
+
15
+ # Phi-4-mini-instruct TensorRT-LLM Checkpoint (FP8)
16
+
17
+ This repository contains a community-converted TensorRT-LLM checkpoint for [`microsoft/Phi-4-mini-instruct`](https://huggingface.co/microsoft/Phi-4-mini-instruct).
18
+
19
+ It is a TensorRT-LLM **checkpoint-format** repository, not a prebuilt engine. The intent is to let you download the checkpoint from Hugging Face and build an engine locally for your own GPU and TensorRT-LLM version.
20
+
21
+ ## Model Characteristics
22
+
23
+ - Base model: `microsoft/Phi-4-mini-instruct`
24
+ - License: `mit`
25
+ - Architecture: `Phi3ForCausalLM`
26
+ - Upstream maximum context length (`max_position_embeddings`): `131072`
27
+ - Hidden size: `3072`
28
+ - Intermediate size: `8192`
29
+ - Layers: `32`
30
+ - Attention heads: `24`
31
+ - KV heads: `8`
32
+ - Vocabulary size: `200064`
33
+
34
+ These values come from the upstream model/checkpoint configuration. They describe the model family itself, not a specific locally built TensorRT engine.
35
+
36
+ ## Checkpoint Details
37
+
38
+ - TensorRT-LLM version used for conversion: `1.2.0rc6`
39
+ - Checkpoint dtype: `bfloat16`
40
+ - Quantization: `FP8`
41
+ - KV cache quantization: `FP8`
42
+ - Tensor parallel size: `1`
43
+ - Checkpoint files:
44
+ - `config.json`
45
+ - `rank0.safetensors`
46
+ - tokenizer and generation files copied from the upstream Hugging Face model
47
+
48
+ ## Files
49
+
50
+ - `config.json`: TensorRT-LLM checkpoint config
51
+ - `rank0.safetensors`: TensorRT-LLM checkpoint weights
52
+ - `generation_config.json`: upstream generation config
53
+ - `tokenizer.json`: upstream tokenizer
54
+ - `tokenizer_config.json`: upstream tokenizer config
55
+ - `merges.txt`: upstream merges file
56
+ - `vocab.json`: upstream vocabulary
57
+ - `added_tokens.json`: upstream added tokens
58
+ - `special_tokens_map.json`: upstream special tokens map
59
+
60
+ ## Build Example
61
+
62
+ The following command is the **validated local engine build** used for the benchmarks in this README. These values are build-time/runtime settings for one local engine, not limits of the checkpoint itself.
63
+
64
+ Build an engine locally with TensorRT-LLM:
65
+
66
+ ```bash
67
+ huggingface-cli download Shoolife/Phi-4-mini-instruct-TensorRT-LLM-Checkpoint-FP8 --local-dir ./checkpoint
68
+
69
+ trtllm-build \
70
+ --checkpoint_dir ./checkpoint \
71
+ --output_dir ./engine \
72
+ --gemm_plugin auto \
73
+ --gpt_attention_plugin auto \
74
+ --max_batch_size 1 \
75
+ --max_input_len 256 \
76
+ --max_seq_len 512 \
77
+ --max_num_tokens 128 \
78
+ --workers 1 \
79
+ --monitor_memory
80
+ ```
81
+
82
+ If you rebuild the engine with different limits, memory usage and supported request shapes will change accordingly.
83
+
84
+ ## Conversion
85
+
86
+ This checkpoint was produced from the upstream model with TensorRT-LLM FP8 quantization tooling:
87
+
88
+ ```bash
89
+ python /app/tensorrt_llm/examples/quantization/quantize.py \
90
+ --model_dir ./Phi-4-mini-instruct \
91
+ --output_dir ./checkpoint_fp8 \
92
+ --dtype bfloat16 \
93
+ --qformat fp8 \
94
+ --kv_cache_dtype fp8 \
95
+ --calib_dataset cnn_dailymail \
96
+ --calib_size 64 \
97
+ --batch_size 1 \
98
+ --calib_max_seq_length 256 \
99
+ --tokenizer_max_seq_length 2048 \
100
+ --device cpu \
101
+ --device_map cpu
102
+ ```
103
+
104
+ Then build the engine:
105
+
106
+ ```bash
107
+ trtllm-build \
108
+ --checkpoint_dir ./checkpoint_fp8 \
109
+ --output_dir ./engine_fp8 \
110
+ --gemm_plugin auto \
111
+ --gpt_attention_plugin auto \
112
+ --max_batch_size 1 \
113
+ --max_input_len 256 \
114
+ --max_seq_len 512 \
115
+ --max_num_tokens 128 \
116
+ --workers 1 \
117
+ --monitor_memory
118
+ ```
119
+
120
+ ## Validation
121
+
122
+ The checkpoint was validated by building a local engine and running inference on:
123
+
124
+ - GPU: `NVIDIA GeForce RTX 5070 Laptop GPU`
125
+ - Runtime: `TensorRT-LLM 1.2.0rc6`
126
+
127
+ Smoke-test prompt:
128
+
129
+ ```text
130
+ Explain the four basic arithmetic operations in one short sentence each.
131
+ ```
132
+
133
+ Observed response:
134
+
135
+ ```text
136
+ Addition combines two or more numbers into a larger total. Subtraction removes one number from another to find the difference. Multiplication calculates the total of repeated addition. Division splits a number into equal parts.
137
+ ```
138
+
139
+ ## Validated Local Engine Characteristics
140
+
141
+ Local build and runtime characteristics from the validated engine used for the benchmark snapshot below:
142
+
143
+ | Property | Value |
144
+ |---|---|
145
+ | Checkpoint size | `5.3 GB` |
146
+ | Built engine size | `5.4 GB` |
147
+ | Tested GPU | `NVIDIA GeForce RTX 5070 Laptop GPU` |
148
+ | GPU memory reported by benchmark host | `7.53 GiB` |
149
+ | Engine build `max_batch_size` | `1` |
150
+ | Engine build `max_input_len` | `256` |
151
+ | Engine build `max_seq_len` | `512` |
152
+ | Engine build `max_num_tokens` | `128` |
153
+ | Runtime effective max input length | `128` |
154
+ | Engine load footprint | `~5.5 GiB` |
155
+ | Paged KV cache allocation | `~1.39 GiB` |
156
+ | Practical total GPU footprint on this setup | `~6.9-7.0 GiB` |
157
+
158
+ Important: the `256` / `512` / `128` limits above belong only to this particular local engine build. They are not the intrinsic maximum context or generation limits of `Phi-4-mini-instruct` itself.
159
+
160
+ The runtime effective input length became `128` on this build because TensorRT-LLM enabled packed input and context FMHA and clamped the usable prompt budget to the engine token budget.
161
+
162
+ These values are specific to the local engine build used for validation and will change if you rebuild with different TensorRT-LLM settings and memory budgets.
163
+
164
+ ## Benchmark Snapshot
165
+
166
+ Local single-GPU measurements from the validated local engine on `RTX 5070 Laptop GPU`, using TensorRT-LLM synthetic fixed-length requests, `20` requests per profile, `2` warmup requests, and `concurrency=1`.
167
+
168
+ | Profile | Input | Output | TTFT | TPOT | Output tok/s | Avg latency |
169
+ |---|---:|---:|---:|---:|---:|---:|
170
+ | `tiny_16_32` | 16 | 32 | `21.95 ms` | `18.15 ms` | `54.73` | `584.68 ms` |
171
+ | `short_chat_42_64` | 42 | 64 | `24.21 ms` | `18.12 ms` | `54.88` | `1166.07 ms` |
172
+ | `balanced_64_64` | 64 | 64 | `23.10 ms` | `17.56 ms` | `56.68` | `1129.17 ms` |
173
+ | `long_prompt_96_32` | 96 | 32 | `26.17 ms` | `18.24 ms` | `54.08` | `591.63 ms` |
174
+ | `long_generation_32_96` | 32 | 96 | `23.01 ms` | `17.91 ms` | `55.68` | `1724.03 ms` |
175
+
176
+ These numbers are local measurements from one machine and should be treated as reference values, not portability guarantees.
177
+
178
+ ## Notes
179
+
180
+ - This is not an official Microsoft or NVIDIA release.
181
+ - This repository does not include a prebuilt TensorRT engine.
182
+ - Engine compatibility and performance depend on your GPU, driver, CUDA, TensorRT, and TensorRT-LLM versions.
added_tokens.json ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "<|/tool_call|>": 200026,
3
+ "<|/tool|>": 200024,
4
+ "<|assistant|>": 200019,
5
+ "<|end|>": 200020,
6
+ "<|system|>": 200022,
7
+ "<|tag|>": 200028,
8
+ "<|tool_call|>": 200025,
9
+ "<|tool_response|>": 200027,
10
+ "<|tool|>": 200023,
11
+ "<|user|>": 200021
12
+ }
config.json ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "producer": {
3
+ "name": "modelopt",
4
+ "version": "0.37.0"
5
+ },
6
+ "architecture": "Phi3ForCausalLM",
7
+ "dtype": "bfloat16",
8
+ "logits_dtype": "float16",
9
+ "num_hidden_layers": 32,
10
+ "num_attention_heads": 24,
11
+ "num_key_value_heads": 8,
12
+ "hidden_size": 3072,
13
+ "norm_epsilon": 1e-05,
14
+ "vocab_size": 200064,
15
+ "max_position_embeddings": 131072,
16
+ "hidden_act": "swiglu",
17
+ "use_parallel_embedding": true,
18
+ "embedding_sharding_dim": 0,
19
+ "head_size": 128,
20
+ "intermediate_size": 8192,
21
+ "position_embedding_type": "long_rope",
22
+ "share_embedding_table": false,
23
+ "residual_mlp": false,
24
+ "bias": false,
25
+ "rotary_pct": 0.75,
26
+ "rank": 0,
27
+ "decoder": "phi3",
28
+ "rmsnorm": true,
29
+ "lm_head_bias": false,
30
+ "rotary_base": 10000.0,
31
+ "rotary_scaling": null,
32
+ "runtime_defaults": null,
33
+ "mapping": {
34
+ "world_size": 1,
35
+ "gpus_per_node": 8,
36
+ "cp_size": 1,
37
+ "tp_size": 1,
38
+ "pp_size": 1,
39
+ "moe_tp_size": 1,
40
+ "moe_cluster_size": 1,
41
+ "moe_ep_size": 1,
42
+ "attn_tp_size": 1,
43
+ "attn_cp_size": 1,
44
+ "cp_config": {},
45
+ "enable_attention_dp": false,
46
+ "enable_lm_head_tp_in_adp": false
47
+ },
48
+ "quantization": {
49
+ "quant_algo": "FP8",
50
+ "kv_cache_quant_algo": "FP8",
51
+ "group_size": 128,
52
+ "smoothquant_val": 0.5,
53
+ "clamp_val": null,
54
+ "use_meta_recipe": false,
55
+ "has_zero_point": false,
56
+ "pre_quant_scale": false,
57
+ "exclude_modules": [
58
+ "lm_head"
59
+ ],
60
+ "mamba_ssm_cache_dtype": null
61
+ },
62
+ "qk_layernorm": false,
63
+ "rotary_embedding_dim": 96,
64
+ "tie_word_embeddings": true,
65
+ "original_max_position_embeddings": 4096,
66
+ "longrope_scaling_short_factors": [
67
+ 1.0,
68
+ 1.0,
69
+ 1.0,
70
+ 1.0,
71
+ 1.0,
72
+ 1.0,
73
+ 1.0,
74
+ 1.0,
75
+ 1.0,
76
+ 1.0,
77
+ 1.0,
78
+ 1.0,
79
+ 1.0,
80
+ 1.0,
81
+ 1.0,
82
+ 1.0,
83
+ 1.0,
84
+ 1.0,
85
+ 1.0,
86
+ 1.0,
87
+ 1.0,
88
+ 1.0,
89
+ 1.0,
90
+ 1.0,
91
+ 1.0,
92
+ 1.0,
93
+ 1.0,
94
+ 1.0,
95
+ 1.0,
96
+ 1.0,
97
+ 1.0,
98
+ 1.0,
99
+ 1.0,
100
+ 1.0,
101
+ 1.0,
102
+ 1.0,
103
+ 1.0,
104
+ 1.0,
105
+ 1.0,
106
+ 1.0,
107
+ 1.0,
108
+ 1.0,
109
+ 1.0,
110
+ 1.0,
111
+ 1.0,
112
+ 1.0,
113
+ 1.0,
114
+ 1.0
115
+ ],
116
+ "longrope_scaling_long_factors": [
117
+ 1,
118
+ 1.118320672,
119
+ 1.250641126,
120
+ 1.398617824,
121
+ 1.564103225,
122
+ 1.74916897,
123
+ 1.956131817,
124
+ 2.187582649,
125
+ 2.446418898,
126
+ 2.735880826,
127
+ 3.059592084,
128
+ 3.421605075,
129
+ 3.826451687,
130
+ 4.279200023,
131
+ 4.785517845,
132
+ 5.351743533,
133
+ 5.984965424,
134
+ 6.693110555,
135
+ 7.485043894,
136
+ 8.370679318,
137
+ 9.36110372,
138
+ 10.4687158,
139
+ 11.70738129,
140
+ 13.09260651,
141
+ 14.64173252,
142
+ 16.37415215,
143
+ 18.31155283,
144
+ 20.47818807,
145
+ 22.90118105,
146
+ 25.61086418,
147
+ 28.64115884,
148
+ 32.03,
149
+ 32.1,
150
+ 32.13,
151
+ 32.23,
152
+ 32.6,
153
+ 32.61,
154
+ 32.64,
155
+ 32.66,
156
+ 32.7,
157
+ 32.71,
158
+ 32.93,
159
+ 32.97,
160
+ 33.28,
161
+ 33.49,
162
+ 33.5,
163
+ 44.16,
164
+ 47.77
165
+ ],
166
+ "model_type": "phi3"
167
+ }
generation_config.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 199999,
4
+ "eos_token_id": [
5
+ 200020,
6
+ 199999
7
+ ],
8
+ "pad_token_id": 199999,
9
+ "transformers_version": "4.45.0"
10
+ }
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
special_tokens_map.json ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<|endoftext|>",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "eos_token": {
10
+ "content": "<|endoftext|>",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": {
17
+ "content": "<|endoftext|>",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ },
23
+ "unk_token": {
24
+ "content": "<|endoftext|>",
25
+ "lstrip": false,
26
+ "normalized": false,
27
+ "rstrip": false,
28
+ "single_word": false
29
+ }
30
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:382cc235b56c725945e149cc25f191da667c836655efd0857b004320e90e91ea
3
+ size 15524095
tokenizer_config.json ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": false,
3
+ "add_eos_token": false,
4
+ "add_prefix_space": false,
5
+ "added_tokens_decoder": {
6
+ "199999": {
7
+ "content": "<|endoftext|>",
8
+ "lstrip": false,
9
+ "normalized": false,
10
+ "rstrip": false,
11
+ "single_word": false,
12
+ "special": true
13
+ },
14
+ "200018": {
15
+ "content": "<|endofprompt|>",
16
+ "lstrip": false,
17
+ "normalized": false,
18
+ "rstrip": false,
19
+ "single_word": false,
20
+ "special": true
21
+ },
22
+ "200019": {
23
+ "content": "<|assistant|>",
24
+ "lstrip": false,
25
+ "normalized": false,
26
+ "rstrip": true,
27
+ "single_word": false,
28
+ "special": true
29
+ },
30
+ "200020": {
31
+ "content": "<|end|>",
32
+ "lstrip": false,
33
+ "normalized": false,
34
+ "rstrip": true,
35
+ "single_word": false,
36
+ "special": true
37
+ },
38
+ "200021": {
39
+ "content": "<|user|>",
40
+ "lstrip": false,
41
+ "normalized": false,
42
+ "rstrip": true,
43
+ "single_word": false,
44
+ "special": true
45
+ },
46
+ "200022": {
47
+ "content": "<|system|>",
48
+ "lstrip": false,
49
+ "normalized": false,
50
+ "rstrip": true,
51
+ "single_word": false,
52
+ "special": true
53
+ },
54
+ "200023": {
55
+ "content": "<|tool|>",
56
+ "lstrip": false,
57
+ "normalized": false,
58
+ "rstrip": true,
59
+ "single_word": false,
60
+ "special": false
61
+ },
62
+ "200024": {
63
+ "content": "<|/tool|>",
64
+ "lstrip": false,
65
+ "normalized": false,
66
+ "rstrip": true,
67
+ "single_word": false,
68
+ "special": false
69
+ },
70
+ "200025": {
71
+ "content": "<|tool_call|>",
72
+ "lstrip": false,
73
+ "normalized": false,
74
+ "rstrip": true,
75
+ "single_word": false,
76
+ "special": false
77
+ },
78
+ "200026": {
79
+ "content": "<|/tool_call|>",
80
+ "lstrip": false,
81
+ "normalized": false,
82
+ "rstrip": true,
83
+ "single_word": false,
84
+ "special": false
85
+ },
86
+ "200027": {
87
+ "content": "<|tool_response|>",
88
+ "lstrip": false,
89
+ "normalized": false,
90
+ "rstrip": true,
91
+ "single_word": false,
92
+ "special": false
93
+ },
94
+ "200028": {
95
+ "content": "<|tag|>",
96
+ "lstrip": false,
97
+ "normalized": false,
98
+ "rstrip": true,
99
+ "single_word": false,
100
+ "special": true
101
+ }
102
+ },
103
+ "bos_token": "<|endoftext|>",
104
+ "chat_template": "{% for message in messages %}{% if message['role'] == 'system' and 'tools' in message and message['tools'] is not none %}{{ '<|' + message['role'] + '|>' + message['content'] + '<|tool|>' + message['tools'] + '<|/tool|>' + '<|end|>' }}{% else %}{{ '<|' + message['role'] + '|>' + message['content'] + '<|end|>' }}{% endif %}{% endfor %}{% if add_generation_prompt %}{{ '<|assistant|>' }}{% else %}{{ eos_token }}{% endif %}",
105
+ "clean_up_tokenization_spaces": false,
106
+ "eos_token": "<|endoftext|>",
107
+ "model_max_length": 131072,
108
+ "pad_token": "<|endoftext|>",
109
+ "tokenizer_class": "GPT2Tokenizer",
110
+ "unk_token": "<|endoftext|>"
111
+ }
vocab.json ADDED
The diff for this file is too large to render. See raw diff