Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions bench/candidate_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,16 @@
textgrad_prompt_optimization,
)

#: Every port publishes its identity, fidelity and reserved proposal calls as
#: module metadata, so the table below is built from constants: calling
#: ``build(0)`` here would load each port's dataset just to learn its name, and
#: that made this module's own ``--help`` need a writable cache (#1260).
ALGORITHMS: Dict[str, Tuple[str, PolicyBuilder]] = {
module.build(0).name: (module.FIDELITY, module.build) for module in _MODULES
module.NAME: (module.FIDELITY, module.build) for module in _MODULES
}

PROPOSAL_CALLS_PER_CANDIDATE = {
name: builder(0).proposal_calls_per_candidate
for name, (_, builder) in ALGORITHMS.items()
module.NAME: module.PROPOSAL_CALLS for module in _MODULES
}

DEFAULT_OUTPUT = Path("bench/results/candidate-methods-framework-live.json")
Expand Down
6 changes: 6 additions & 0 deletions changelog.d/1260-bench-import-cost.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Fixed
`python -m bench.candidate_methods --help` no longer loads every port's dataset
before it can print usage: the matrix reads each port's name, fidelity and
reserved proposal calls from module constants instead of building a policy at
import time, so the command works on a host whose dataset cache is read-only and
needs no download on a clean one (#1260).
9 changes: 7 additions & 2 deletions examples/absolute_zero/absolute_zero_selfplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@

FIDELITY = "inference_analogue"

#: The port's identity and reserved proposal calls, as metadata: a matrix
#: can list this port without calling :func:`build`, which loads its dataset.
NAME = "absolute_zero"
PROPOSAL_CALLS = 1

_FALLBACK = CartTask((125, 240), (1, 2))


Expand Down Expand Up @@ -106,7 +111,7 @@ def propose(llm, rendered: str, task: Task, output: str,

train, held_out, test = selfplay_splits(seed, "absolute_zero")
return MethodPolicy(
name="absolute_zero",
name=NAME,
fidelity=FIDELITY,
notes=(
"Proposer, solver, grounded verifier, and zero-data curriculum are preserved in training rollouts.",
Expand All @@ -123,7 +128,7 @@ def propose(llm, rendered: str, task: Task, output: str,
solve=solve,
propose=propose,
reward=mixed_reward,
proposal_calls_per_candidate=1,
proposal_calls_per_candidate=PROPOSAL_CALLS,
reflective=True,
)

Expand Down
9 changes: 7 additions & 2 deletions examples/aflow/aflow_workflow_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@

FIDELITY = "mechanism_microport"

#: The port's identity and reserved proposal calls, as metadata: a matrix
#: can list this port without calling :func:`build`, which loads its dataset.
NAME = "aflow"
PROPOSAL_CALLS = 2

REVIEW_INSTRUCTION = "Check the arithmetic and return only the corrected answer."

#: `select_round` computes `scores = [item["score"] * 100 ...]` before the
Expand Down Expand Up @@ -210,7 +215,7 @@ def _modification(raw: str) -> str:

train, held_out, test = gsm8k_splits(seed)
return MethodPolicy(
name="aflow",
name=NAME,
fidelity=FIDELITY,
notes=(
"The pinned revision's soft mixed selection (not UCT) runs through the population aggregator over the archive of committed workflows, with upstream's own alpha=0.2, lambda=0.3 and its score-by-100 scaling -- without which the distribution is uniform.",
Expand All @@ -232,7 +237,7 @@ def _modification(raw: str) -> str:
solve=solve,
propose=propose,
reward=gsm8k_reward,
proposal_calls_per_candidate=2,
proposal_calls_per_candidate=PROPOSAL_CALLS,
engine=Policies(selection=SoftMixed(seed=seed)),
reflective=True,
)
Expand Down
9 changes: 7 additions & 2 deletions examples/agent0/agent0_tool_curriculum.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@

FIDELITY = "inference_analogue"

#: The port's identity and reserved proposal calls, as metadata: a matrix
#: can list this port without calling :func:`build`, which loads its dataset.
NAME = "agent0"
PROPOSAL_CALLS = 1

_FALLBACK = CartTask((125, 240), (1, 2))

#: Executor samples per generated task. `generate_results` is the same
Expand Down Expand Up @@ -174,7 +179,7 @@ def propose(llm, rendered: str, task: Task, output: str,

train, held_out, test = selfplay_splits(seed, "agent0")
return MethodPolicy(
name="agent0",
name=NAME,
fidelity=FIDELITY,
notes=(
"Curriculum/Executor co-evolution and multi-turn calculator use are preserved; frozen evaluation carts also run the tool loop.",
Expand All @@ -190,7 +195,7 @@ def propose(llm, rendered: str, task: Task, output: str,
solve=solve,
propose=propose,
reward=mixed_reward,
proposal_calls_per_candidate=1,
proposal_calls_per_candidate=PROPOSAL_CALLS,
engine=Policies(task_sampler=DifficultyWeighted()),
reflective=True,
)
Expand Down
9 changes: 7 additions & 2 deletions examples/dynamic_cheatsheet/dynamic_cheatsheet_cumulative.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@

FIDELITY = "mechanism_microport"

#: The port's identity and reserved proposal calls, as metadata: a matrix
#: can list this port without calling :func:`build`, which loads its dataset.
NAME = "dynamic_cheatsheet"
PROPOSAL_CALLS = 1

#: Upstream's initial cheatsheet (``cheatsheet = "(empty)"`` in run_benchmark.py).
INITIAL_CHEATSHEET = "(empty)"

Expand Down Expand Up @@ -326,7 +331,7 @@ def propose(llm, rendered: str, task: Task, output: str,

train, held_out, test = game24_splits(seed)
return MethodPolicy(
name="dynamic_cheatsheet",
name=NAME,
fidelity=FIDELITY,
notes=(
"DC-Cu (cumulative, no retrieval) traced at suzgunmirac/dynamic-cheatsheet@5cfe3c3: Gen answers with the current cheatsheet in context, Cur rewrites the whole cheatsheet from (memory, question, the model's own answer).",
Expand All @@ -349,7 +354,7 @@ def propose(llm, rendered: str, task: Task, output: str,
solve=solve,
propose=propose,
reward=game24_reward,
proposal_calls_per_candidate=1,
proposal_calls_per_candidate=PROPOSAL_CALLS,
engine=Policies() if gated else Policies(acceptance=CommitEveryUpdate()),
reflective=True,
# Skill-layer context, like ACE's playbook. Above 0.3 the runtime audits
Expand Down
9 changes: 7 additions & 2 deletions examples/godel_agent/godel_agent_self_modify.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@

FIDELITY = "self_edit_analogue"

#: The port's identity and reserved proposal calls, as metadata: a matrix
#: can list this port without calling :func:`build`, which loads its dataset.
NAME = "godel_agent"
PROPOSAL_CALLS = 1

GODEL_INITIAL_SOURCE = '''def solve_prompt(question):
return "Solve the arithmetic problem carefully. Return only the final answer.\\n\\n" + question

Expand Down Expand Up @@ -83,7 +88,7 @@ def propose(llm, rendered: str, task: Task, output: str,

train, held_out, test = gsmhard_splits(seed)
return MethodPolicy(
name="godel_agent",
name=NAME,
fidelity=FIDELITY,
notes=(
"The artifact owns both solve and self-improvement prompt functions; each proposal is produced by the artifact's own current self-improvement prompt.",
Expand All @@ -99,7 +104,7 @@ def propose(llm, rendered: str, task: Task, output: str,
solve=solve,
propose=propose,
reward=gsmhard_reward,
proposal_calls_per_candidate=1,
proposal_calls_per_candidate=PROPOSAL_CALLS,
engine=(Policies(acceptance=AcceptAnyCompiling()) if gateless
else Policies()),
reflective=True,
Expand Down
9 changes: 7 additions & 2 deletions examples/gskill/gskill_repo_skill.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@

FIDELITY = "mechanism_microport"

#: The port's identity and reserved proposal calls, as metadata: a matrix
#: can list this port without calling :func:`build`, which loads its dataset.
NAME = "gskill"
PROPOSAL_CALLS = 1

SKILL_NAME = "kvtools-fixer"

#: "GEPA starts with empty skills" -- as a *valid* skill, so the structural gate
Expand Down Expand Up @@ -307,7 +312,7 @@ def report() -> str:

train, held_out, test = gskill_splits(seed)
return MethodPolicy(
name="gskill",
name=NAME,
fidelity=FIDELITY,
notes=(
"Traced gepa-ai/gepa@f1cfdee src/gepa/gskill: optimize_anything evolves one repository skill from agent traces and test feedback; skills start empty and are deployed unchanged.",
Expand All @@ -325,7 +330,7 @@ def report() -> str:
solve=solve,
propose=propose,
reward=reward,
proposal_calls_per_candidate=1,
proposal_calls_per_candidate=PROPOSAL_CALLS,
engine=Policies(acceptance=StrictHeldOutGate()),
# `ReflectiveFusion` writes its synthesis to the ledger without passing
# `to_diff`, so a model-merged SKILL.md would bypass the frontmatter gate.
Expand Down
9 changes: 7 additions & 2 deletions examples/promptbreeder/promptbreeder_genetic_prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@

FIDELITY = "mechanism_microport"

#: The port's identity and reserved proposal calls, as metadata: a matrix
#: can list this port without calling :func:`build`, which loads its dataset.
NAME = "promptbreeder"
PROPOSAL_CALLS = 2

MUTATION_PROMPT = MUTATION_PROMPTS[0]

#: Units in the population. The paper uses 50; this is budget-sized, and the
Expand Down Expand Up @@ -207,7 +212,7 @@ def report() -> str:

train, held_out, test = gsm8k_splits(seed)
return MethodPolicy(
name="promptbreeder",
name=NAME,
fidelity=FIDELITY,
notes=(
"Algorithm 1 as written: fixed-size population, binary tournament on a random training batch, and the loser replaced by the mutated winner.",
Expand All @@ -229,7 +234,7 @@ def report() -> str:
# Two, not one: the paper's hypermutation operators are two model calls,
# and declaring one would make the budget check fail on a run that spent
# exactly what the algorithm asks for.
proposal_calls_per_candidate=2,
proposal_calls_per_candidate=PROPOSAL_CALLS,
engine=Policies(selection=BinaryTournament(seed)),
reflective=True,
population=population,
Expand Down
9 changes: 7 additions & 2 deletions examples/r_zero/r_zero_challenger_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@

FIDELITY = "inference_analogue"

#: The port's identity and reserved proposal calls, as metadata: a matrix
#: can list this port without calling :func:`build`, which loads its dataset.
NAME = "r_zero"
PROPOSAL_CALLS = 2

_FALLBACK = CartTask((125, 240), (1, 2))
CHALLENGER_SEED = "Increase curriculum difficulty gradually."

Expand Down Expand Up @@ -116,7 +121,7 @@ def propose(llm, rendered: str, task: Task, output: str,

train, held_out, test = selfplay_splits(seed, "r_zero")
return MethodPolicy(
name="r_zero",
name=NAME,
fidelity=FIDELITY,
notes=(
"Separate Challenger and Solver role memories receive separate updates and union-merge across fields.",
Expand All @@ -135,7 +140,7 @@ def propose(llm, rendered: str, task: Task, output: str,
solve=solve,
propose=propose,
reward=mixed_reward,
proposal_calls_per_candidate=2,
proposal_calls_per_candidate=PROPOSAL_CALLS,
engine=Policies(
task_sampler=DifficultyWeighted(),
acceptance=AdvantageAcceptance(), # wraps the run's own gate
Expand Down
9 changes: 7 additions & 2 deletions examples/reflexion/reflexion_episodic_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@

FIDELITY = "mechanism_microport"

#: The port's identity and reserved proposal calls, as metadata: a matrix
#: can list this port without calling :func:`build`, which loads its dataset.
NAME = "reflexion"
PROPOSAL_CALLS = 1

#: `prompts.REFLECTION_HEADER`, with "question" generalised to "problem" because
#: this memory is shared across the domain rather than bound to one instance.
MEMORY_HEADER = (
Expand Down Expand Up @@ -206,7 +211,7 @@ def propose(llm, rendered: str, task: Task, output: str,

train, held_out, test = gsmhard_splits(seed)
return MethodPolicy(
name="reflexion",
name=NAME,
fidelity=FIDELITY,
notes=(
"The reflection query carries two worked examples of a failed attempt and its plan, as _generate_reflection_query prepends FEW_SHOT_EXAMPLES; without them the reflector answers the arithmetic instead of planning.",
Expand All @@ -226,7 +231,7 @@ def propose(llm, rendered: str, task: Task, output: str,
solve=solve,
propose=propose,
reward=gsmhard_reward,
proposal_calls_per_candidate=1,
proposal_calls_per_candidate=PROPOSAL_CALLS,
reflective=True,
)

Expand Down
9 changes: 7 additions & 2 deletions examples/self_refine/self_refine_feedback_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@

FIDELITY = "mechanism_microport"

#: The port's identity and reserved proposal calls, as metadata: a matrix
#: can list this port without calling :func:`build`, which loads its dataset.
NAME = "self_refine"
PROPOSAL_CALLS = 1

STOP_SIGNAL = "it is correct"

#: `entire_output.split("def solution():")` -- the marker that separates the
Expand Down Expand Up @@ -142,7 +147,7 @@ def propose(llm, rendered: str, task: Task, output: str,

train, held_out, test = gsm8k_splits(seed)
return MethodPolicy(
name="self_refine",
name=NAME,
fidelity=FIDELITY,
notes=(
"FEEDBACK and REFINE are one model call split on a marker, as GSMFeedback.__call__ is; six of the seven upstream tasks separate them, and gsm -- this port's domain -- does not.",
Expand All @@ -161,7 +166,7 @@ def propose(llm, rendered: str, task: Task, output: str,
solve=solve,
propose=propose,
reward=gsm8k_reward,
proposal_calls_per_candidate=1,
proposal_calls_per_candidate=PROPOSAL_CALLS,
reflective=True,
)

Expand Down
9 changes: 7 additions & 2 deletions examples/sica/sica_self_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@

FIDELITY = "self_edit_analogue"

#: The port's identity and reserved proposal calls, as metadata: a matrix
#: can list this port without calling :func:`build`, which loads its dataset.
NAME = "sica"
PROPOSAL_CALLS = 1

SICA_INITIAL_SOURCE = '''def agent_prompt(question):
return "Solve the arithmetic problem carefully. Return only the final answer.\\n\\n" + question
'''
Expand Down Expand Up @@ -120,7 +125,7 @@ def propose(llm, rendered: str, task: Task, output: str,

train, held_out, test = gsmhard_splits(seed)
return MethodPolicy(
name="sica",
name=NAME,
fidelity=FIDELITY,
notes=(
"The meta loop edits real Python policy source and the framework gate measures utility.",
Expand All @@ -136,7 +141,7 @@ def propose(llm, rendered: str, task: Task, output: str,
solve=solve,
propose=propose,
reward=gsmhard_reward,
proposal_calls_per_candidate=1,
proposal_calls_per_candidate=PROPOSAL_CALLS,
engine=Policies(selection=Archive(sampling="best", seed=seed)),
reflective=True,
)
Expand Down
9 changes: 7 additions & 2 deletions examples/skillweaver/skillweaver_web_apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@

FIDELITY = "environment_analogue"

#: The port's identity and reserved proposal calls, as metadata: a matrix
#: can list this port without calling :func:`build`, which loads its dataset.
NAME = "skillweaver"
PROPOSAL_CALLS = 1

#: 48, not 12: `run_port` refuses a run whose train split is smaller than
#: the worker count, so twelve tasks split 4/4/4 capped this port at four
#: workers with a four-task gate.
Expand Down Expand Up @@ -282,7 +287,7 @@ def propose(llm, rendered: str, task: Task, output: str,
train, held_out, test = _split(seed)
categories = ["api generic"] + sorted({f"api {p}" for p, _, _ in PAGES})
return MethodPolicy(
name="skillweaver",
name=NAME,
fidelity=FIDELITY,
notes=(
"The paper's three stages map to: Proposal = task pool + difficulty sampling; Synthesis = rollout + self-verify reward model; Honing = the repair call.",
Expand All @@ -308,7 +313,7 @@ def propose(llm, rendered: str, task: Task, output: str,
solve=solve,
propose=propose,
reward=reward,
proposal_calls_per_candidate=1,
proposal_calls_per_candidate=PROPOSAL_CALLS,
engine=Policies(task_sampler=DifficultyWeighted()),
reflective=False,
self_verify=True,
Expand Down
Loading
Loading