Skip to content

Commit ff45cb4

Browse files
committed
Improve TrainCheck workflow documentation
1 parent 6c4f006 commit ff45cb4

11 files changed

Lines changed: 519 additions & 478 deletions

README.md

Lines changed: 65 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,73 +2,102 @@
22
<picture>
33
<img alt="TrainCheck logo" width="55%" src="https://raw.githubusercontent.com/OrderLab/TrainCheck/main/docs/assets/images/traincheck_logo.png">
44
</picture>
5-
<h1>TrainCheck: Invariant Checking & Observability for AI Training</h1>
5+
<h1>TrainCheck: Invariant Checking for AI Training</h1>
66

77
[![Chat on Discord](https://img.shields.io/badge/Discord-Join%20us-5865F2?logo=discord&logoColor=white)](https://discord.gg/ZvYewjsQ9D)
88
[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/OrderLab/TrainCheck)
99

1010
</div>
1111

12+
TrainCheck catches silent training bugs by learning what a healthy run does, then checking a new run against those learned invariants. It works by tracing PyTorch API calls and model state changes, so you can inspect training behavior before a loss curve or final metric tells you something went wrong.
1213

13-
**Stop flying blind.** TrainCheck gives you deep visibility into your training dynamics, continuously validating correctness and stability where standard metrics fail.
14+
## Install
1415

15-
---
16+
Install TrainCheck in the same Python environment that runs your training script:
1617

17-
### Why TrainCheck?
18+
```bash
19+
pip3 install traincheck
20+
```
1821

19-
**Continuous Invariant Checking**
20-
TrainCheck validates the "physics" of your training process in real-time. It ensures your model adheres to learned invariants—such as gradient norms, tensor shapes, and update magnitudes—effectively catching silent corruption before it wastes GPU hours.
22+
For CUDA, conda, and source-install details, see the [Installation Guide](https://orderlab.io/TrainCheck/installation-guide/).
2123

22-
🚀 **Holistic Observability**
23-
Traditional tools only show you *if* your model crashed. TrainCheck shows you *why* it's degrading, analyzing internal state dynamics that loss curves miss.
24+
## Use TrainCheck
2425

25-
🧠 **Zero-Config Validation**
26-
No manual tests required. TrainCheck automatically learns the invariants of your specific model from healthy runs and flags deviations instantly.
26+
TrainCheck has four main steps.
2727

28-
**Universal Compatibility**
29-
Drop-in support for PyTorch, Hugging Face, and industry-class workloads using DeepSpeed/Megatron and more.
28+
### 1. Collect a Reference Trace
3029

31-
---
32-
## Installation
30+
Run `traincheck-collect` on a known-good training script. This should be a short run that covers the training behavior you want TrainCheck to learn.
31+
32+
```bash
33+
traincheck-collect \
34+
--pyscript reference.py \
35+
--models-to-track model \
36+
--output-dir reference_trace
37+
```
3338

34-
Install TrainCheck in the Python environment where you will run your training script:
39+
### 2. Infer Invariants
40+
41+
Turn the reference trace into invariants:
3542

3643
```bash
37-
pip3 install traincheck
44+
traincheck-infer -f reference_trace -o invariants.json
45+
```
46+
47+
### 3. Collect a Target Trace
48+
49+
Run the target training script with the inferred invariants. Passing `--invariants` lets TrainCheck trace only the APIs and variables needed for those checks.
50+
51+
```bash
52+
traincheck-collect \
53+
--pyscript target.py \
54+
--models-to-track model \
55+
--invariants invariants.json \
56+
--output-dir target_trace
3857
```
3958

40-
For detailed setup (CUDA configuration, UV, conda environments), see the [Installation Guide](https://orderlab.io/TrainCheck/installation-guide/).
59+
For long target runs, trace fewer steps:
4160

61+
```bash
62+
traincheck-collect \
63+
--pyscript target.py \
64+
--models-to-track model \
65+
--invariants invariants.json \
66+
--sampling-interval 10 \
67+
--warm-up-steps 10 \
68+
--output-dir target_trace
69+
```
4270

43-
### How It Works
71+
### 4. Check the Target Run
4472

45-
1. **Instrument**: We wrap your training loop with lightweight probes—no code changes needed.
46-
2. **Learn**: We analyze correct runs to infer *invariants* (mathematical rules of healthy training).
47-
3. **Check**: We monitor new runs in real-time, verifying every step against learned invariants to catch silent logic bugs and hardware faults.
73+
For live checking, start `traincheck-onlinecheck` while the target run is writing traces:
4874

49-
![Workflow](https://raw.githubusercontent.com/OrderLab/TrainCheck/main/docs/assets/images/workflow.png)
75+
```bash
76+
traincheck-onlinecheck -f target_trace -i invariants.json
77+
```
5078

51-
## 🔥 Try TrainCheck
79+
The easier offline path is to wait for trace collection to finish, then run:
5280

53-
Work through [5‑Minute Experience with TrainCheck](./docs/5-min-tutorial.md). You’ll learn how to:
54-
- Instrument a training script and collect a trace
55-
- Automatically infer invariants
56-
- Uncover silent bugs in the training script
81+
```bash
82+
traincheck-check -f target_trace -i invariants.json
83+
```
84+
85+
Both checkers write a results directory with failure logs and a `report.html` summary.
5786

58-
## Documentation
87+
## Learn More
5988

60-
- **[Installation Guide](https://orderlab.io/TrainCheck/installation-guide/)**
61-
- **[Usage Guide: Scenarios and Limitations](https://orderlab.io/TrainCheck/usage-guide/)**
62-
- **[TrainCheck Technical Doc](https://orderlab.io/TrainCheck/technical-doc/)**
89+
- [Use TrainCheck](https://orderlab.io/TrainCheck/usage-guide/) explains the full workflow and output files.
90+
- [5-Minute Tutorial](./docs/5-min-tutorial.md) walks through a real silent training issue.
91+
- [Installation Guide](https://orderlab.io/TrainCheck/installation-guide/) covers environment setup.
92+
- [Technical Documentation](https://orderlab.io/TrainCheck/technical-doc/) describes invariants, trace representation, and implementation details.
6393

6494
## Status
6595

66-
TrainCheck is under active development. Please join our 💬 [Discord server](https://discord.gg/VwxpJDvB) or file a GitHub issue for support. You can also reach the team at [traincheck@umich.edu](mailto:traincheck@umich.edu).
67-
We welcome feedback and contributions from early adopters.
96+
TrainCheck is under active development. Please join our [Discord server](https://discord.gg/VwxpJDvB), file a GitHub issue, or email [traincheck@umich.edu](mailto:traincheck@umich.edu).
6897

6998
## Contributing
7099

71-
We welcome and value any contributions and collaborations. Please check out [Contributing to TrainCheck](./CONTRIBUTING.md) for how to get involved.
100+
We welcome contributions. See [Contributing to TrainCheck](./CONTRIBUTING.md) for setup and contribution guidance.
72101

73102
## License
74103

@@ -77,6 +106,7 @@ TrainCheck is licensed under the [Apache License 2.0](./LICENSE).
77106
## Citation
78107

79108
If TrainCheck is relevant to your work, please cite our paper:
109+
80110
```bib
81111
@inproceedings{TrainCheckOSDI2025,
82112
author = {Jiang, Yuxuan and Zhou, Ziming and Xu, Boyu and Liu, Beijie and Xu, Runhui and Huang, Peng},
@@ -90,7 +120,6 @@ If TrainCheck is relevant to your work, please cite our paper:
90120
}
91121
```
92122

93-
94123
## Artifact Evaluation
95124

96-
🕵️‍♀️ OSDI AE members, please see [TrainCheck AE Guide](./docs/ae.md).
125+
OSDI AE members should use the [TrainCheck AE Guide](./docs/ae.md).

docs/ae-eval-s5.5-perf-overhead.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ This evaluation measures the runtime overhead introduced by TrainCheck’s instr
2121
- Located in [overhead-e2e](../eval_scripts/perf_benchmark/overhead-e2e)
2222

2323
- The deployed 100 invariants:
24-
[eval_scripts/perf_benchmark/overhead-e2e/sampled_100_invariants.json](../eval_scripts/perf_benchmark/overhead-e2e/sampled_100_invariants.json)
24+
`eval_scripts/perf_benchmark/overhead-e2e/sampled_100_invariants.json`
2525

2626

2727
## 🛠 How to Run

docs/check.md

Lines changed: 101 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,110 +1,152 @@
1-
# TrainCheck Checker Usage Guide
1+
# CLI Reference: Check Traces
22

3-
`traincheck-check` is the **final stage** of the TrainCheck workflow. It verifies a set of invariants against trace files or streams from target programs, reporting any detected violations—helping you catch silent issues in your ML training pipelines.
3+
Start with [Use TrainCheck](usage-guide.md) if you want the full workflow. This page explains `traincheck-onlinecheck` and `traincheck-check`.
44

5-
## 🔧 Checking Modes
5+
TrainCheck has two checking modes:
66

7-
TrainCheck supports two checking modes:
7+
- `traincheck-onlinecheck` checks traces while `traincheck-collect` is still writing them.
8+
- `traincheck-check` checks completed trace files after collection finishes.
89

9-
- **Post-training Checking (`traincheck-check`)**:
10-
Perform invariant checking on completed trace files after the training job finishes. ✅
10+
Use online checking when you want violations during a running job. Use offline checking when you want the easiest path or a reproducible local workflow.
1111

12-
- **On-the-fly Checking (`traincheck-onlinecheck`):**
13-
Perform real-time checking while the target training job is running. ✅
12+
## Live Checking
1413

15-
## How to Use: On-the-fly Checking
16-
17-
While training is in progress with `traincheck-collect`, run the following command:
14+
Start trace collection for the target run:
1815

1916
```bash
20-
traincheck-onlinecheck -f <trace_folder> -i <path_to_invariant_file>
17+
traincheck-collect \
18+
--pyscript target.py \
19+
--models-to-track model \
20+
--invariants invariants.json \
21+
--output-dir target_trace
2122
```
2223

23-
- `-f <trace_folder>`: Path to the folder where traces are:
24-
- Already collected, or
25-
- **Actively being collected** by `traincheck-collect` during the training job.
24+
In another terminal, start the online checker:
2625

27-
- `-i <path_to_invariant_file>`: Path to the JSON file containing inferred invariants.
26+
```bash
27+
traincheck-onlinecheck -f target_trace -i invariants.json
28+
```
2829

29-
## How to Use: Post-training Checking
30+
The online checker watches `target_trace/` and updates its report as new traces arrive.
3031

31-
Run the following command:
32+
If the command fails with a missing `watchdog` package, install it in the same environment:
3233

3334
```bash
34-
traincheck-check -f <trace_folder> -i <path_to_invariant_file>
35+
pip install watchdog
3536
```
3637

37-
- `-f <trace_folder>`: Path to the folder containing traces collected by `traincheck-collect`.
38-
- `-i <path_to_invariant_file>`: Path to the JSON file containing inferred invariants.
38+
Control the report refresh interval with:
3939

40-
## Report Visualization Options
41-
42-
Both checkers can produce a standalone HTML report and optionally log summary metrics to external monitoring tools.
40+
```bash
41+
traincheck-onlinecheck \
42+
-f target_trace \
43+
-i invariants.json \
44+
--report-interval-seconds 30
45+
```
4346

44-
### Standalone HTML Report (default)
47+
## Offline Checking
4548

46-
- Output: `<output_dir>/report.html`
47-
- Includes summary counts, relation breakdown, and top violations.
48-
- Disable with `--no-html-report`.
49+
The offline path is simpler. First let `traincheck-collect` finish, then run:
4950

50-
**Offline example**
5151
```bash
52-
traincheck-check -f <trace_folder> -i <path_to_invariant_file>
52+
traincheck-check -f target_trace -i invariants.json
5353
```
5454

55-
**Online example**
55+
Offline checking reads the completed trace folder and writes a results directory.
56+
57+
## Sampling and Checking
58+
59+
Sampling is configured during trace collection:
60+
5661
```bash
57-
traincheck-onlinecheck -f <trace_folder> -i <path_to_invariant_file>
62+
traincheck-collect \
63+
--pyscript target.py \
64+
--models-to-track model \
65+
--invariants invariants.json \
66+
--sampling-interval 10 \
67+
--warm-up-steps 10 \
68+
--output-dir target_trace
5869
```
5970

60-
### W&B Integration
61-
62-
Enable with `--report-wandb`. You can also pass:
63-
`--wandb-project`, `--wandb-entity`, `--wandb-run-name`, `--wandb-group`, `--wandb-tags`.
71+
Then run either checker normally:
6472

6573
```bash
66-
traincheck-check -f <trace_folder> -i <path_to_invariant_file> \
67-
--report-wandb --wandb-project <project>
74+
traincheck-onlinecheck -f target_trace -i invariants.json
6875
```
6976

7077
```bash
71-
traincheck-onlinecheck -f <trace_folder> -i <path_to_invariant_file> \
72-
--report-wandb --wandb-project <project>
78+
traincheck-check -f target_trace -i invariants.json
7379
```
7480

75-
### MLflow Integration
81+
The checker does not decide which steps were traced. It checks the trace files that collection produced.
7682

77-
Enable with `--report-mlflow`. Optional:
78-
`--mlflow-experiment`, `--mlflow-run-name`.
83+
## Reports and Logs
84+
85+
Both checkers write:
86+
87+
- `failed.log`: violated invariants.
88+
- `passed.log`: triggered invariants that passed.
89+
- `not_triggered.log`: invariants that never ran on the trace.
90+
- `violations_summary.json`: compact violation summaries.
91+
- `report.html`: browser-readable summary.
92+
93+
The default output directory is timestamped. Use `-o` or `--output-dir` to choose a path:
7994

8095
```bash
81-
traincheck-check -f <trace_folder> -i <path_to_invariant_file> \
82-
--report-mlflow --mlflow-experiment <experiment>
96+
traincheck-check \
97+
-f target_trace \
98+
-i invariants.json \
99+
--output-dir check_results
83100
```
84101

102+
## W&B and MLflow
103+
104+
Log checker results to Weights & Biases:
105+
85106
```bash
86-
traincheck-onlinecheck -f <trace_folder> -i <path_to_invariant_file> \
87-
--report-mlflow --mlflow-experiment <experiment>
107+
traincheck-check \
108+
-f target_trace \
109+
-i invariants.json \
110+
--report-wandb \
111+
--wandb-project traincheck
88112
```
89113

90-
### Online Report Refresh
114+
Attach offline checker metrics to an existing W&B run:
91115

92-
The online checker refreshes the report when violations change, and also on a periodic timer.
93-
Control the interval with `--report-interval-seconds` (default: 10).
116+
```bash
117+
traincheck-check \
118+
-f target_trace \
119+
-i invariants.json \
120+
--report-wandb \
121+
--wandb-run-id <run-id>
122+
```
123+
124+
Log checker results to MLflow:
94125

95126
```bash
96-
traincheck-onlinecheck -f <trace_folder> -i <path_to_invariant_file> \
97-
--report-interval-seconds 30
127+
traincheck-check \
128+
-f target_trace \
129+
-i invariants.json \
130+
--report-mlflow \
131+
--mlflow-experiment traincheck
98132
```
99133

100-
**Note:** W&B and MLflow logging are optional. If the packages are not installed, TrainCheck will skip logging and emit a warning.
134+
The online checker supports the same W&B and MLflow reporting flags.
101135

102-
## Interpreting the Results
136+
## Useful Options
103137

104-
After running either checking mode, TrainCheck will output a summary of detected invariant violations. Each violation entry typically includes:
138+
- `-f, --trace-folders`: trace directories produced by `traincheck-collect`.
139+
- `-t, --traces`: individual trace files.
140+
- `-i, --invariants`: invariant files produced by `traincheck-infer`.
141+
- `-o, --output-dir`: results directory.
142+
- `--no-html-report`: skip `report.html`.
143+
- `--report-wandb`: log summary metrics and the HTML report to W&B.
144+
- `--report-mlflow`: log summary metrics and the HTML report to MLflow.
145+
- `--report-interval-seconds`: online checker report refresh interval.
105146

106-
- **Trace file or stream name**: Identifies where the issue was found.
107-
- **Invariant description**: Details the specific invariant that was violated.
108-
- **Violation details**: Provides context, such as the step or epoch where the violation occurred.
147+
Run the command help for the complete option list:
109148

110-
Review these results to pinpoint silent errors or unexpected behaviors in your ML training pipeline. For more information on result formats and how to diagnose issues, see [5. Detection & Diagnosis](./5-min-tutorial.md#5-detection--diagnosis) in the **5-Minute Tutorial**.
149+
```bash
150+
traincheck-check --help
151+
traincheck-onlinecheck --help
152+
```

0 commit comments

Comments
 (0)