lvwerra HF staff commited on
Commit
e041ed4
1 Parent(s): 34f1dfd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -4
app.py CHANGED
@@ -47,10 +47,9 @@ def plot_curve(kn, kd):
47
  plt.xlabel("Fraction of compute optimal model size")
48
  plt.ylabel("Compute overhead (%)")
49
 
50
- with gr.Blocks() as demo:
51
- N = gr.Number(value=1, label="Model size (in B parameters)")
52
- D = gr.Number(value=100, label="Dataset size (in B tokens")
53
 
 
 
54
  C = to_flops(N * Bn, D * Bn)
55
  N_opt = n_opt(C)
56
  D_opt = d_opt(C)
@@ -59,7 +58,17 @@ with gr.Blocks() as demo:
59
 
60
  plot_curve(kn, 100*overhead(kn, get_kd(kn)))
61
 
 
 
 
 
 
 
 
 
62
  gr.Plot(value=plt)
63
- gr.Markdown(f"""Compute budget (TFLOPs): {C:.2E}\nTraining compute overhead (%): {100*overhead(kn, get_kd(kn)):.2f}\nInference cost fraction (%): {kn*100:.2f}""")
 
 
64
 
65
  demo.launch()
 
47
  plt.xlabel("Fraction of compute optimal model size")
48
  plt.ylabel("Compute overhead (%)")
49
 
 
 
 
50
 
51
+
52
+ def compute(N, D):
53
  C = to_flops(N * Bn, D * Bn)
54
  N_opt = n_opt(C)
55
  D_opt = d_opt(C)
 
58
 
59
  plot_curve(kn, 100*overhead(kn, get_kd(kn)))
60
 
61
+ text = f"""Compute budget (TFLOPs): {C:.2E}\nTraining compute overhead (%): {100*overhead(kn, get_kd(kn)):.2f}\nInference cost fraction (%): {kn*100:.2f}"""
62
+ return text
63
+
64
+ with gr.Blocks() as demo:
65
+ N = gr.Number(value=1, label="Model size (in B parameters)")
66
+ D = gr.Number(value=100, label="Dataset size (in B tokens")
67
+ button = gr.Button("Compute!")
68
+
69
  gr.Plot(value=plt)
70
+ md = gr.Markdown(f"""{}""")
71
+
72
+ button.click(fn=, inputs=[N, D], ouptus=[md])
73
 
74
  demo.launch()