-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: dialect to represent combinational circuits #110
Comments
CIRCT has a comb dialect: https://circt.llvm.org/docs/Dialects/Comb/ |
WDYT about CIRCT as a dependency? IMO yes it's large, but I think it'd be great to re-use the existing comb dialect. |
I recall they were missing a LUT operation, but they seem to have added it recently: comb.truth_table (::circt::comb::TruthTableOp) It is a big dependency... I'm just taking quick notes here to see what else they provide that would make the dependency worthwhile
The folding logic seems nice, but if we're planning to use an external optimizer, they don't provide us that much value since they would be unlikely to cover what the external optimizer doesn't cover. IMO the two alternatives to consider are:
|
I also noticed that the majority of their ops are variadic, and they take advantage of it by canonicalizing stuff like |
They also have an
So I have been successful at building just the Comb dialect (not the passes yet) using a custom BUILD file after cloning circt - so this is kind of the route I'm going. We could also further simplify it, but if we're using the files as is, it's not too bad to filter for the relevant files and define our custom Bazel builds. |
Shruthi mentioned an interesting idea: would we have a use for the |
Let's see, I was under the impression the Yosys pass would be used to optimize arithmetic circuits anyway using blackbox cells? (It can likely do that better than MLIR can). In that case, since the cells we chose for that would be reflected from the supported ops of the crypto dialect, perhaps that could really simplify it - the LUT/binary cell targets binary LWE / CGGI, while arithmetic targets other shortint schemes! We can frame the Yosys pass as an "optimize circuit for XYZ scheme" - and make it more like a lowering pass that performs optimizations rather than a rewrite. Makes sense? @code-perspective for feedback EDIT: The one downside is that it would be nice to use the Yosys pass for other non-FHE things (like optmizing an MPC circuit) - the comb intermediate representation is nice for a non-opinionated representation. Something to consider... |
Some programs may benefit from translation into a combinational circuit with logic gates that can then be optimized by tools (like Yosys).
These programs can eventually target FHE schemes that implement boolean logic / LUTs (such as TFHE).
In order to integrate combinational lgoic optimizations, we need a dialect or IR that can represent these programs, and then create passes that may invoke programs like ABC through Yosys to optimize gates.
The ops involved would be LUTs (perhaps with rewrite patterns that would be able to optimize these LUTs (related: google/fully-homomorphic-encryption#62 @johannesmono) or fix the LUTs to certain sizes) and boolean gates.
@j2kun
The text was updated successfully, but these errors were encountered: