Skip to content

Commit 1c796f8

Browse files
janselmeta-codesync[bot]
authored andcommitted
Simplify Min/Max using ShapeEnv value ranges (#186248)
Summary: ShapeEnv.simplify previously only had narrow handling for Max(0, x) and Max(1, x), so value-range facts such as torch._check(u0 <= 5) were not used to simplify Min(u0, 5). That left guards like Eq(Min(5, u0), u0) data-dependent in Dynamo even though the ordering was already known. Generalize the ShapeEnv simplification pass to visit both Min and Max atoms and remove dominated arguments when ShapeEnv can prove their ordering from value ranges. The current implementation keeps the reasoning in ShapeEnv, where range information is available, and uses cheap lower-bound/sign checks before the heavier bound_sympy path so common Min/Max simplifications do not pay the full static solver cost. The legacy _maybe_evaluate_static fallback remains limited to preserving the previous Max(0/1, x) behavior. This pass runs only in the non-size-oblivious path, preserving the existing size-oblivious guard behavior. A narrower binary-only change would fix the exact repro, but using the same proved-ordering rule for n-ary Min/Max avoids leaving equivalent flattened expressions unsimplified while still requiring ShapeEnv to prove every removed argument. Fixes #137096 Generated by my agent Benchmark Results: - Mixed cold simplify workload with 400 legacy Max expressions and 400 newly handled Min expressions: the earlier solver-heavy PR version was 0.340158s best of 5; after the cheap ordering checks and fallback tightening this is 0.069140s best of 5. - Unproven Min/Max stress workload with 500 expressions: 0.243360s best of 5 after fallback tightening, compared with 0.537786s best of 3 before the narrowing in that follow-up. - Legacy Max-only cold simplify workload stayed roughly unchanged in earlier benchmarking: main best of 5 was 0.122475s and the patched path was 0.125108s. X-link: pytorch/pytorch#186248 Approved by: https://github.com/aorenste Reviewed By: jeanschmidt Differential Revision: D112034768 fbshipit-source-id: 1578a2df94ca1a242206573f452f2cdcc172e9c6
1 parent 6ee1e55 commit 1c796f8

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

userbenchmark/dynamo/dynamobench/huggingface.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ skip:
66
- BlenderbotForConditionalGeneration
77
- GPTNeoForCausalLM
88
- GPTNeoForSequenceClassification
9+
# Fails importing transformers.modeling_deberta_v2 with current TorchScript.
10+
- DebertaV2ForMaskedLM
911
# Fails with even batch size = 1
1012
- GPTJForCausalLM
1113
- GPTJForQuestionAnswering

0 commit comments

Comments
 (0)