DedeProGames commited on
Commit
e3da13f
·
verified ·
1 Parent(s): 9de8b8a

Season 5 pool: - Supra-Mini-v5-8M, Supra1.5-50M-Base-exp, SupraGDN-5M, LowOnMind-1M, BananaMind-2.1-Unified, BananaMind-2-Mini, DynamicMind-MoE; + SmolLM-135M, SmolLM2-135M, Rose-1.5-Medium, Rose-Mini, Boris-1.3-75M

Browse files
Files changed (1) hide show
  1. app.py +1 -386
app.py CHANGED
@@ -1,386 +1 @@
1
- """SLM Tetris Arena — decoder-only LMs play Tetris zero-shot and earn Elo."""
2
- import os
3
-
4
- # Keep the write token out of the environment before any model code runs:
5
- # only the results store receives it (custom model code runs in this process).
6
- _TOKEN = os.environ.pop("HF_TOKEN", None) or os.environ.pop("HUGGING_FACE_HUB_TOKEN", None)
7
- os.environ.setdefault("HF_HUB_DISABLE_PROGRESS_BARS", "1")
8
-
9
- import html
10
- import inspect
11
- import random
12
- import time
13
-
14
- import gradio as gr
15
- import torch
16
-
17
- from arena import MAX_PIECES, SEASON, ResultsStore, choose, rank_games
18
- from leaderboard import LB_CSS, leaderboard_html
19
- from leaderboard import fmt_params as short_params
20
- from players import (BASELINES, MAX_PARAMS, MIN_PARAMS, ORACLE_ID, PROMPTS, RANDOM_ID, ModelRejected, OracleReaderPlayer,
21
- RandomPlayer, fmt_params, load_player, precheck)
22
- from ranked import Pool, RankedRunner
23
- from render import CSS, arena_html, empty_html, results_html
24
- from tetris import TetrisGame
25
-
26
- # cpu-basic Spaces have 2 vCPUs; os.cpu_count() reports the host, which oversubscribes threads
27
- torch.set_num_threads(int(os.environ.get("TORCH_THREADS", 2)))
28
-
29
- RESULTS_REPO = os.environ.get("RESULTS_REPO", "DedeProGames/lm-tetris-arena-results")
30
- MAX_MODELS = int(os.environ.get("MAX_MODELS", 4))
31
- # Optional size limit for the random ranked pick (0 = none). Without it every model can meet every other, so all
32
- # ratings sit on one comparable scale; Elo already weighs each win by the opponent's rating, so beating a much
33
- # weaker model earns almost nothing once ratings have settled.
34
- MAX_PARAM_GAP = int(os.environ.get("MAX_PARAM_GAP", 0))
35
- # ...with a gap, models this size or bigger can still all play each other
36
- LARGE_FROM = int(os.environ.get("LARGE_FROM", 100_000_000))
37
- if MAX_PARAM_GAP:
38
- SIZE_RULE = (f"all within ±{short_params(MAX_PARAM_GAP)} parameters of each other "
39
- f"(models with {short_params(LARGE_FROM)}+ parameters can all play each other)")
40
- else:
41
- SIZE_RULE = "of any size (Elo weighs every win by the opponent's rating, so all models share one scale)"
42
-
43
- SUGGESTED = [
44
- 'AxiomicLabs/GPT-S-1.4M',
45
- 'AxiomicLabs/GPT-S2-5M',
46
- 'AxiomicLabs/GPT-X2.5-135M',
47
- 'BananaMind/BananaMind-2-Medium',
48
- 'BananaMind/BananaMind-2-Mini',
49
- 'BananaMind/BananaMind-2-Nano',
50
- 'BananaMind/BananaMind-2-Pro',
51
- 'BananaMind/BananaMind-2.1-Pico-Preview',
52
- 'BananaMind/BananaMind-2.1-Unified',
53
- 'DedeBckp/BackKiyo-10M',
54
- 'DedeProGames/DynamicMind-Mini',
55
- 'DedeProGames/DynamicMind-MoE',
56
- 'DedeProGames/GPT-U-20M',
57
- 'DedeProGames/Kiyo-230M-Preview',
58
- 'DedeProGames/Kiyo-65M',
59
- 'DedeProGames/LowOnMind-1M',
60
- 'DedeProGames/LowOnMind-5M',
61
- 'DedeProGames/Overaddicted-500K',
62
- 'DedeProGames/Wisp-15M',
63
- 'DedeProGames/Wisp-5M',
64
- 'openai-community/gpt2',
65
- 'SupraLabs/Supra-Mini-v5-8M',
66
- 'SupraLabs/Supra1.5-50M-Base-exp',
67
- 'SupraLabs/Supra2-100M-Base',
68
- 'SupraLabs/Supra2-Medium-Base',
69
- 'SupraLabs/SupraGDN-5M',
70
- 'SupraLabs/SupraNeo-4M',
71
- 'veyra-ai/Veyra2-Apricot-50M-Base',
72
- 'veyra-ai/Veyra2-Blueberry-5M-Base',
73
- 'veyra-ai/Veyra2-Mango-30M-Base',
74
- ]
75
- DEFAULT_MODELS = ["DedeProGames/Kiyo-65M", "BananaMind/BananaMind-2-Medium", "DedeProGames/DynamicMind-MoE", "SupraLabs/Supra2-Medium-Base"]
76
- # The leaderboard only keeps pool models: removing a model from SUGGESTED also removes it from the leaderboard.
77
- STORE = ResultsStore(RESULTS_REPO, _TOKEN, min_params=MIN_PARAMS, allowed=SUGGESTED)
78
- # Ranked: the arena picks the players at random from the suggested models (nobody chooses who plays)
79
- POOL = Pool(SUGGESTED, MAX_PARAM_GAP, MAX_MODELS, LARGE_FROM)
80
- RANKED = RankedRunner(POOL, STORE)
81
- PROTOCOL_CHOICES = [("Guided: the rules are in the prompt", "guided"), ("Blind: no rules, only pre-training knowledge", "blind")]
82
- BASELINE_CHOICES = [(label, key) for key, label in BASELINES.items()]
83
-
84
- # ---- Look & feel: BananaMind SLM Leaderboard palette and type (dark + light), light-blue accent ----
85
- _D = dict(bg="#0b0e0d", surface="#111613", surface2="#191e1b", text="#f0f1ec", muted="#929b93", line="#29312c", accent="#4d9fff")
86
- _L = dict(bg="#f4f5f1", surface="#ffffff", surface2="#edf0e9", text="#17221b", muted="#626e64", line="#d7ded5", accent="#1b64c4")
87
- _CHECK = ("url(\"data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='%2307182e' xmlns='http://www.w3.org/2000/svg'%3e"
88
- "%3cpath d='M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2-2a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z'/%3e%3c/svg%3e\")")
89
-
90
-
91
- _THEME_KEYS = set(inspect.signature(gr.themes.Base.set).parameters)
92
-
93
-
94
- def _both(**pairs):
95
- """name=(light, dark) -> theme kwargs for both modes (skips variables this Gradio version lacks)."""
96
- out = {}
97
- for k, (light, dark) in pairs.items():
98
- if k in _THEME_KEYS:
99
- out[k] = light
100
- if k + "_dark" in _THEME_KEYS:
101
- out[k + "_dark"] = dark
102
- return out
103
-
104
-
105
- THEME = gr.themes.Base(
106
- primary_hue=gr.themes.colors.blue, secondary_hue=gr.themes.colors.blue, neutral_hue=gr.themes.colors.stone,
107
- font=[gr.themes.GoogleFont("DM Sans"), "Arial", "sans-serif"], font_mono=["ui-monospace", "SFMono-Regular", "monospace"],
108
- ).set(
109
- block_border_width="1px", block_radius="13px", block_label_border_width="0px", block_title_text_weight="500",
110
- input_radius="8px", checkbox_check=_CHECK,
111
- **_both(
112
- body_background_fill=(_L["bg"], _D["bg"]), body_text_color=(_L["text"], _D["text"]),
113
- body_text_color_subdued=(_L["muted"], _D["muted"]),
114
- background_fill_primary=(_L["surface"], _D["surface"]), background_fill_secondary=(_L["surface2"], _D["surface2"]),
115
- block_background_fill=(_L["surface"], _D["surface"]), block_border_color=(_L["line"], _D["line"]),
116
- block_shadow=("none", "none"), block_label_background_fill=("transparent", "transparent"),
117
- block_label_text_color=(_L["muted"], _D["muted"]), block_label_shadow=("none", "none"),
118
- block_title_background_fill=("transparent", "transparent"), block_title_text_color=(_L["muted"], _D["muted"]),
119
- block_info_text_color=(_L["muted"], _D["muted"]),
120
- border_color_primary=(_L["line"], _D["line"]), border_color_accent=("#4d9fff", "#4d9fff"),
121
- color_accent=("#4d9fff", "#4d9fff"), color_accent_soft=("#4d9fff26", "#4d9fff26"),
122
- input_background_fill=(_L["surface2"], _D["surface2"]), input_border_color=(_L["line"], _D["line"]),
123
- input_border_color_focus=("#4d9fff", "#4d9fff"),
124
- button_primary_background_fill=("#4d9fff", "#4d9fff"), button_primary_background_fill_hover=("#74b4ff", "#74b4ff"),
125
- button_primary_text_color=("#07182e", "#07182e"), button_primary_border_color=("#4d9fff", "#4d9fff"),
126
- button_secondary_background_fill=(_L["surface2"], _D["surface2"]),
127
- button_secondary_background_fill_hover=(_L["line"], _D["line"]),
128
- button_secondary_text_color=(_L["text"], _D["text"]), button_secondary_border_color=(_L["line"], _D["line"]),
129
- checkbox_background_color_selected=("#4d9fff", "#4d9fff"), checkbox_border_color_selected=("#4d9fff", "#4d9fff"),
130
- checkbox_label_background_fill=(_L["surface2"], _D["surface2"]),
131
- checkbox_label_background_fill_selected=(_L["surface2"], _D["surface2"]),
132
- checkbox_label_border_color=(_L["line"], _D["line"]), checkbox_label_border_color_selected=("#4d9fff", "#4d9fff"),
133
- checkbox_label_text_color_selected=(_L["text"], _D["text"]),
134
- slider_color=("#4d9fff", "#4d9fff"), loader_color=("#4d9fff", "#4d9fff"),
135
- link_text_color=(_L["accent"], _D["accent"]), link_text_color_hover=(_L["accent"], _D["accent"]),
136
- panel_background_fill=(_L["surface"], _D["surface"]), panel_border_color=(_L["line"], _D["line"]),
137
- table_border_color=(_L["line"], _D["line"]), code_background_fill=(_L["surface2"], _D["surface2"]),
138
- ),
139
- )
140
-
141
- APP_CSS = """
142
- @import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Space+Grotesk:wght@400;500;600;700&family=Press+Start+2P&display=swap');
143
- .gradio-container{font-family:'DM Sans',Arial,sans-serif!important}
144
- .gradio-container h1,.gradio-container h2,.gradio-container h3{font-family:'Space Grotesk',Arial,sans-serif!important;letter-spacing:-.4px}
145
- .ah-heading{display:flex;justify-content:space-between;align-items:center;gap:20px;padding:10px 0 6px}
146
- .ah-eyebrow{font:11px/1.5 monospace!important;letter-spacing:1.9px;color:var(--body-text-color-subdued)!important;margin:0 0 10px!important}
147
- .ah-heading h1{font:500 clamp(32px,4vw,48px)/1.2 'Space Grotesk',Arial,sans-serif!important;letter-spacing:-2px!important;margin:0!important;
148
- color:var(--body-text-color)!important}
149
- .ah-accent{color:#1b64c4}.dark .ah-accent{color:#4d9fff}
150
- .ah-intro{margin:10px 0 0!important;font-size:15px!important;color:var(--body-text-color-subdued)!important;max-width:860px}
151
- .ah-version{font:11px monospace;letter-spacing:1px;color:var(--body-text-color-subdued);display:flex;align-items:center;gap:10px;white-space:nowrap}
152
- .ah-dot{height:6px;width:6px;background:#95c79a;border-radius:50%}
153
- .ah-note{margin:0 0 4px!important;font-size:14px!important;line-height:1.55;color:var(--body-text-color-subdued)!important;max-width:900px}
154
- .ah-note b{color:var(--body-text-color)}
155
- .ah-warn{margin-top:14px;padding:10px 14px;border:1px solid #4d9fff66;border-radius:8px;font-size:13px;color:var(--body-text-color)}
156
- button[role=tab]{font-size:14px!important;color:var(--body-text-color-subdued)!important}
157
- button[role=tab][aria-selected=true]{color:var(--body-text-color)!important;border-color:#4d9fff!important}
158
- @media(max-width:550px){.ah-version{display:none}}
159
- """
160
-
161
-
162
- def _status(text, kind="info"):
163
- icon = {"info": "⏳", "ok": "✅", "err": "⛔", "warn": "⚠️"}[kind]
164
- return f"{icon} {text}"
165
-
166
-
167
- def run_match(model_ids, baselines, protocol, seed, delay):
168
- """Friendly match: any models, any seed, nothing is recorded (Elo only changes in the Ranked tab)."""
169
- model_ids = [m.strip() for m in (model_ids or []) if m and m.strip()]
170
- model_ids = list(dict.fromkeys(model_ids))
171
- baselines = baselines or []
172
- protocol = protocol or "guided"
173
- if not model_ids:
174
- yield _status("Pick at least one language model.", "err"), empty_html(), ""
175
- return
176
- if len(model_ids) > MAX_MODELS:
177
- yield _status(f"At most {MAX_MODELS} language models per match on this CPU.", "err"), empty_html(), ""
178
- return
179
- if len(model_ids) + len(baselines) < 2:
180
- yield _status("A match needs at least 2 players: add another model or a baseline.", "err"), empty_html(), ""
181
- return
182
-
183
- players = []
184
- try:
185
- metas = []
186
- for m in model_ids:
187
- yield _status(f"Checking `{m}`…"), empty_html("Checking models…"), ""
188
- meta = precheck(m)
189
- if any(x["id"] == meta["id"] for x in metas):
190
- continue # same repo typed twice with different casing
191
- metas.append(meta)
192
- model_ids = [x["id"] for x in metas]
193
- for i, (m, meta) in enumerate(zip(model_ids, metas), 1):
194
- yield _status(f"Loading `{m}` on CPU ({i}/{len(model_ids)})… first load downloads the weights."), empty_html("Loading models…"), ""
195
- players.append(load_player(m, meta))
196
- except ModelRejected as e:
197
- yield _status(str(e), "err"), empty_html("Match cancelled."), ""
198
- return
199
- if RANDOM_ID in baselines:
200
- players.append(RandomPlayer())
201
- if ORACLE_ID in baselines:
202
- players.append(OracleReaderPlayer())
203
-
204
- seed = int(seed) if seed else random.SystemRandom().randrange(1, 10**9)
205
- games = [TetrisGame(seed) for _ in players]
206
- mode = "friendly"
207
- yield _status(f"Seed {seed} · {protocol} · {mode}. Scoring the first moves…"), arena_html(games, players), ""
208
-
209
- last = time.time()
210
- try:
211
- while True:
212
- active = [(g, p) for g, p in zip(games, players) if g.alive and g.pieces < MAX_PIECES]
213
- if not active:
214
- break
215
- for g, p in active:
216
- choose(g, p, protocol, seed)
217
- elapsed = time.time() - last
218
- if elapsed < delay:
219
- time.sleep(delay - elapsed)
220
- last = time.time()
221
- n = max(g.pieces for g in games)
222
- alive = sum(g.alive for g in games)
223
- yield _status(f"Seed {seed} · {protocol} · {mode} · piece {n}/{MAX_PIECES} · {alive} still playing"), arena_html(games, players), ""
224
- except ModelRejected as e:
225
- yield _status(str(e), "err"), arena_html(games, players), ""
226
- return
227
- except Exception as e:
228
- yield _status(f"A model crashed during play: {type(e).__name__}: {str(e)[:200]}", "err"), arena_html(games, players), ""
229
- return
230
-
231
- ranks = rank_games(games)
232
- order = sorted(range(len(players)), key=lambda i: ranks[i])
233
- elos = None
234
- note = "Friendly match: Elo not changed (only matches in the Ranked tab count)."
235
- note += f" Ranking: score, then lines, then pieces survived. ✓ = still alive at the {MAX_PIECES}-piece cap."
236
- results = results_html(order, ranks, players, games, elos, note)
237
- yield _status(f"Match finished · seed {seed} · {protocol} · {mode}.", "ok"), arena_html(games, players, ranks, elos), results
238
-
239
-
240
- def ranked_play(protocol):
241
- """Start a ranked match (models picked at random) or watch the one already running."""
242
- match, started = RANKED.start_or_join(protocol or "guided")
243
- joined = "" if started else f" · you joined the ranked match already in progress ({match.protocol})"
244
- seen = -1
245
- while True:
246
- version, status, boards, results, done = match.snapshot()
247
- if version != seen:
248
- seen = version
249
- yield status + joined, boards, results
250
- if done:
251
- return
252
- time.sleep(0.1)
253
-
254
-
255
- def stop_status(current):
256
- # only claim a stop when a match was actually running
257
- if (current or "").startswith("⏳"):
258
- return _status("Match stopped. Nothing was recorded.", "warn")
259
- return current
260
-
261
-
262
- def leaderboard_view(protocol):
263
- protocol = protocol or "guided"
264
- entries = [e for e in STORE.rows(protocol) if e["model"] not in BASELINES]
265
- return leaderboard_html(entries, protocol, MAX_PARAM_GAP, short_params(MAX_PARAM_GAP))
266
-
267
-
268
- def refresh_leaderboard(protocol):
269
- STORE.reload()
270
- return leaderboard_view(protocol)
271
-
272
-
273
- INTRO = f"""
274
- <div class="ah-heading"><div><p class="ah-eyebrow">SMALL MODELS. ZERO-SHOT TETRIS.</p>
275
- <h1>SLM Tetris Arena<span class="ah-accent">.</span></h1>
276
- <p class="ah-intro">Decoder-only language models ({short_params(MIN_PARAMS)}–{short_params(MAX_PARAMS)} parameters, custom architectures welcome) play Tetris
277
- zero-shot: no fine-tuning, no game data, only what they learned from pre-training on text. Every player gets the same
278
- piece sequence, and ranked matches update a public Elo leaderboard.</p></div>
279
- <span class="ah-version">SEASON {SEASON} <span class="ah-dot"></span></span></div>
280
- """
281
-
282
- HOW = f"""
283
- ### How a model plays
284
- For every new piece the game lists all legal placements (rotation × column, hard drop), simulates each one and
285
- describes the outcome in plain English. The model never sees the grid; it judges the descriptions:
286
-
287
- ```
288
- {PROMPTS['guided'].format(desc='drops the piece into the lowest part of the board, clears one line, creates no new holes, keeps the stack low and leaves the surface flat')}
289
- ```
290
-
291
- The model's value for a placement is **log P(" good move") − log P(" bad move")** after that prompt. The placement with the
292
- highest value is played; exact ties are broken by a seeded coin that is identical for every player.
293
- Because the value is a difference, a model's general bias towards "good" or "bad" cancels out.
294
-
295
- ### Protocols (separate leaderboards)
296
- - **Guided**: the first line states the goal ("clear lines, avoid holes, keep the stack low"). Tests reading comprehension.
297
- - **Blind**: `{PROMPTS['blind'].splitlines()[0]}` No rules; the model must already know what is good in Tetris.
298
-
299
- ### Rules of a match
300
- - Same 7-bag piece sequence for everyone. The game ends at top-out or after {MAX_PIECES} pieces.
301
- - Placement = score (100/300/500/800 for 1/2/3/4 lines), then lines, then pieces survived.
302
- - **Match** tab (friendly): pick any 2+ players (up to {MAX_MODELS} language models of any size, plus optional baselines)
303
- and the seed. Nothing is recorded.
304
- - **Ranked** tab: press Play and the arena picks up to {MAX_MODELS} models at random from its pool of {len(POOL.ids)} models,
305
- {SIZE_RULE}, with a random seed. Nobody chooses who plays, so Elo can't be farmed.
306
- Models with fewer ranked games are more likely to be picked, so every model gets played. The match runs on the server and counts even if
307
- you close the page; only one ranked match runs at a time, and pressing Play while one is running lets you watch it.
308
- - Elo: K=32, multiplayer (every pair of players counts as a game, scaled by 1/(N−1)).
309
-
310
- ### Baselines
311
- - **🎲 Random**: every placement ties, so it plays uniformly at random. This is the floor a model should beat.
312
- - **📏 Oracle reader**: reads the same descriptions and ranks them with fixed common sense (holes > lines > height > surface > landing).
313
- This is roughly the ceiling for a perfect reader of the text.
314
-
315
- Baselines can join friendly matches for comparison. They never play ranked and never change anyone's Elo.
316
-
317
- ### Model requirements
318
- Public, not gated, loads with `AutoModelForCausalLM` + `AutoTokenizer` (PyTorch or safetensors weights), between {fmt_params(MIN_PARAMS)} and {fmt_params(MAX_PARAMS)} parameters.
319
- Models with custom code (`auto_map`) load with `trust_remote_code=True`. That code runs on this Space's CPU, so only
320
- submit repos you trust. Prompts are in English (the language most pre-training corpora such as FineWeb-edu use).
321
-
322
- Results and every match (seed, commit SHA of each model, scores) are published in
323
- [`{RESULTS_REPO}`](https://huggingface.co/datasets/{RESULTS_REPO}).
324
- """
325
-
326
- RANKED_INTRO = f"""<p class="ah-note">Press <b>Play</b> and the arena picks up to {MAX_MODELS} language models <b>at random</b>
327
- from its pool of {len(POOL.ids)} models, {SIZE_RULE}, with a random seed.
328
- The result updates the public Elo leaderboard. The match runs on the server: it finishes and counts even if you close the page.
329
- Only one ranked match runs at a time; if one is already running, you watch it.</p>"""
330
-
331
- with gr.Blocks(title="SLM Tetris Arena") as demo:
332
- gr.HTML(INTRO, padding=False)
333
- if not STORE.persistent:
334
- gr.HTML('<div class="ah-warn">⚠️ Results are not being saved: add an <code>HF_TOKEN</code> secret with write access '
335
- 'to the results dataset.</div>', padding=False)
336
- with gr.Tabs():
337
- with gr.Tab("⚔️ Match"):
338
- with gr.Row():
339
- with gr.Column(scale=3):
340
- models = gr.Dropdown(
341
- choices=SUGGESTED, value=DEFAULT_MODELS, multiselect=True, allow_custom_value=True,
342
- max_choices=MAX_MODELS, label=f"Language models (1–{MAX_MODELS})",
343
- info="Pick from the list or type any Hub repo id (owner/name) and press Enter.",
344
- )
345
- baselines = gr.CheckboxGroup(BASELINE_CHOICES, value=[RANDOM_ID], label="Baselines (optional, never rated)")
346
- with gr.Column(scale=2):
347
- protocol = gr.Radio(PROTOCOL_CHOICES, value="guided", label="Protocol")
348
- seed = gr.Number(value=42, precision=0, label="Seed (0 = random)",
349
- info="Friendly match: any models, nothing is recorded. Elo only changes in the Ranked tab.")
350
- delay = gr.Slider(0, 0.5, value=0.12, step=0.02, label="Seconds per piece (viewing speed)")
351
- with gr.Row():
352
- start = gr.Button("▶ Start match", variant="primary")
353
- stop = gr.Button("■ Stop", variant="secondary")
354
- status = gr.Markdown(_status("Ready.", "ok"))
355
- boards = gr.HTML(empty_html())
356
- results = gr.HTML()
357
- with gr.Tab("🏅 Ranked"):
358
- gr.HTML(RANKED_INTRO, padding=False)
359
- with gr.Row(equal_height=True):
360
- r_protocol = gr.Radio(PROTOCOL_CHOICES, value="guided", label="Protocol", scale=3)
361
- r_play = gr.Button("▶ Play ranked match", variant="primary", scale=1)
362
- r_status = gr.Markdown(_status("Ready. Press Play: the arena picks the models.", "ok"))
363
- r_boards = gr.HTML(empty_html("Press <b>Play ranked match</b>. The arena picks the models at random."))
364
- r_results = gr.HTML()
365
- with gr.Tab("🏆 Leaderboard"):
366
- lb_protocol = gr.Radio(PROTOCOL_CHOICES, value="guided", label="Protocol")
367
- lb = gr.HTML(leaderboard_view("guided"), padding=False)
368
- lb_refresh = gr.Button("↻ Refresh", variant="secondary")
369
- with gr.Tab("📖 How it works"):
370
- gr.Markdown(HOW)
371
-
372
- match_event = start.click(
373
- run_match, [models, baselines, protocol, seed, delay], [status, boards, results], concurrency_limit=1,
374
- )
375
- stop.click(stop_status, status, status, cancels=[match_event])
376
- # viewers only watch; the ranked match itself runs in one background thread
377
- r_play.click(ranked_play, r_protocol, [r_status, r_boards, r_results], concurrency_limit=16,
378
- concurrency_id="ranked").then(leaderboard_view, lb_protocol, lb)
379
- lb_protocol.change(leaderboard_view, lb_protocol, lb)
380
- lb_refresh.click(refresh_leaderboard, lb_protocol, lb)
381
- demo.load(leaderboard_view, lb_protocol, lb)
382
-
383
- demo.queue(max_size=32)
384
-
385
- if __name__ == "__main__":
386
- demo.launch(css=APP_CSS + CSS + LB_CSS, theme=THEME, ssr_mode=False)
 
1
+ {{FILE:/home/claude/space/app.py}}