Skip to content

Commit ca5f51e

Browse files
authored
Fix backwards_compat job misattribution in log classifier (#8390)
The backwards_compat job runs check_public_api_test_fails self-checks that deliberately emit FAIL lines in every log (green or red), causing the classifier to blame red jobs on these self-checks instead of the real cause. - Update the 'Operator backwards compatibility' rule to tolerate the '[WARNING <timestamp> <file>:<line>] ' logging-formatter prefix that check_forward_backward_compatibility.py now prepends, while still matching the pre-Oct-2024 unprefixed print() format. - Add a 'Forward/backward compatibility check failed' rule for the 'FC/BC check failed' torchscript model-load failures. - Add regression tests covering both formats and the model-load case.
1 parent 25522d9 commit ca5f51e

2 files changed

Lines changed: 80 additions & 1 deletion

File tree

aws/lambda/log-classifier/ruleset.toml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,19 @@
1616
# For example, for the failure 'FAIL [10.2s]: test_foo', 'test_foo' is a
1717
# good capture group, as it filters out test timings which might be
1818
# variable.
19+
# NB: check_forward_backward_compatibility.py emits this through a logging
20+
# formatter that prepends '[WARNING <timestamp> <file>:<line>] ', so the
21+
# message no longer starts at column 0. Keep the capture group to just the
22+
# stable sentence so captures stay groupable (no timestamps).
1923
[[rule]]
2024
name = 'Operator backwards compatibility'
21-
pattern = '^The PR is introducing backward incompatible changes to the operator library.'
25+
pattern = '^(?:\[WARNING [^\]]+\] )?(The PR is introducing backward incompatible changes to the operator library\.)'
26+
27+
# Emitted by test_forward_backward_compatibility() in pytorch's .ci/pytorch/test.sh
28+
# when the torchscript model load checks fail.
29+
[[rule]]
30+
name = 'Forward/backward compatibility check failed'
31+
pattern = '^(?:FC|BC) check failed: .*'
2232

2333
[[rule]]
2434
name = 'Failed graph_break_registry check'

aws/lambda/log-classifier/src/main.rs

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,75 @@ mod test {
265265
}
266266
}
267267

268+
// Regression test: a red backwards_compat job must be blamed on the real
269+
// cause (check_forward_backward_compatibility.py's "backward incompatible
270+
// changes" warning), not on the FAIL lines from the deliberate
271+
// failure-injection self-checks (check_public_api_test_fails) that appear
272+
// in EVERY backwards_compat log, green or red.
273+
#[test]
274+
fn backwards_compat_not_blamed_on_public_api_self_check() {
275+
let ruleset = RuleSet::new_from_config();
276+
let log = Log::new(
277+
"\
278+
++ python test/test_public_bindings.py -k test_modules_can_be_imported\n\
279+
+ test_output='FAIL: test_modules_can_be_imported (__main__.TestPublicBindings)\n\
280+
Generating XML reports...\n\
281+
FAILED (failures=1)'\n\
282+
Success! 'test_modules_can_be_imported' identified a non-importable module torch.abcd1234.\n\
283+
+ python check_forward_backward_compatibility.py --existing-schemas nightly_schemas.txt\n\
284+
[WARNING 2026-07-28 01:23:45,678 check_forward_backward_compatibility.py:332] The PR is introducing backward incompatible changes to the operator library. Please contact PyTorch team to confirm whether this change is wanted or not. \n\
285+
\n\
286+
Broken ops: [\n\
287+
\taten::foo(Tensor self) -> Tensor\n\
288+
]\n\
289+
##[error]Process completed with exit code 1.\n\
290+
"
291+
.into(),
292+
);
293+
let match_ = evaluate_ruleset(&ruleset, &log).unwrap();
294+
assert_eq!(match_.rule.name, "Operator backwards compatibility");
295+
assert_eq!(
296+
match_.captures,
297+
vec![
298+
"The PR is introducing backward incompatible changes to the operator library."
299+
.to_string()
300+
]
301+
);
302+
}
303+
304+
// The pre-Oct-2024 checker printed the message with plain print(), i.e. no
305+
// "[WARNING ...]" prefix. Make sure that format still matches too.
306+
#[test]
307+
fn backwards_compat_matches_unprefixed_format() {
308+
let ruleset = RuleSet::new_from_config();
309+
let log = Log::new(
310+
"\
311+
FAIL: test_modules_can_be_imported (__main__.TestPublicBindings)\n\
312+
The PR is introducing backward incompatible changes to the operator library. Please contact PyTorch team to confirm whether this change is wanted or not.\n\
313+
"
314+
.into(),
315+
);
316+
let match_ = evaluate_ruleset(&ruleset, &log).unwrap();
317+
assert_eq!(match_.rule.name, "Operator backwards compatibility");
318+
}
319+
320+
#[test]
321+
fn backwards_compat_bc_fc_model_load_failure() {
322+
let ruleset = RuleSet::new_from_config();
323+
let log = Log::new(
324+
"\
325+
FAIL: test_modules_can_be_imported (__main__.TestPublicBindings)\n\
326+
BC check failed: old model cannot be load in new code\n\
327+
"
328+
.into(),
329+
);
330+
let match_ = evaluate_ruleset(&ruleset, &log).unwrap();
331+
assert_eq!(
332+
match_.rule.name,
333+
"Forward/backward compatibility check failed"
334+
);
335+
}
336+
268337
#[test]
269338
fn gather_optional_context() {
270339
let mut ruleset = RuleSet::new();

0 commit comments

Comments
 (0)