styalai commited on
Commit
ec9433e
·
1 Parent(s): 1c45780

Add application file

Browse files
Files changed (1) hide show
  1. app.py +43 -0
app.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ with gr.Blocks() as app:
4
+ gr.Markdown("# Some calculs about LLMs")
5
+
6
+ def calculate_flops(n_params, n_tokens, n_epochs):
7
+ n_params *= 1e9
8
+ n_tokens *= 1e12
9
+ flops = 6 * n_params * n_tokens * n_epochs
10
+ return "%e"%flops, "%e"%flops
11
+
12
+ def calculate_time(num_flops, num_flops_gpu):
13
+ num_flops_gpu *= 1e12
14
+ num_flops = float(num_flops)
15
+ time_h = num_flops / num_flops_gpu / 3600
16
+ time_days = time_h / 24
17
+ return f"{round(time_h, 2)} hours or {round(time_days, 2)} days"
18
+
19
+
20
+ gr.Markdown("## FLOPs calculation")
21
+ with gr.Row():
22
+ num_params = gr.Number(label="Number of Parameters (in Billion)", value=1)
23
+ num_tokens = gr.Number(label="Number of Tokens (in Terra)", value=1)
24
+ num_epochs = gr.Number(label="Number of Epochs", value=1)
25
+
26
+ button_flops = gr.Button(value="calculate")
27
+ flops = gr.Textbox(label="flops")
28
+
29
+ gr.Markdown("## training time calculation")
30
+ with gr.Row():
31
+ num_flops = gr.Number(label="nbr Model FLOPs")
32
+ num_flops_gpu = gr.Number(label="nbr GPU TFLOPs", value=1)
33
+
34
+ button_time = gr.Button(value="calculate")
35
+ time = gr.Textbox(label="time")
36
+
37
+
38
+ button_flops.click(calculate_flops, inputs=[num_params, num_tokens, num_epochs], outputs=[flops, num_flops])
39
+ button_time.click(calculate_time, inputs=[num_flops, num_flops_gpu], outputs=time)
40
+
41
+
42
+
43
+ app.launch()