[AutoScheduler] Querying and sampling in task extraction #7571
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR deals with the case that we may want to extract tuning tasks from a JIT model that compiles each subgraph when first time executing the model graph. In this case, we need at least one valid schedule (for GPU) to make sure we can visit the whole graph and collect all tasks, but this may not be the case especially for the backward model.
The above puzzle forms a chicken egg problem -- we don't have valid schedules so we need to extract tasks to tune, but we need at least one valid schedule in order to extract tasks. This PR solves this puzzle by sampling one valid schedule during task extraction:
The idea is once we found that there's no valid schedule of the task being collected, we immediately sample a valid schedule and use it for the current subgraph. In this way, we guarantee the graph can be visited from beginning to the end.
cc @merrymercy