Commit debdf00
Split TransitionCriterion into TransitionCriterion and GenerationCriterion (facebook#4854)
Summary:
Pull Request resolved: facebook#4854
**TLDR:** This diff splits TransitionCriterion into (1) TransitionCriterion and (2) GenerationBlockingCriterion. I think this makes sense to do because it *greatly* increases the conceptual clarity of the transition criterion. Some ways it does this include:
1. Removal of confusing dual purpose flags — block_transition_if_unmet and block_generation_if_met flags. Now transition criteria are inferred to block transition if unmet and generation criteria are inferred to raise informative errors if the criteria is met.
2. Each criterion contains less flags, and the flags are more directly intuitive.
3. With upcoming removal of special logic for online, we will need to add more generation blocking criteria (ie do we have an opt config), it is better to make this change before adding more criteria that will need to be migrated
4. It will allows the logic for transition and generation to be smoother — this diff keeps things ~= to exisiting logic as possible to minimize diff review overhead, but in subsequent diffs we can save fit time if we know we can’t generate from this node + can’t transition. It will also allow for some further clarification on generation/transition blocking logic that i think is contributing to the confusion of the file
5. i like that creating a new generation blocking criteria with a specific error to raise is easy and painless
**Cons of this change:**
- it’s a large change, sorry about that.
- There is some duplication between TrialBased transition criterion and generation criterion. I explored using a Mixin here, but i find mixins tend to add unnecessary inheritance structures to reason about.
**Most important files for review, in order of importance**
1. transition_criterion.py
2. generation_node.py
3. decoder.py
4. encoders.py
5. registery.py
6. generation_strategy_dispatch.py
7. generation_nodes.py
8. generation_strategy.py
The remaining files are mainly trivial updates to tests
**Note about backwards compatibility:**
* This diff will directly decode legacy MaxGenerationParallelism as a generation blocking criterion called MaxGenrationParallelism
* Historically, there are some instances of mintrials that have block_gen_if_met=True, this usually comes from enforce_num_trials=True. Now we call this MaxTrialsAwaitingData, and MinTrials is decoded as that. I am open to other, better names for this new criterion.
**Other notes/potential improvements:**
- we could split transition criterion, generation criterion, and utils into their own files. i kinda like them together, and if we do want to do this split i’d like to do it in a follow up to try to minimize an already v large blast radius
Reviewed By: lena-kashtelyan
Differential Revision: D92201085
fbshipit-source-id: 27a8b6c6afe81d35d1c41b7e45c384a2934c32571 parent c2f9aec commit debdf00
20 files changed
Lines changed: 947 additions & 518 deletions
File tree
- ax
- api/utils
- tests
- generation_strategy
- tests
- orchestration/tests
- service
- tests
- storage
- json_store
- tests
- sqa_store/tests
- utils/testing
- tutorials/external_generation_node
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
75 | | - | |
76 | 74 | | |
77 | 75 | | |
78 | 76 | | |
79 | 77 | | |
80 | 78 | | |
81 | 79 | | |
82 | | - | |
83 | | - | |
84 | 80 | | |
85 | 81 | | |
86 | 82 | | |
87 | 83 | | |
88 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
89 | 96 | | |
90 | 97 | | |
91 | 98 | | |
| |||
95 | 102 | | |
96 | 103 | | |
97 | 104 | | |
| 105 | + | |
98 | 106 | | |
99 | 107 | | |
100 | 108 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | | - | |
103 | | - | |
104 | 102 | | |
105 | 103 | | |
106 | 104 | | |
107 | 105 | | |
108 | 106 | | |
109 | 107 | | |
110 | | - | |
111 | | - | |
112 | 108 | | |
113 | 109 | | |
114 | 110 | | |
| |||
390 | 386 | | |
391 | 387 | | |
392 | 388 | | |
393 | | - | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
394 | 401 | | |
395 | 402 | | |
396 | 403 | | |
| |||
0 commit comments