Graphs and stages
Graphs and stages
Read this page when the two packaged graphs don't fit our workload and we want to write or adjust our own. A study runs a graph: named nodes we load from graph.yaml. Each tick, the controller runs the next pending node's target stage, then routes to the next node by looking up the result status in that node's on: map:
node.execute() -> StageResult(status=...) -> graph.route(node, status) -> next nodeNode Anatomy
run_trial:
target: espnet3.bin.atlas.stages.run_trial.RunTrialStage
execution: submission # "local" or "submission"
resources: # only meaningful for execution: submission
gpus: 1
cpus: 4
mem: 32G
time: "08:00:00"
"on":
success: collect_result
failure: debug_trial
timeout: debug_trial
waiting_job: run_trial
early_stopped: reflect- Set
targetto the dotted path of aBaseStagesubclass. - Set
executiontolocalif we want it to run in the controller tick, orsubmissionto dispatch it as a job (itsresourcesoverride the study-level default). - Fill in
onfor every status the stage can return, or setterminal: trueinstead to end the graph there. skill,allowed_actions,output_schema,output_file,output_key,output_append,fallback_output,trial_update_keys,skill_contextonly apply whentargetisSkillStage— see below.
We don't need to worry about re-running a crashed node: ATLAS caches each node run's result on disk and returns it instead of re-running.
Packaged Graphs
Set atlas.application to either name; both ship under espnet3/bin/atlas/graphs/.
hyperparameter_search
We use this when we only want config changes, never code changes:
research_context ──► propose_trial ──► run_trial ──► collect_result ──► accept_or_reject
│(implement_code) │(failure/timeout) │
▼ ▼ ▼
implement_code ──► debug_trial ──► (run_trial/reflect) reflect ──► update_knowledge ──► check_budget
│
(continue) propose_trial ◄───┘ (done) select_best ──► analyze [terminal]architecture_search
We use this when we want the agent to write code. Same shape, but a proposal runs through a write/test loop before training:
... propose_trial ──(implement_code)──► implement_code (WriteFilesStage)
│success │failure
▼ ▼
run_tests ──────► run_trial
(failure loops back to implement_code,
success or max_retries_exceeded -> run_trial)Both share the same tail: collect_result → accept_or_reject → reflect → update_knowledge → check_budget, looping back to propose_trial until our budget runs out, then select_best → analyze (terminal).
Stages
All under espnet3/bin/atlas/stages/:
| Stage | Node(s) | What it does |
|---|---|---|
SkillStage | research_context, reflect, update_knowledge, analyze, custom skill nodes | Runs the node's skill through our agent; applies trial_update_keys; writes output_file. |
ProposeTrialStage | propose_trial | Asks the agent for a config patch, filters it through search_space, dedups against prior trials, writes resolved configs. |
WriteFilesStage | implement_code (architecture search) | Applies an agreed code patch to src/. |
RunTestsStage | run_tests (architecture search) | Runs our test suite against the patch; loops back to implement_code on failure. |
RunTrialStage | run_trial | Runs train/infer/measure (or our command_template); resumes from checkpoint, skips completed stages. |
DebugTrialStage | debug_trial | Diagnoses a failed/timed-out trial; retries run_trial or gives up to reflect. |
CollectResultStage | collect_result | Extracts our atlas.metric.extraction keys into trial.score/trial.metrics. |
AcceptOrRejectStage | accept_or_reject | Compares the score to the current best; accepts or rejects, writes decision.md. |
CheckBudgetStage | check_budget | Routes continue/done from should_stop(). |
SelectBestStage | select_best | Picks the final best trial. |
Skills
Most of the agent-facing behavior lives in markdown skill files under .agents/skills/atlas_<application>_<skill_name>/SKILL.md, run through SkillStage. We point a node at one like this:
reflect:
target: espnet3.bin.atlas.stages.skill.SkillStage
execution: local
skill: atlas_hyperparameter_search_reflect
allowed_actions: [read_only, terminal, file_write]
trial_update_keys: [reflection, next_suggestion]
output_file: trials/{trial_id}/reflection.md
output_key: reflection
output_schema:
reflection: {type: string, description: "summary of the trial result"}
next_suggestion: {type: string, description: "recommended next experiment"}
"on":
continue: update_knowledge
done: update_knowledge
failure: update_knowledgeSkillStage builds the agent's request from program.md, the knowledge pack, trials.csv, the current trial, and our skill_context; constrains the reply to a schema; writes output_key/output_file for us (this is how knowledge_pack.md, reflection.md, and summary.md get written); copies trial_update_keys onto the trial; and writes fallback_output instead of stalling the graph if the call fails.
We get these skills out of the box:
| Skill | Node | What it's for |
|---|---|---|
research_context | research_context | Write the first knowledge-pack entry from program.md. |
propose_trial | inside ProposeTrialStage | Propose the next config patch (and code changes, for architecture search). |
implement_code | implement_code | Write/modify src/ for an architecture-search trial. |
debug_trial | inside DebugTrialStage | Diagnose a failed trial; patch-and-retry or give up. |
reflect | reflect | Summarize a trial and suggest the next direction. |
update_knowledge | update_knowledge | Append to the knowledge pack. |
analyze | analyze | Write the final study summary. |
atlas_study_status | via espnet3 atlas status | Read progress without touching the study. |
Custom Graph
Set atlas.application to our own graph YAML (ATLAS resolves it relative to --recipe-dir first, then falls back to a packaged graph by name). We keep the research_context → propose_trial → run_trial → collect_result → accept_or_reject → reflect → update_knowledge → check_budget backbone, and only add a step before propose_trial/run_trial if our workload needs one (e.g. train_tokenizer — see Trial.extra_stages). Here's a minimal extra node:
create_dataset:
target: espnet3.bin.atlas.stages.skill.SkillStage
execution: local
skill: my_app_create_dataset
output_schema: {}
"on":
success: propose_trial
failure: propose_trial