Spaces:
Sleeping

p4r5kpftnp-cmd commited on
Commit
df04431
·
1 Parent(s): 1145e92

Speed up proof generation: cache components, smaller max_tokens, two-stage retry

Browse files

Three targeted speedups for the live Space:

1. Cache LeanEnvironment + MathLibRetriever module-level in app.py. Each
solve_proof call used to spawn a fresh Lean REPL (5-15s cold) and
reload the 200MB FAISS index. Now both are built once on first use
and shared across requests. LeanEnvironment grew a threading.Lock
so concurrent verifies serialize at the Lean step but parallelize
everywhere else.

2. Lower LLM max_tokens from 1024 -> 512. Most Lean proofs are 1-5
lines; the cap rarely bites and the smaller window is ~20-30% faster.

3. Two-stage retry. On Groq, attempt 0 now uses llama-3.1-8b-instant
(~3-5x faster than 70b); subsequent attempts escalate to whichever
model the user picked in the dropdown. Skipped when the user
explicitly picks 8b or any Claude model.

LangGraphAgent gained optional `fast_model`, `lean_env`, and `retriever`
parameters so callers can opt into the new behavior; defaults preserve
the old per-call construction for scripts/run_agent.py and benchmarks.

Tests gain a `_get_components` mock so they don't pay the real Lean+FAISS
init cost; test wall time dropped from ~20s to ~0.4s.

6 files changed +100 -10
Files changed (6)
app.py+42
src/langgraph_agent.py+33-7
src/lean_verifier.py+9-1
src/rag_chain.py+2-2
tests/test_app_fuzz.py+8
tests/test_concurrent_solve.py+6