File size: 862 Bytes
f2efe9b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import gradio as gr

def calculate_effective_batch_size(ctx_len, num_gpus, bsz, accum):
    eff_bsz_tokens = ctx_len * num_gpus * bsz * accum
    return "{:,}".format(eff_bsz_tokens)  # Format with commas for readability
with gr.Blocks() as demo:
    gr.Markdown("## Effective Batch Size Calculator")
    with gr.Row():
        ctx_len = gr.Number(label="Context Length", value=16000)
        num_gpus = gr.Number(label="Number of GPUs", value=2)
        bsz = gr.Number(label="Batch Size", value=2)
        accum = gr.Number(label="Gradient Accumulation Steps", value=32)
    output = gr.Textbox(label="Effective Batch Size in Tokens")  # Changed to Textbox for formatted output
    btn = gr.Button("Calculate")
    btn.click(
        fn=calculate_effective_batch_size,
        inputs=[ctx_len, num_gpus, bsz, accum],
        outputs=output
    )

demo.launch()