|
1 | | -# TrainCheck Checker Usage Guide |
| 1 | +# CLI Reference: Check Traces |
2 | 2 |
|
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`. |
4 | 4 |
|
5 | | -## 🔧 Checking Modes |
| 5 | +TrainCheck has two checking modes: |
6 | 6 |
|
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. |
8 | 9 |
|
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. |
11 | 11 |
|
12 | | -- **On-the-fly Checking (`traincheck-onlinecheck`):** |
13 | | - Perform real-time checking while the target training job is running. ✅ |
| 12 | +## Live Checking |
14 | 13 |
|
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: |
18 | 15 |
|
19 | 16 | ```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 |
21 | 22 | ``` |
22 | 23 |
|
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: |
26 | 25 |
|
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 | +``` |
28 | 29 |
|
29 | | -## How to Use: Post-training Checking |
| 30 | +The online checker watches `target_trace/` and updates its report as new traces arrive. |
30 | 31 |
|
31 | | -Run the following command: |
| 32 | +If the command fails with a missing `watchdog` package, install it in the same environment: |
32 | 33 |
|
33 | 34 | ```bash |
34 | | -traincheck-check -f <trace_folder> -i <path_to_invariant_file> |
| 35 | +pip install watchdog |
35 | 36 | ``` |
36 | 37 |
|
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: |
39 | 39 |
|
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 | +``` |
43 | 46 |
|
44 | | -### Standalone HTML Report (default) |
| 47 | +## Offline Checking |
45 | 48 |
|
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: |
49 | 50 |
|
50 | | -**Offline example** |
51 | 51 | ```bash |
52 | | -traincheck-check -f <trace_folder> -i <path_to_invariant_file> |
| 52 | +traincheck-check -f target_trace -i invariants.json |
53 | 53 | ``` |
54 | 54 |
|
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 | + |
56 | 61 | ```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 |
58 | 69 | ``` |
59 | 70 |
|
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: |
64 | 72 |
|
65 | 73 | ```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 |
68 | 75 | ``` |
69 | 76 |
|
70 | 77 | ```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 |
73 | 79 | ``` |
74 | 80 |
|
75 | | -### MLflow Integration |
| 81 | +The checker does not decide which steps were traced. It checks the trace files that collection produced. |
76 | 82 |
|
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: |
79 | 94 |
|
80 | 95 | ```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 |
83 | 100 | ``` |
84 | 101 |
|
| 102 | +## W&B and MLflow |
| 103 | + |
| 104 | +Log checker results to Weights & Biases: |
| 105 | + |
85 | 106 | ```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 |
88 | 112 | ``` |
89 | 113 |
|
90 | | -### Online Report Refresh |
| 114 | +Attach offline checker metrics to an existing W&B run: |
91 | 115 |
|
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: |
94 | 125 |
|
95 | 126 | ```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 |
98 | 132 | ``` |
99 | 133 |
|
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. |
101 | 135 |
|
102 | | -## Interpreting the Results |
| 136 | +## Useful Options |
103 | 137 |
|
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. |
105 | 146 |
|
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: |
109 | 148 |
|
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