Use ISL equality check - #3256
Conversation
That was the LRM model. For tc_resnet I am compiling with these flags and the version of tc_resnet I'm using has this signature It compiles in 75 seconds with 19 seconds in convert-to-ciphertext-semantics and 33 seconds in configure-crypto-context. That said, I'm currently working on a bug where if I omit the |
j2kun
left a comment
There was a problem hiding this comment.
Generally speaking, I think enumeration of points will not scale well and I've observed performance issues with it.
Can you do the following:
- Add the slow relations to the benchmarking target in benchmark/isl (maybe add an equality check benchmark).
- Add a step to this that estimates the size of the two relations using a fast approximate method. You could try the recently added
relationSize(which is exact) or isl'sbox_hullorisl_map_polyhedral_hull. Use this with a decent threshold to determine if enumeration will be too slow. - Use the
tryProveUnequaltest before enumeration, since that one should be much faster and can short-circuit the rest of the function. If you userelationSizeand it's fast enough, you could also use this to short-circuit the full enumeration (if it's false, the two relations are unequal).
b2aef5b to
59d81c5
Compare
I changed the name of the PR because I tried the ISL version and it is much faster on my example and does not hang. As such, this solution might be a bit over engineered: I could also change it to just using the ISL version and be done with it, without doing the quick checks first. |
|
yes, I am fine to just using the ISL version, provided all the benchmarks align. Can you also add a comment line there to remark which specific Presburger API call was the one that was slow? Eventually I would like to improve the performance of the upstream Presburger library, and it would help to have some bread-crumbs (this PR and code comments) |
59d81c5 to
39d713e
Compare
never use IntegerRelation isEqual
39d713e to
ef9ff9f
Compare
I ended up keeping the volume check since it is very fast (and left a comment as you requested). If you could have a look, I think it is good to go (modulo the missing hash. Should I reopen a new PR from the google repo instead of our Belfortlabs fork?) |
When running the tc-resnet model, we could never finish running heir-opt because the following check was blowing up
heir/lib/Transforms/ConvertToCiphertextSemantics/ConvertToCiphertextSemantics.cpp
Lines 2377 to 2378 in de797a2
Here, we replace this check with an enumeration of the points to make it faster.
Alternatively, we could simply omit this check and assume that the expandedRelation is indeed equal to the input relation.
@j2kun Do I remember correctly that you said you could compile this model in 30 seconds? It could be that we are hitting this check because of some other changes we introduced and you avoided it? These checks are certainly not free (we compile in 320 seconds without the checks, and 420 seconds with the checks)
Our TC-Resnet has dimension 40x101, and I suspect that the 101 dimension is particularly nasty for ISL, introducing a lot of floor/divs
I am looking for feedback if you think this approach is sensible.