Spaces:
Sleeping
Sleeping
Commit ·
fc989b4
1
Parent(s): ab92e0d
Add dynamic GPU time estimate indicator to UI
Browse files- Shows estimated GPU seconds for current inference settings
- Updates in real-time when model, search settings, or max tokens change
- Displays model size, AOT status, and search status
- Helps users manage precious ZeroGPU time budget effectively
613 unmodified lines6146156166176186196206216226236246256266276286296306316326336346356366376386396406415 unmodified lines64764864965065165265365465565665765811 unmodified lines670671672673674675676677678679680681682683684685686687688689690691692693694695613 unmodified linesdef update_default_prompt(enable_search): return f"You are a helpful assistant."
def update_duration_estimate(model_name, enable_search, max_results, max_chars, max_tokens, search_timeout): """Calculate and format the estimated GPU duration for current settings.""" try: # Create dummy values for the other parameters that get_duration expects dummy_msg = "" dummy_history = [] dummy_system_prompt = "" duration = get_duration(dummy_msg, dummy_history, dummy_system_prompt, enable_search, max_results, max_chars, model_name, max_tokens, 0.7, 40, 0.9, 1.2, search_timeout) model_size = MODELS[model_name].get("params_b", 4.0) use_aot = model_size >= 2 return f"⏱️ **Estimated GPU Time: {duration:.1f} seconds**\n\n" \ f"📊 **Model Size:** {model_size:.1f}B parameters\n" \ f"⚡ **AOT Compilation:** {'Enabled' if use_aot else 'Disabled'}\n" \ f"🔍 **Web Search:** {'Enabled' if enable_search else 'Disabled'}" except Exception as e: return f"⚠️ Error calculating estimate: {e}"
# ------------------------------# Gradio UI# ------------------------------5 unmodified lines model_dd = gr.Dropdown(label="Select Model", choices=list(MODELS.keys()), value="Qwen3-1.7B") search_chk = gr.Checkbox(label="Enable Web Search", value=False) sys_prompt = gr.Textbox(label="System Prompt", lines=3, value=update_default_prompt(search_chk.value)) # GPU Time Estimate Display duration_display = gr.Markdown(value=update_duration_estimate( "Qwen3-1.7B", False, 4, 50, 1024, 5.0 )) gr.Markdown("### Generation Parameters") max_tok = gr.Slider(64, 16384, value=1024, step=32, label="Max Tokens") temp = gr.Slider(0.1, 2.0, value=0.7, step=0.1, label="Temperature")11 unmodified lines txt = gr.Textbox(placeholder="Type your message and press Enter...") dbg = gr.Markdown()
# Update duration estimate when relevant inputs change model_dd.change(fn=update_duration_estimate, inputs=[model_dd, search_chk, mr, mc, max_tok, st], outputs=duration_display) search_chk.change(fn=update_duration_estimate, inputs=[model_dd, search_chk, mr, mc, max_tok, st], outputs=duration_display) max_tok.change(fn=update_duration_estimate, inputs=[model_dd, search_chk, mr, mc, max_tok, st], outputs=duration_display) mr.change(fn=update_duration_estimate, inputs=[model_dd, search_chk, mr, mc, max_tok, st], outputs=duration_display) mc.change(fn=update_duration_estimate, inputs=[model_dd, search_chk, mr, mc, max_tok, st], outputs=duration_display) st.change(fn=update_duration_estimate, inputs=[model_dd, search_chk, mr, mc, max_tok, st], outputs=duration_display)
search_chk.change(fn=update_default_prompt, inputs=search_chk, outputs=sys_prompt) clr.click(fn=lambda: ([], "", ""), outputs=[chat, txt, dbg]) cnl.click(fn=cancel_generation, outputs=dbg)app.py+48