drawais commited on
Commit
76fdae2
·
verified ·
1 Parent(s): 662a43d

Initial upload of Phi-4-reasoning-NVFP4

Browse files
Files changed (10) hide show
  1. LICENSE +21 -0
  2. NOTICE +6 -0
  3. README.md +57 -0
  4. chat_template.jinja +1 -0
  5. config.json +85 -0
  6. generation_config.json +11 -0
  7. model.safetensors +3 -0
  8. recipe.yaml +7 -0
  9. tokenizer.json +0 -0
  10. tokenizer_config.json +13 -0
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2024 DeepSeek
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
NOTICE ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ NOTICE
2
+
3
+ This artifact is a derivative work of microsoft/Phi-4-reasoning, distributed under the MIT License.
4
+ The full license text is in the LICENSE file at the root of this repository.
5
+
6
+ Source model: https://huggingface.co/microsoft/Phi-4-reasoning
README.md ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ license_link: https://opensource.org/license/mit
4
+ base_model: microsoft/Phi-4-reasoning
5
+ tags:
6
+ - quantized
7
+ - 4-bit
8
+ - int4
9
+ - awq
10
+ language:
11
+ - en
12
+ library_name: transformers
13
+ pipeline_tag: text-generation
14
+ ---
15
+
16
+ # Phi-4-reasoning-NVFP4
17
+
18
+ INT4 weight-only quantization of [`microsoft/Phi-4-reasoning`](https://huggingface.co/microsoft/Phi-4-reasoning).
19
+
20
+ Microsoft Phi-4-reasoning in NVFP4 W4A4. Native vLLM compressed-tensors. About 8 GB on disk.
21
+
22
+ | Property | Value |
23
+ |---|---|
24
+ | Base model | [microsoft/Phi-4-reasoning](https://huggingface.co/microsoft/Phi-4-reasoning) |
25
+ | Quantization | INT4 weight-only |
26
+ | Approx. on-disk size | ~9.7 GB |
27
+ | License | MIT License |
28
+ | Languages | English |
29
+
30
+ ## Load (vLLM)
31
+
32
+ ```bash
33
+ vllm serve drawais/Phi-4-reasoning-NVFP4 \
34
+ --max-model-len 32768 \
35
+ --gpu-memory-utilization 0.94
36
+ ```
37
+
38
+ ```python
39
+ from vllm import LLM, SamplingParams
40
+ llm = LLM(model="drawais/Phi-4-reasoning-NVFP4", max_model_len=32768)
41
+ print(llm.generate(["Hello!"], SamplingParams(max_tokens=128))[0].outputs[0].text)
42
+ ```
43
+
44
+ ## Footprint
45
+
46
+ ~9.7 GB on disk. Recommended VRAM: enough headroom for KV cache.
47
+
48
+ ## License & attribution
49
+
50
+ This artifact is a derivative work of [`microsoft/Phi-4-reasoning`](https://huggingface.co/microsoft/Phi-4-reasoning),
51
+ released by its original authors under the **MIT License**.
52
+
53
+ This artifact is distributed under the same license. The full license text is
54
+ included in [`LICENSE`](LICENSE), and required attribution is in [`NOTICE`](NOTICE).
55
+
56
+ License text: https://opensource.org/license/mit
57
+ Source model: https://huggingface.co/microsoft/Phi-4-reasoning
chat_template.jinja ADDED
@@ -0,0 +1 @@
 
 
1
+ <|im_start|>system<|im_sep|>You are Phi, a language model trained by Microsoft to help users. Your role as an assistant involves thoroughly exploring questions through a systematic thinking process before providing the final precise and accurate solutions. This requires engaging in a comprehensive cycle of analysis, summarizing, exploration, reassessment, reflection, backtracing, and iteration to develop well-considered thinking process. Please structure your response into two main sections: Thought and Solution using the specified format: <think> {Thought section} </think> {Solution section}. In the Thought section, detail your reasoning process in steps. Each step should include detailed considerations such as analysing questions, summarizing relevant findings, brainstorming new ideas, verifying the accuracy of the current steps, refining any errors, and revisiting previous steps. In the Solution section, based on various attempts, explorations, and reflections from the Thought section, systematically present the final solution that you deem correct. The Solution section should be logical, accurate, and concise and detail necessary steps needed to reach the conclusion. Now, try to solve the following question through the above guidelines:<|im_end|>{% for message in messages %}{% if (message['role'] == 'user') %}{{'<|im_start|>user<|im_sep|>' + message['content'] + '<|im_end|>'}}{% elif (message['role'] == 'assistant') %}{{'<|im_start|>assistant<|im_sep|>'}}{% generation %}{{message['content'] + '<|im_end|>'}}{% endgeneration %}{% endif %}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant<|im_sep|>' }}{% endif %}
config.json ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Phi3ForCausalLM"
4
+ ],
5
+ "attention_bias": false,
6
+ "attention_dropout": 0.0,
7
+ "bos_token_id": 100257,
8
+ "dtype": "bfloat16",
9
+ "embd_pdrop": 0.0,
10
+ "eos_token_id": 100265,
11
+ "hidden_act": "silu",
12
+ "hidden_size": 5120,
13
+ "initializer_range": 0.02,
14
+ "intermediate_size": 17920,
15
+ "max_position_embeddings": 32768,
16
+ "model_type": "phi3",
17
+ "num_attention_heads": 40,
18
+ "num_hidden_layers": 40,
19
+ "num_key_value_heads": 10,
20
+ "original_max_position_embeddings": 32768,
21
+ "pad_token_id": 100349,
22
+ "partial_rotary_factor": 1.0,
23
+ "quantization_config": {
24
+ "config_groups": {
25
+ "group_0": {
26
+ "format": "nvfp4-pack-quantized",
27
+ "input_activations": {
28
+ "actorder": null,
29
+ "block_structure": null,
30
+ "dynamic": "local",
31
+ "group_size": 16,
32
+ "num_bits": 4,
33
+ "observer": "static_minmax",
34
+ "observer_kwargs": {},
35
+ "scale_dtype": "torch.float8_e4m3fn",
36
+ "strategy": "tensor_group",
37
+ "symmetric": true,
38
+ "type": "float",
39
+ "zp_dtype": null
40
+ },
41
+ "output_activations": null,
42
+ "targets": [
43
+ "Linear"
44
+ ],
45
+ "weights": {
46
+ "actorder": null,
47
+ "block_structure": null,
48
+ "dynamic": false,
49
+ "group_size": 16,
50
+ "num_bits": 4,
51
+ "observer": "memoryless_minmax",
52
+ "observer_kwargs": {},
53
+ "scale_dtype": "torch.float8_e4m3fn",
54
+ "strategy": "tensor_group",
55
+ "symmetric": true,
56
+ "type": "float",
57
+ "zp_dtype": null
58
+ }
59
+ }
60
+ },
61
+ "format": "nvfp4-pack-quantized",
62
+ "global_compression_ratio": null,
63
+ "ignore": [
64
+ "lm_head"
65
+ ],
66
+ "kv_cache_scheme": null,
67
+ "quant_method": "compressed-tensors",
68
+ "quantization_status": "compressed",
69
+ "sparsity_config": {},
70
+ "transform_config": {},
71
+ "version": "0.15.1.a20260428"
72
+ },
73
+ "resid_pdrop": 0.0,
74
+ "rms_norm_eps": 1e-05,
75
+ "rope_parameters": {
76
+ "partial_rotary_factor": 1.0,
77
+ "rope_theta": 500000,
78
+ "rope_type": "default"
79
+ },
80
+ "sliding_window": null,
81
+ "tie_word_embeddings": false,
82
+ "transformers_version": "5.8.0.dev0",
83
+ "use_cache": true,
84
+ "vocab_size": 100352
85
+ }
generation_config.json ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 100257,
4
+ "do_sample": true,
5
+ "eos_token_id": 100265,
6
+ "pad_token_id": 100349,
7
+ "temperature": 0.8,
8
+ "top_k": 50,
9
+ "top_p": 0.95,
10
+ "transformers_version": "5.8.0.dev0"
11
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f075dbd759c6d7fc9d9c39cb58a5ac8dbd94598a61afe7d9acf82ac0054d7910
3
+ size 9723835440
recipe.yaml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ default_stage:
2
+ default_modifiers:
3
+ QuantizationModifier:
4
+ targets: [Linear]
5
+ ignore: [lm_head, 're:.*embed.*', 're:.*router.*']
6
+ scheme: NVFP4
7
+ bypass_divisibility_checks: false
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "backend": "tokenizers",
4
+ "bos_token": "<|endoftext|>",
5
+ "clean_up_tokenization_spaces": false,
6
+ "eos_token": "<|im_end|>",
7
+ "is_local": false,
8
+ "local_files_only": false,
9
+ "model_max_length": 32768,
10
+ "pad_token": "<|dummy_85|>",
11
+ "padding_side": "left",
12
+ "tokenizer_class": "TokenizersBackend"
13
+ }