Create compile.py
Browse files- compile.py +29 -0
compile.py
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from huggingface_hub.hf_api import HfFolder
|
2 |
+
from huggingface_hub import login
|
3 |
+
from optimum.neuron import NeuronModelForCausalLM
|
4 |
+
import os
|
5 |
+
|
6 |
+
hf_token="hf_TBD"
|
7 |
+
sequence_length=256
|
8 |
+
auto_cast_type="bf16"
|
9 |
+
batch_size=8
|
10 |
+
num_cores=16
|
11 |
+
hf_repo="yahavb/DeepSeek-R1-Distill-Llama-70B-Neuron"
|
12 |
+
model_dir="/deepseek-ai/DeepSeek-R1-Distill-Llama-70B"
|
13 |
+
model_id="deepseek-ai/DeepSeek-R1-Distill-Llama-70B"
|
14 |
+
|
15 |
+
from huggingface_hub.hf_api import HfFolder
|
16 |
+
from huggingface_hub import login
|
17 |
+
from optimum.neuron import NeuronModelForCausalLM
|
18 |
+
|
19 |
+
login(hf_token,add_to_git_credential=True)
|
20 |
+
|
21 |
+
compiler_args = {"num_cores": num_cores, "auto_cast_type": auto_cast_type}
|
22 |
+
input_shapes = {"batch_size": batch_size, "sequence_length": sequence_length}
|
23 |
+
model = NeuronModelForCausalLM.from_pretrained(
|
24 |
+
model_id,
|
25 |
+
export=True,
|
26 |
+
**compiler_args,
|
27 |
+
**input_shapes)
|
28 |
+
model.save_pretrained(model_dir)
|
29 |
+
model.push_to_hub(model_dir,repository_id=hf_repo)
|