Zhidaily AI · Intelligence · Daily
Zhidaily
Issue 7 · November 6, 2026 · Fri
Today's stories
12 stories · 10 companies
Home / November 6, 2026 / trainlint uses static checks to catch ML training bugs that do not raise errors
← Back
Release Models Score6

trainlint uses static checks to catch ML training bugs that do not raise errors

MachineLearning /u/Possible-Active-1903 · Reddit · reddit.com
Nov 6 · 00:54 Read the original ↗
01Summary

A Reddit author released trainlint, a Python AST-based static checker that finds 14 common machine learning code errors that do not throw exceptions, including feature selection before the data split causing leakage, forgetting to disable eval() during training, adding softmax before CrossEntropyLoss, calling zero_grad between backward and step, keeping loss as a tensor, and swapping y_true and y_pred. It parses only names in the code and needs no data, model or GPU, and currently recognises only PyTorch and scikit-learn patterns. Using 5000 random features and random labels, the author showed leakage severity: selecting the top 20 features on all data before 5-fold cross-validation gives 85% accuracy (87.7% averaged over 20 random seeds), while moving selection into a Pipeline gives only 48% (50.0% average). The author also stated validation limits: the 20 defective scripts were written alongside the rules and only guard against regressions; external testing covered only a fixed commit of pytorch/examples, with 22 warnings, 20 real issues and 2 correct but harmless, and no recall data.

02Background

trainlint is an AST-based offline static checker that scans PyTorch and scikit-learn training and evaluation code using name matching, and runs without data, models or a GPU. Its project page says it uses the MIT licence, has no dependencies, currently provides 14 rules and supports JSON output for CI integration.

03Impact

For developers using PyTorch or scikit-learn, the tool can flag leakage, mode switching and loss function misuse without running training, making it suitable as an auxiliary check before commits or during code review. However, the author explicitly states that it matches by name, reads only one file at a time, and misjudges uncommon split naming conventions, so warnings need human review and cannot replace experimental validation.