[RFC][AutoTVM] Non-square ConfigSpace
Hello! I find that non-square ConfigSpace might be critical to a project I'm working on, while currently this is not supported. By non-square I mean the scheduling of one axis has a constraint that is also relying on another axis. For example, if we have a sample code like:
cfg.define_split('split_x', X, num_outputs=2, policy='factors')
cfg.define_split('split_y', Y, num_outputs=2, policy='factors')
cfg['split_x'].apply(s, A, X)
cfg['split_y'].apply(s, A, Y)
and if we want to limit the inner block size to be less or equal to 64, then we have a constraint
cfg['split_x'].size[-1] * cfg['split_y'].size[-1] <= 64
We cannot simply pass this constraint as cfg.define_split(..., filter=...), so I'm seeking a solution for this. My current plan is to leave the instantiation of xxxSpace, e.g. SplitSpace, ReorderSpace unchanged and add constraints ConfigSpace so that only valid parameters under these constraints will be returned when queried. I see there's a _constaints variable in ConfigEntity but it seems not been used anywhere. Should I get started from here?
Any suggestions are much appreciated!
This sounds like you need polyhedral model?
@masahi Yes, exactly, but it looks like TVM doesn't support it, does it?
I'm thinking of a temporary workaround by adding appending all the constraints and axis dependencies as well as a function to verify a config's validity to the ConfigEntity class. Every time when a tuner's next_batch function is called, it calls the validation function and only takes those configs that are valid. I think directly making changes on the ConfigEntity class itself to only keep the valid configs might mess up the stuff.
Would love to hear your advice!
In this case it is not polyhedral model, but just some constraints on the config space.
Polyhedral analysis would be an approach to generate the constraints in this scenario. On the other hand, the runtime validation sounds not a general solution, because it might affect the tuner. For example, throwing invalid configs in next_batch would result in no measurement results for those records, which means the learning based tuner won't get the feedback of invalid configs. I would prefer either of the following:
- Propose a new config space representation to support non-grid config space.
- Let verify passes pluggable. Currently, we have
VerifyGPUpass that traverses TIR to estimate the memory usage and rejects invalid configs before sending them for compilation. Since this is at the evaluation stage, the rejected configs will still appear at the log file with proper error code, so that the tuner can benefit from it. We can make this mechanism as a callback so that users can bring their own verifier. The problem is that the verifier does not have config space information but just a graph in TIR, so it might be more difficult to check if it's valid or not.
@tqchen @comaniac Thanks for the comments! The feedback of the invalid configs is something I didn't think of. Actually this is the representation I came up for non-grid config space. If the config space is too large, and there are too many constraints so that the shape of the space is very irregular, it will cost too much memory to store the whole config space during the runtime. Therefore I'm thinking of storing a grid space with the current representation and its constraints as the solution. I wonder if it is possible to throw the error code in next_batch? Or the error code can only be thrown by a low-level check?
The second plan sounds like an interesting idea. Is it gonna be a new pass as you suggest? My concern is as Ansor comes out the pass might not be of great use in the future. What's your opinion?
I assume this is no longer active.