File size: 2,383 Bytes
0feb6c8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
---
title: PyTorch Debug Env
emoji: πŸ”₯
colorFrom: orange
colorTo: red
sdk: docker
app_port: 7860
short_description: Multi-step RL environment for diagnosing broken PyTorch training jobs
tags:
  - openenv
  - pytorch
  - reinforcement-learning
  - debugging
  - ml-training
  - agent
pinned: true
---

# PyTorch Debug Env πŸ”₯

A complete [OpenEnv](https://meta-pytorch.org/OpenEnv/) environment for the **Meta PyTorch Hackathon** where an AI agent investigates and diagnoses broken PyTorch training jobs.

## Quick Start

```python
from openenv import AutoEnv, AutoAction

env = AutoEnv.from_env("ArchCoder/pytorch-debug-env")
Action = AutoAction.from_env("ArchCoder/pytorch-debug-env")

with env.sync() as client:
    result = client.reset(task_id="easy")
    action = Action(
        current_hypothesis={
            "bug_type": "missing_zero_grad",
            "affected_file": "train.py",
            "confidence": 0.7
        },
        commit_diagnosis=False
    )
    step_result = client.step(action)
```

## API Endpoints

| Endpoint | Method | Description |
|----------|--------|-------------|
| `/` | GET | Environment info |
| `/health` | GET | Health check |
| `/reset?task_id=easy` | POST | Start new episode |
| `/step` | POST | Submit hypothesis + action |
| `/state` | GET | Current episode state |

## Tasks

| Task | Difficulty | Description |
|------|-----------|-------------|
| `easy` | ⭐ | Single-file bug β€” missing `zero_grad`, wrong loss |
| `medium` | ⭐⭐ | Multi-file root cause β€” data leakage, scheduler mismatch |
| `hard` | ⭐⭐⭐ | Silent failure β€” memory leak, AMP overflow, red herrings |

## Reward Structure

- **Hypothesis delta** (60%) β€” reward for improving your bug hypothesis each step
- **Investigation** (20%) β€” reward for inspecting the right files
- **Final diagnosis** (20%) β€” accuracy of committed diagnosis vs ground truth

Scores range from `0.0` to `1.0`. Partial credit for correct bug category on hard tasks.

## Environment State

Each episode provides a synthetic PyTorch repo with:
- Source files (`train.py`, `model/`, `data/`, `config/`)
- Loss curves and GPU memory profiles
- Training logs with realistic noise and red herrings

The agent reveals files progressively across up to 5–6 steps, refining its hypothesis before committing a final diagnosis.

## Author

**Priyansh Saxena** β€” IIIT Gwalior