File size: 3,022 Bytes
938b63e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94975f5
 
 
 
 
 
 
938b63e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
"""LaunchReady Space: will this model fit on this GPU? A thin Gradio page over logic.py.

Stays anonymous even if a token is added to the Space later: a public page holding a token would
let anyone read gated repos through it. Both lines must run before huggingface_hub is imported.
"""

import os

os.environ.pop("HF_TOKEN", None)
os.environ["HF_HUB_DISABLE_IMPLICIT_TOKEN"] = "1"
os.environ["GRADIO_ANALYTICS_ENABLED"] = "False"

import gradio as gr  # noqa: E402
from logic import (  # noqa: E402
    DEFAULT_CONTEXT,
    DEFAULT_USERS,
    EXAMPLES,
    LIGHTNING,
    check,
    how_calculated_text,
    load_gpus,
    measured_text,
)

INTRO = """# LaunchReady

**Will this open model run on my NVIDIA GPU?**

Think of the model as a stack of papers and your GPU's memory as a desk. LaunchReady works out
whether the stack fits on the desk, with room left for everyone using it, before you download it.

Enter a model from Hugging Face and how you'd use it. Nothing is downloaded, and every result is a
projection, not a measurement.
"""
# Gradio breaks table cells mid-word on a phone; keep words whole and scroll the table instead.
CSS = """
.md table { display: block; overflow-x: auto; }
.md th, .md td { word-break: normal; overflow-wrap: normal; }
"""


def run(repo_id, gpu_id, context, users):
    page = check(repo_id, gpu_id, context, users)
    return page.verdict, page.memory, page.warnings, page.variants


gpus = load_gpus()

with gr.Blocks(title="LaunchReady") as demo:
    gr.Markdown(INTRO)
    repo = gr.Textbox(
        label="Model",
        value=LIGHTNING,
        info="A Hugging Face model id or link, like Qwen/Qwen3-4B",
        lines=1,
        max_lines=1,
    )
    with gr.Row():
        gpu = gr.Dropdown(label="GPU", choices=[(g.name, g.id) for g in gpus], value="rtx-5090")
        context = gr.Number(
            label="Context length",
            value=DEFAULT_CONTEXT,
            precision=0,
            minimum=1,
            info="Tokens per conversation",
        )
        users = gr.Number(
            label="Number of users",
            value=DEFAULT_USERS,
            precision=0,
            minimum=1,
            info="At the same time",
        )
    inputs = [repo, gpu, context, users]
    example_row = gr.Column()
    button = gr.Button("Check", variant="primary")
    verdict = gr.Markdown("Press **Check**, or pick an example above.")
    memory = gr.Markdown()
    warnings = gr.Markdown()
    variants = gr.Markdown()

    outputs = [verdict, memory, warnings, variants]
    button.click(run, inputs, outputs)
    repo.submit(run, inputs, outputs)
    with example_row:
        gr.Examples(
            examples=EXAMPLES,
            inputs=inputs,
            outputs=outputs,
            fn=run,
            run_on_click=True,
            cache_examples=False,
            label="Examples: click one to run it",
        )
    gr.Markdown(how_calculated_text(gpus))
    gr.Markdown(measured_text())

if __name__ == "__main__":
    demo.launch(css=CSS)