-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathtest.py
More file actions
44 lines (31 loc) · 1.16 KB
/
test.py
File metadata and controls
44 lines (31 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import subprocess
def parse_prompts(filepath):
with open(filepath, 'r') as file:
arr = file.read().split('\n\n')
arr = [prompt.strip() for prompt in arr if prompt.strip()]
return arr
def parse_prompt_data(filepath):
with open(filepath, 'r') as file:
content = file.read()
blocks = content.split('\n')
if blocks[-1] == '':
blocks = blocks[0:-1]
return [block.split(',') for block in blocks]
def main():
prompts = parse_prompts("prompts.txt")
prompt_data = parse_prompt_data("prompt_data.txt")
assert len(prompts) == len(prompt_data)
mode = "evaluate"
# Iterate through the prompts
for i, prompt in enumerate(prompts):
data = prompt_data[i]
seq_len = data[2]
latency = data[3]
throughput = data[4]
command = f'python main.py --enable-nki --mode {mode} --seq-len {seq_len} --base-latency {latency} --base-throughput {throughput} --prompt "{prompt}"'
print(command)
with open(f'prompt{i}_out.txt', 'w') as outfile:
subprocess.run(command, shell=True, stdout=outfile)
print("")
if __name__ == "__main__":
main()