Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
def calculate_effective_batch_size(ctx_len, num_gpus, bsz, accum):
|
| 4 |
+
eff_bsz_tokens = ctx_len * num_gpus * bsz * accum
|
| 5 |
+
return "{:,}".format(eff_bsz_tokens) # Format with commas for readability
|
| 6 |
+
with gr.Blocks() as demo:
|
| 7 |
+
gr.Markdown("## Effective Batch Size Calculator")
|
| 8 |
+
with gr.Row():
|
| 9 |
+
ctx_len = gr.Number(label="Context Length", value=16000)
|
| 10 |
+
num_gpus = gr.Number(label="Number of GPUs", value=2)
|
| 11 |
+
bsz = gr.Number(label="Batch Size", value=2)
|
| 12 |
+
accum = gr.Number(label="Gradient Accumulation Steps", value=32)
|
| 13 |
+
output = gr.Textbox(label="Effective Batch Size in Tokens") # Changed to Textbox for formatted output
|
| 14 |
+
btn = gr.Button("Calculate")
|
| 15 |
+
btn.click(
|
| 16 |
+
fn=calculate_effective_batch_size,
|
| 17 |
+
inputs=[ctx_len, num_gpus, bsz, accum],
|
| 18 |
+
outputs=output
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
+
demo.launch()
|