How logic-star-ai/swe-star works
1. What this repo is
SWE-Star is an end-to-end pipeline for producing, training, and evaluating agentic coding models. The main artifact is a large dataset of coding trajectories, then fine-tuned Qwen2.5-Coder-based models, and finally benchmark evaluation on SWE-Bench Verified.
2. Top-level pipeline
The core flow is: task generation / rollouts → trajectory storage → dataset curation → supervised fine-tuning → benchmark evaluation. The repository is organized around those stages rather than around a single app service.
3. Agent runtime
uac/agent is the execution boundary for interactive code-editing episodes. It contains:
- the agent loop (agent.py)
- environment abstraction (environment.py)
- tool definitions (tools.py)
- message/model/schema handling (model.py)
- persistence and logging (save.py, log.py)
- prompt templates (templates/)
This layer is the “runtime” that talks to a model, executes tools, and records trajectories.
4. Tool-using coding scaffold
The README describes an OpenHands-like scaffold with XML tool calling and tools such as think, str_replace_editor, execute_bash, and submit. That means the agent layer is not just text generation; it is a controlled, multi-step executor that can inspect and modify repositories during benchmark-style tasks.
5. Data generation
uac/generate and uac/experiments/*/generate.py are responsible for producing trajectories under different settings. The generate package appears to be the general entry point, while the experiment folders contain variants such as teacher strength, issue type, multiple unrolls, and train-on-sympy. This is where raw agent rollouts are created before training.
6. Training subsystem
uac/train contains the model fine-tuning layer. The presence of trl.py, torchtune.py, split.py, and a zero_stage_3_config.json indicates support for multiple training backends and distributed training setups. This layer likely consumes curated trajectory data and outputs tuned checkpoints for the SWE-Star family.
7. Evaluation subsystem
uac/eval contains benchmark-specific evaluation code, including SWE-Bench and SWE-Bench-related variants. This is the downstream scoring boundary that compares generated patches/solutions against benchmark instances, separate from the agent rollout system.
8. MN5 / SLURM operations layer
uac/mn5 is the infrastructure control plane for MareNostrum 5. It includes:
- dataset and model coordination
- inference orchestration
- scheduling
- monitoring for sglang and vllm
- Podman integration
- Slack notifications
- statistics, usage, and W&B integration
This suggests the repo is designed for batch and cluster execution rather than local development alone.
9. Containerization and cluster setup
setup/podman packages Podman binaries, systemd units, and helper components, and setup/setup_podman.sh likely bootstraps that environment on MN5 nodes. This is an important architectural boundary: runtime isolation and reproducibility are handled with Podman rather than ad hoc host installation.
10. Experiment matrix
uac/experiments is a collection of ablations and research variants around the same core pipeline. Examples include:
- cheating
- major
- rejection_sampling
- student_family
- teacher_strength
- number_of_repos
- r2e
- train_on_input
- train_on_sympy
These are not separate products; they are controlled entry points into the shared generation/training/eval stack.
11. Analysis and reporting
uac/analysis/analyze_by_repo.py provides post-hoc analysis over generated data or evaluation outputs, likely to break results down by repository or task source. This is the analytics boundary after training/evaluation.
12. Tests and CI
tests/ covers agent behavior, environment behavior, and tools. workflows/lint.yaml indicates repo-level quality checks. These tests likely protect the agent/tool interface and environment contract, which are the most failure-sensitive parts of the system.
13. External dependencies that shape architecture
The repo is built around Hugging Face model/dataset workflows, SWE-Bench Verified, SLURM on MN5, and optional W&B/Slack operational hooks. The README also notes offline agent rollouts on MN5 and internet-enabled benchmark evaluation elsewhere, so network policy is a real architectural constraint.
Main entry points: agent.py Agent loop · trl.py Train · generate.py Generate · utils.py Experiments
Components 19
Core pipeline
End-to-end flow from data generation through training and evaluation.
- Generate · General trajectory generation entrypoint.
uac/generate/generate.py - R2E flows · Specialized generation paths for rollout variants.
uac/generate/r2e.py - Train · Orchestrates model fine-tuning workflows for SWE-Star variants.
uac/train/trl.py - Torchtune · Training backend integration for checkpoint fine-tuning.
uac/train/torchtune.py - Split data · Dataset splitting and preparation for training/evaluation.
uac/train/split.py - Evaluate · Evaluation entrypoint for benchmark scoring.
uac/eval/eval.py - SWE-Bench · SWE-Bench-specific evaluation logic.
uac/eval/swebench.py
Agent runtime
Interactive coding episode execution, tools, and persistence.
- Agent loop · Coordinates model turns, tool use, and environment interaction.
uac/agent/agent.py - Environment · Abstraction over the editable repository and task environment.
uac/agent/environment.py - Tools · Tool definitions such as edit, shell, think, and submit.
uac/agent/tools.py - Model I/O · Message, schema, and prompt/template handling for agent calls.
uac/agent/model.py - Logs & save · Logging and persistence of agent traces and artifacts.
uac/agent/log.py
MN5 ops
Cluster execution, orchestration, and environment setup.
- Schedule · Batch scheduling and job coordination on MN5.
uac/mn5/schedule.py - Inference · Inference orchestration for large-model serving and rollouts.
uac/mn5/inference.py - Monitoring · Monitoring for serving stacks and operational status.
uac/mn5/monitor_sglang.py - Podman setup · Container runtime packaging and bootstrap for reproducible cluster execution.
setup/setup_podman.sh
Experiments
Ablations and variants built on the shared pipeline.
- Experiments · Shared entrypoint group for ablations and research variants.
uac/experiments/utils.py - Analysis · Repository-level analysis of generated data and outcomes.
uac/analysis/analyze_by_repo.py
Validation
Tests and repository checks.
- Tests · Coverage for agent, environment, and tools contracts.
tests/test_agent.py
Connections 22
- Generate → Agent loop: launches · Generation starts agent rollouts.
- R2E flows → Generate: specializes · Variant generation paths feed the shared generator.
- Agent loop → Environment: uses · The agent acts inside the environment boundary.
- Agent loop → Tools: calls · Agent decisions are executed through tools.
- Agent loop → Model I/O: queries · The loop formats prompts and model messages.
- Agent loop → Logs & save: records · Episodes are logged and saved as trajectories.
- Logs & save → Split data: feeds · Saved trajectories are curated and split for training.
- Split data → Train: prepares · Prepared datasets are consumed by training.
- Train → Torchtune: backends · Training can run through multiple backend implementations.
- Train → Evaluate: outputs · Tuned checkpoints proceed to evaluation.
- Evaluate → SWE-Bench: adapts · Benchmark-specific scoring is handled by SWE-Bench logic.
- Schedule → Generate: orchestrates · Cluster jobs run generation at scale.
- Schedule → Train: orchestrates · Cluster jobs run training at scale.
- Inference → Generate: serves · Inference serving supports rollout and rollout-like workflows.
- Monitoring → Inference: watches · Operational telemetry tracks serving health.
- Podman setup → Schedule: enables · Containerized runtime setup supports cluster execution.
- Experiments → Generate: variants · Research variants reuse the shared generation stack.
- Experiments → Train: variants · Research variants reuse the shared training stack.
- Experiments → Analysis: studies · Experiment code feeds post-hoc analysis.
- Tests → Agent loop: covers · Tests protect the agent loop contract.
- Tests → Environment: covers · Tests protect environment behavior.
- Tests → Tools: covers · Tests protect tool semantics.