Circuit Transformer: A Transformer That Preserves Logical Equivalence
Xihan Li, Xing Li, Lei Chen, Xing Zhang, Mingxuan Yuan, Jun Wang
TL;DR
The paper tackles the challenge of generating circuits that are strictly equivalent to a given Boolean function, addressing the risk of incorrect predictions by standard generative models. It introduces the Circuit Transformer, aTransformer-based model that uses a masking-based decoding process and a top-down sequential circuit representation to enforce equivalence throughout generation, aided by a three-valued logic to allow short-circuit evaluation. It also casts equivalence-preserving optimization as a Markov decision process and demonstrates an 88-million-parameter Circuit Transformer trained on Resyn2 signals to produce strictly equivalent yet more compact circuits, achieving zero equivalence violations on unseen data and often smaller results than ground truth. The work provides a practical pathway for exact, constraint-satisfying generation in hardware design and opens avenues for applying similar constrained-generation strategies to other domains requiring formal feasibility guarantees.
Abstract
Implementing Boolean functions with circuits consisting of logic gates is fundamental in digital computer design. However, the implemented circuit must be exactly equivalent, which hinders generative neural approaches on this task due to their occasionally wrong predictions. In this study, we introduce a generative neural model, the "Circuit Transformer", which eliminates such wrong predictions and produces logic circuits strictly equivalent to given Boolean functions. The main idea is a carefully designed decoding mechanism that builds a circuit step-by-step by generating tokens, which has beneficial "cutoff properties" that block a candidate token once it invalidate equivalence. In such a way, the proposed model works similar to typical LLMs while logical equivalence is strictly preserved. A Markov decision process formulation is also proposed for optimizing certain objectives of circuits. Experimentally, we trained an 88-million-parameter Circuit Transformer to generate equivalent yet more compact forms of input circuits, outperforming existing neural approaches on both synthetic and real world benchmarks, without any violation of equivalence constraints.
