Closed ugobenazra closed 4 months ago
Take a look at the "rejection_sample" method in "model_utils.py" where this error is being thrown. https://ax.dev/api/_modules/ax/models/model_utils.html
How it works is that points are generated with "gen_unconstrained", and filters out those which don't meet the parameter constraint. In your case, you add "2*(nbr_hidden_blocks-1)" order constraints on tensor_out_dimblock{i} and tensor_expand_ratioblock{i}. So once you increase the number up to 8 blocks, there are 14 parameter constraints which need to be satisfied for a unconstrained candidate to meet the parameter constraints.
Because the parameters are unconstrained, the chance of a single candidate meeting all 14 of these is (0.5)^14 = 0.000061. So for 10000 draws, the chance of none of them being a valid candidate is (1 - 0.000061)^10000 = 0.54. This means that at 8 blocks, you'll fail to find a valid candidate more than half the time.
For 7 blocks, the chance of a candidate meeting all 12 constraints is 0.0002, and the chance of all 10,000 draws failing to meet the constraints is (1 - 0.0002)^10000 = 0.087- this explains why you did not encounter this issue when using 7 or less blocks.
So your issue is coming from the parameter constraints scaling with the number of blocks. Let me know if this makes sense and if you have any other questions.
We do have an option to fall back to a different sampler in such cases of search spaces that are highly constrained: https://www.internalfb.com/code/fbsource/[f4eb45809174569b78529c2bf29b56025610ecf9]/fbcode/ax/models/random/base.py?lines=63
This is not enabled by default (it probably should be though?), but you can manually construct a Sobol GenerationStep
that does this by passing model_kwargs = {"fallback_to_sample_polytope": False}
to the GenerationStep
constructor. See https://github.com/facebook/Ax/issues/2373 for an example of this.
Hello,
Thank you very much for your clear explanations. Now I have a better understanding of from where my issue came from and I'll find a way to deal with it.
Hello, I got some issues with my search space. I am using Ax to perform NAS on hyper parameters but more importantly on the neural network architecture. I am using the Developper API from Ax to make it choose, according to SOBOL and then BO, every layer of my hidden blocks, the output dimensions of each block., layer's parameters and so on
I also added some parameter constraints on output dimensions and expand_ratio.
As soon as I added the parameter constraints on the expand_ratio, the script crashed and wrote me :
Seeing this, I started to think that my constraints were not working well so I first removed them. Then I started to increase the number of hidden blocks that Ax will have to generate. As soon as I went over 8 blocks, the same error appeared. So from what I understand, the issue does not come from the constraints but from the search space that is maybe too big or too complex. The probability that my understanding of the package is not good and that I made a mistake is also high.
Here is the Ax script that I run for this task. I'm open for any comment, suggestion, or solution and I would be pleased to discuss with the community to better understand the logics behind. I didn't upload the whole code because it is quite big and I don't think it's a necessity but I'm open to this option if it is.