AndrewRqy commited on
Commit ·
a777ed3
1
Parent(s): f9490c0
Pre-warm Modal LLM at app startup + document cold-start behavior in README
Browse filesFiles changed (2)
42 unmodified lines43444546474842 unmodified lines- **Field notes (repo)**: [`docs/FIELD_NOTES_apprentice.md`](../docs/FIELD_NOTES_apprentice.md)> **⏱ Note on loading time**: this Space ships ~100 pixel-art sprites + theme backdrops. HF Space's free CPU tier has slow egress bandwidth, so first paint of a fresh container can take a minute or two; subsequent page transitions are faster as the browser caches assets. The front-page dropdown lets you flip between **Lean** (small payload, fast loading, default on the Space) and **Full** (parallax banner, scene landscapes, all decorative PNGs — recommended only on a fast connection or once the Space is warm).## What's inside42 unmodified lines434445464748495042 unmodified lines- **Field notes (repo)**: [`docs/FIELD_NOTES_apprentice.md`](../docs/FIELD_NOTES_apprentice.md)> **⏱ Note on loading time**: this Space ships ~100 pixel-art sprites + theme backdrops. HF Space's free CPU tier has slow egress bandwidth, so first paint of a fresh container can take a minute or two; subsequent page transitions are faster as the browser caches assets. The front-page dropdown lets you flip between **Lean** (small payload, fast loading, default on the Space) and **Full** (parallax banner, scene landscapes, all decorative PNGs — recommended only on a fast connection or once the Space is warm).>> **🥶 Note on LLM cold start**: the Modal-hosted LLM container scales to zero when idle to avoid 24/7 billing during the review period. The first LLM call after the container has been idle (~20 min) pays a **~60-120s cold start** while vLLM loads the 14B weights + the LoRA adapter onto an L40S GPU. To hide this from the player, the app fires a background warmup ping to the Modal endpoint at startup, so by the time you've finished inscribing five oracles (~2-5 min of typing), the container should already be warm. If you click "Let the journey begin" immediately on a cold Space, expect the first trial to wait an extra minute. Every subsequent trial in the same session is instant.## What's inside
168 unmodified lines169170171172173174168 unmodified linesdefault_headers=dict(self.config.extra_headers),timeout=60, # resolution call can be longer than apprentice)@propertydef using_mock(self) -> bool:168 unmodified lines169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207168 unmodified linesdefault_headers=dict(self.config.extra_headers),timeout=60, # resolution call can be longer than apprentice)# Fire-and-forget warmup: hit /v1/models in a daemon thread so# Modal's scaled-to-zero container starts spinning up while the# player is still inscribing oracles. By the time they click# "let the journey begin" the container should be warm.self._kick_warmup()def _kick_warmup(self) -> None:"""Send a non-blocking GET /v1/models to wake a cold Modal container.Runs in a daemon thread so app startup never blocks on the warmup.Failures are swallowed — the real call later will surface anyconnectivity issues with a proper error message."""import threadingimport urllib.requestif not self.config.base_url:returnurl = self.config.base_url.rstrip("/") + "/v1/models"headers = dict(self.config.extra_headers)def _ping() -> None:try:req = urllib.request.Request(url, headers=headers, method="GET")# Long timeout — vLLM cold start with cached weights is# 30-90s. We don't care if it eventually succeeds; we just# want to trigger the container allocation.with urllib.request.urlopen(req, timeout=180) as resp:resp.read()except Exception:passthreading.Thread(target=_ping, daemon=True, name="llm-warmup").start()@propertydef using_mock(self) -> bool:
README.md+2
oracles/llm_client.py+33