Skip to main content

MER: Minimal Extraction and Reconstruction for deep learning bug reproduction environments.

Project description

MER: Minimal Extraction and Reconstruction

MER is an agentic framework for verifying and reconstructing deep learning bug reproduction environments.

Installation

  1. Clone the repository:

    git clone <repository_url>
    cd DL-Faults-Sandbox
    
  2. Install dependencies: It is recommended to use a virtual environment.

    python3 -m venv venv
    source venv/bin/activate
    pip install -r requirements.txt
    

    Or install the package directly with pip:

    pip install .
    
  3. Docker Setup: Ensure Docker is installed and running on your machine, as MER agents utilize Docker containers for environment isolation.

Usage

Running the Orchestrator

The main entry point for the MER system is mer/orchestrator/main.py.

# After `pip install .`
mer

# Run all bug samples under dataset/
python3 -m mer.orchestrator.main

# Run a subset by bug_id
python3 -m mer.orchestrator.main --sample huggingface_diffusers_12975 --sample pyg-team_pytorch_geometric_10548

# Limit number of samples
python3 -m mer.orchestrator.main --limit 2

# Use a custom dataset root
python3 -m mer.orchestrator.main --dataset-root /path/to/dataset

# Enable LangSmith tracing
python3 -m mer.orchestrator.main --langsmith --langsmith-project MER

# Run no-planner ablation
python3 -m mer.orchestrator.main --ablation-profile no_planner_agent

# Run no-data ablation
python3 -m mer.orchestrator.main --ablation-profile no_data_agent

# Run no-determinism ablation
python3 -m mer.orchestrator.main --ablation-profile no_determinism_agent

# Run no-environment ablation
python3 -m mer.orchestrator.main --ablation-profile no_environment_agent

# Combine full-agent and sub-component ablations
python3 -m mer.orchestrator.main \
  --disable-agent planner \
  --disable-component data.llm_terminal_judge \
  --disable-component determinism.profile_llm

For external developers, install the package and use the portable study runner:

pip install dl-faults-sandbox

mer-study-runner \
  --bug-id 035 \
  --codebase /path/to/cloned/repo \
  --bug-report /path/to/bug_report.txt \
  --repro /path/to/reproduce.py \
  --openai-api-key "$OPENAI_API_KEY"

The runner creates the dataset layout MER expects:

.mer-study/
  dataset/
    <bug-id>/
      bug_report.txt
      reproduce.py
      codebase/

By default the codebase is symlinked into the staged dataset. Use --mode copy if you want an isolated copy instead. Use --prepare-only if you only want the staged dataset without invoking MER yet.

For local repository-based testing, the repo also includes:

scripts/setup_and_run_bug.sh --openai-api-key "$OPENAI_API_KEY"

Each bug run now writes exactly one run log file:

  • logs/activities/<run_id>/run.log

Additional traceability artifacts are non-log files:

  • workflow_logs_manifest (all activity logs)
  • workflow_trajectory_json (phase-by-phase trajectory with durations and terminal-check outcomes)
  • workflow_errors_json (structured failures and stack traces)
  • workflow_langsmith_trace_config_json (trace metadata used for this run)

Batch mode also writes logs/dataset_batch_summary_<timestamp>.json including pointers to these artifacts per bug.

Ablations

Ablation config is fully CLI/JSON-driven:

  • --ablation-profile <name>: apply a predefined profile (repeatable)
  • --disable-agent <planner|environment|data|determinism>: disable a whole agent
  • --disable-component <agent.component>: disable sub-components
  • --ablation-config <path.json>: load JSON config with keys profiles, disable_agents, disable_components, notes
  • --ablation-json '<json>': inline JSON config

Metadata is persisted for every run and batch:

  • workflow_ablation_config_json artifact in each run
  • ablation_label and ablation_config_path in per-bug batch result entries
  • batch summary includes top-level ablation payload

When environment is disabled, MER bootstraps a barebones CPU sandbox (dl-sandbox:cpu-py310-torch) if needed and passes it through run context so data/determinism still run end-to-end.

Dataset Link Downloading

The data agent now scans both bug_report.* and reproduce_issue.py for dataset links, then downloads into the bug folder when remote artifacts are required.

Provider-aware handling:

  • Kaggle links (kaggle.com/datasets/..., kaggle.com/competitions/...) via Kaggle API.
  • GitHub links (github.com/..., raw.githubusercontent.com/...) via GitHub endpoints.
  • Other links via direct HTTP download.
  • requested_format is inferred from URL/query/context; if a ZIP is downloaded and a non-zip format is requested, MER extracts and returns a matching file when possible.

Configuration (environment variables):

  • KAGGLE_USERNAME and KAGGLE_KEY for Kaggle API downloads.
  • GITHUB_TOKEN (optional but recommended) for GitHub API/authenticated downloads.

Built-in profiles:

  • no_planner_agent
  • no_environment_agent
  • no_data_agent
  • no_determinism_agent
  • planner_no_llm_heuristics
  • planner_no_llm_policy_override
  • planner_no_llm
  • environment_no_dependency_planner_llm
  • environment_no_resource_mocking
  • environment_no_gpu_detection
  • data_no_bug_static_scan
  • data_no_remote_download
  • data_no_bug_dir_reconstruction
  • data_no_fidelity_iteration
  • data_no_repo_context_scan
  • data_no_data_role_assessment
  • data_no_llm
  • determinism_no_profile_llm
  • determinism_no_refinement

Legacy/utility profile:

  • none

LangSmith

Set LANGSMITH_API_KEY in your environment (or .env) and run with --langsmith. Optional env/flags:

  • LANGSMITH_PROJECT / --langsmith-project
  • LANGSMITH_ENDPOINT / --langsmith-endpoint

Development

  • Agents: Located in mer/agents/. Each agent (local, data, determinism, driver) has its own package.
  • Tools: Located in mer/tools/. Generic tools are shared; specific tools are injected by the orchestrator.

Structure

  • mer/orchestrator/: Core logic and agent management.
  • mer/agents/: Autonomous agents for each phase of the pipeline.
  • mer/tools/: Tool definitions (Docker control, Static Analysis, etc.).
  • mer/libs/: Native libraries (e.g., libdeterminism.so source).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dl_faults_sandbox-0.1.0.tar.gz (95.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dl_faults_sandbox-0.1.0-py3-none-any.whl (112.4 kB view details)

Uploaded Python 3

File details

Details for the file dl_faults_sandbox-0.1.0.tar.gz.

File metadata

  • Download URL: dl_faults_sandbox-0.1.0.tar.gz
  • Upload date:
  • Size: 95.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for dl_faults_sandbox-0.1.0.tar.gz
Algorithm Hash digest
SHA256 dce7d761c4a27a62bb053f8327c318abe830d5d6ddec37b241963d155a5b6436
MD5 1e3e7c51bcd7d74749737ce8d8db224c
BLAKE2b-256 7c51558552a54a6741b31356a66efed4291791e7abca0bf0c227382df022a7fd

See more details on using hashes here.

File details

Details for the file dl_faults_sandbox-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for dl_faults_sandbox-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 21358cbdc7ca229d45c30d9c31eca5b6862a3767ff003e2da8db2a158c43f616
MD5 781a4a409d74849e75a079f06feea958
BLAKE2b-256 faabe928bfb6d98aaec281fa6bd644d3e1b1a118212400056e8cfc7a1aba9ef5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page