# bold_boolean_logic_deep_learning__eb22acb6.pdf BOLD: Boolean Logic Deep Learning Van Minh Nguyen Cristian Ocampo Aymen Askri Louis Leconte Ba-Hien Tran Mathematical and Algorithmic Sciences Laboratory, Huawei Paris Research Center, France vanminh.nguyen@huawei.com Computational intensiveness of deep learning has motivated low-precision arithmetic designs. However, the current quantized/binarized training approaches are limited by: (1) significant performance loss due to arbitrary approximations of the latent weight gradient through its discretization/binarization function, and (2) training computational intensiveness due to the reliance on full-precision latent weights. This paper proposes a novel mathematical principle by introducing the notion of Boolean variation such that neurons made of Boolean weights and/or activations can be trained for the first time natively in Boolean domain instead of latent-weight gradient descent and real arithmetic. We explore its convergence, conduct extensively experimental benchmarking, and provide consistent complexity evaluation by considering chip architecture, memory hierarchy, dataflow, and arithmetic precision. Our approach achieves baseline full-precision accuracy in Image Net classification and surpasses state-of-the-art results in semantic segmentation, with notable performance in image super-resolution, and natural language understanding with transformer-based models. Moreover, it significantly reduces energy consumption during both training and inference. 1 Introduction Deep learning [59] has become the de facto solution to a wide range of tasks. However, running deep learning models for inference demands significant computational resources, yet it is just the tip of the iceberg. Training deep models is even much more intense. The extensive literature on this issue can be summarized into four approaches addressing different sources of complexity. These include: (1) model compression, pruning [38, 20, 109] and network design [94, 44, 96] for large model dimensions; (2) arithmetic approximation [58, 94, 15] for intensive multiplication; (3) quantization techniques like post-training [106, 34], quantization-aware training [37, 114, 51], and quantized training to reduce precision [16, 93]; and (4) hardware design [18, 87, 105, 101, 35, 112] to overcome computing bottleneck by moving computation closer to or in memory. Aside from hardware and dataflow design, deep learning designs have primarily focused on the number of compute operations (OPs), such as FLOPS or BOPS, as a complexity measure [33, 83] rather than the consumed energy or memory, and particularly in inference tasks. However, it has been demonstrated that OPs alone are inadequate and even detrimental as a measure of system complexity. Instead, energy consumption provides a more consistent and efficient metric for computing hardware Van Minh developed the mathematical principle, designed and implemented the Boolean deep learning framework first in C++ and later in Py Torch, validated the concept on the MNIST and CIFAR-10 benchmarks, and led all aspects of the project. Cristian evaluated the design using computer vision benchmarks. Aymen analyzed and evaluated the computational complexity. Louis proposed the incorporation of plasticity effects in the Boolean optimizer and developed the convergence analysis. Ba Hien contributed to the design and evaluation of Boolean attention mechanisms and enhanced the quality of the paper s presentation. 38th Conference on Neural Information Processing Systems (Neur IPS 2024). [94, 95, 108, 92]. Data movement, especially, dominates energy consumption and is closely linked to system architecture, memory hierarchy, and dataflow [57, 89, 110, 19]. Therefore, efforts aimed solely at reducing OPs are inefficient. Quantization-aware training, notably binarized neural networks (BNNs) [24, 47], have garnered significant investigation [see, e.g. 83, 34, and references therein]. BNNs typically binarize weights and activations, forming principal computation blocks in binary. They learn binary weights, wbin, through full-precision (FP) latent weights, wfp, leading to no memory or computation savings during training. For example, a binarized linear layer is operated as s = α w binxbin, where s is the output and α is a FP scaling factor, wbin = sign(wfp), and xbin = sign(xfp) is the binarized inputs. The weights are updated via common gradient descent backpropagation, i.e. wbin = sign(wfp η gwfp) with a learning rate η, and FP gradient signal gwfp. Gradient approximation of binarized variables often employs a differentiable proxy of the binarization function sign, commonly the identity proxy. Various approaches treat BNN training as a constrained optimization problem [7, 2, 3, 65], exploring methods to derive binary weights from real-valued latent ones. BNNs commonly suffers notable accuracy drops due to reduced network capacity and the use of proxy FP optimizers [61] instead of operating directly in binary domain [83, 77, 36]. Recent works mitigate this by incorporating multiple FP components in the network, retaining only a few binary dataflows [68]. Thus, while binarization aids in reducing inference complexity, it increases network training complexity and memory usage. In contrast to binarizing FP models like BNNs, designing native binary models not relying on FP latent weight has been explored. For example, Expectation Backpropagation [91], although operating on full-precision training, was proposed for this purpose. Statistical physics-inspired [8, 9] and Belief Propagation [10] algorithms utilize integer latent weights, mainly applied to single perceptrons, with unclear applicability to deep models. Evolutionary algorithms [75, 50] are also an alternative but encounter performance and scalability challenges. Summary: No scalable and efficient algorithm currently exists for natively training deep models in binary. The challenge of significantly reducing the training complexity while maintaining high performance of deep learning models remains open. Contributions. For the aforementioned challenge, we propose a novel framework Boolean Logic Deep Learning (B LD) which relies on Boolean notions to define models and training: We introduce the notion of variation to the Boolean logic and develop a new mathematical framework of function variation (see 3.2). One of the noticeable properties is that Boolean variation has the chain rule (see Theorem 3.12) similar to the continuous gradient. Based on the proposed framework, we develop a novel Boolean backpropagation and optimization method allowing for a deep model to support native Boolean components operated solely with Boolean logic and trained directly in Boolean domain, eliminating the need for gradient descent and FP latent weights (see 3.3). This drastically cuts down memory footprint and energy consumption during both training and inference (see, e.g., Fig. 1). We provide a theoretical analysis of the convergence of our training algorithm (see Theorem 3.17). We conduct an extensive experimental campaign using modern network architectures such as convolutional neural networks (CNNs) and Transformers [100] on a wide range of challenging tasks including image classification, segmentation, super-resolution and natural language understanding (see 4). We rigorously evaluate analytically the complexity of B LD and BNNs. We demonstrate the superior performance of our method in terms of both accuracy and complexity compared to the state-of-the-art (see, e.g., Table 4, Table 5, Table 7). 2 Are Current Binarized Neural Networks Really Efficient? Our work is closely related with the line of research on binarized neural networks (BNNs). The concept of BNNs traces back to early efforts to reduce the complexity of deep learning models. BINARYCONNECT [24] is one of the pioneering works that introduced the idea of binarizing FP weights during training, effectively reducing memory footprint and computational cost. Similarly, BINARYNET [47], XNOR-NET [86] extended this approach to binarize both weights and activations, further enhancing the efficiency of neural network inference. However, these early BNNs struggled with maintaining accuracy comparable to their full-precision counterparts. To address this issue, Table 1: A summary of SOTA BNNs compared to our method. The notation indicates the nonexistence of a specific requirement (column) within a given method (row). The colors denoting the methods shall be used consistently throughout the paper. Method Bitwidth Specialized Mandatory Multi-stage or Weight Backprop Training (Weight-Act.) Architecture FP Components KD Training Updates Arithmetic ( ) BINARYNET [47] 1-1 FP latent-weights Gradient FP ( ) BINARYCONNECT [24] 1-32 FP latent-weights Gradient FP ( ) XNOR-NET [86] 1-1 FP latent-weights Gradient FP ( ) BI-REALNET [69] 1-1 FP latent-weights Gradient FP ( ) REAL2BINARY [73] 1-1 FP latent-weights Gradient FP ( ) REACTNET [68] 1-1 FP latent-weights Gradient FP ( ) MELIUS-NET [11] 1-1 FP latent-weights Gradient FP ( ) BNEXT [36] 1-1 FP latent-weights Gradient FP ( ) POKEBNN [117] 1-1 FP latent-weights Gradient FP ( ) B LD [Ours] 1-1 Native Boolean weights Logic Logic significant advances have been made on BNNs [see, e.g., 83, 85, and references therein], which can be categorized into three main aspects. 1 Binarization strategy. The binarization strategy aims to efficiently convert real-valued data such as activations and weights into binary form { 1, 1}. The sign function is commonly used for this purpose, sometimes with additional constraints such as clipping bounds in state-of-the-art (SOTA) methods like POKEBNN [117] or BNEXT [36]. REACTNET [68] introduces rsign as a more general alternative to the sign function, addressing potential shifts in the distribution of activations and weights. Another approach [99] explores the use of other two real values instead of strict binary to enhance the representational capability of BNNs. 2 Optimization and training strategy. BNN optimization relies totally on latent-weight training, necessitating a differentiable proxy for the backpropagation. Moreover, latent-weight based training methods have to store binary and real parameters during training and often requires multiple sequential training stages, where one starts with training a FP model and only later enables binarization [36, 117, 107]. This further increases the training costs. Furthermore, knowledge distillation (KD) has emerged as a method to narrow the performance gap by transferring knowledge from a full-precision teacher model to a binary model [68, 107, 117, 60]. While a single teacher model can sufficiently improve the accuracy of the student model, recent advancements like multi-KD with multiple teachers, such as BNEXT [36], have achieved unprecedented performance. However, the KD approach often treats network binarization as an add-on to full-precision models. In addition, this training approach relies on specialized teachers for specific tasks, limiting adaptability on new data. Lastly, [103, 41] proposed some heuristics and improvements to the classic BNN latent-weight based optimizer. B LD WITH BATCH-NORM B LD W/O BATCH-NORM BINARYCONNECT XNOR-NET BINARYNET Energy Consum. w.r.t. FP (%) ( ) Accuracy (%) ( ) Figure 1: Our method against notable BNNs on CIFAR10 using VGG-SMALL. The energy is analytically evaluated considering a hypothetical V100 equivalence with native 1-bit support; cf 4 for details. 3 Architecture design. Architecture design in BNNs commonly utilizes RESNET [69, 68, 11, 36] and MOBILENET [68, 36] layouts. These methodologies often rely on heavily modified basic blocks, including additional shortcuts, automatic channel scaling via squeezeand-excitation (SE) [117], block duplication with concatenation in the channel domain [68, 36]. Recent approaches introduce initial modules to enhance input adaptation for binary dataflow [107] or replace convolutions with lighter point-wise convolutions [66]. Another related line of research involves logic gate networks (LGNs) [79]. In LGNs, each neuron functions as a binary logic gate and, consequently, has only two inputs. Unlike traditional neural networks, LGNs do not utilize weights; instead, they are parameterized by selecting a specific logic gate for each neuron, which can be learned. Compared to the standard neural networks or our proposed method, LGNs are sparse because each neuron receives only two inputs rather than multiple inputs. Recently, [5] expanded on LGNs by incorporating flexible and differentiable lookup tables. While these advancements show promises, adapting them to modern neural network architectures such as CNN or Transformers is challenging. Furthermore, these approaches have not been validated on large-scale datasets like IMAGENET or on tasks that require high precision, such as image segmentation or super-resolution, as demonstrated in our work. Summary. Table 1 shows key characteristics of SOTA BNN methods. These methods will be considered in our experiments. Notice that all these techniques indeed have to involve operations on FP latent weights during training, whereas our proposed method works directly on native Boolean weights. In addition, most of BNN methods incorporate FP data and modules as mandatory components. As a result, existing BNNs consume much more training energy compared to our B LD method. An example is shown in Fig. 1, where we consider the VGG-SMALL architecture [24, 90] on CIFAR10 dataset. In 4 we will consider much larger datasets and networks on more challenging tasks. We can see that our method achieves 36 and more than 15 energy reduction compared to the FP baseline and BINARYNET, respectively, while yielding better accuracy than BNNs. Furthermore, BNNs are commonly tied to specialized network architecture and have to employ costly multi-stage or KD training. Meanwhile, our Boolean framework is completely orthogonal to these BNN methods. It is generic and applicable for a wide range of network architectures, and its training procedure purely relies on Boolean logic from scratch. Nevertheless, we stress that it is not obligatory to use all Boolean components in our proposed framework as it is flexible and can be extended to architectures comprised of a mix of Boolean and FP modules. This feature further improves the superior performance of our method as can be seen in Fig. 1, where we integrate batch normalization (BN) [49] into our Boolean model, and we will demonstrate extensively in our experiments. 3 Proposed Method 3.1 Neuron Design Boolean Neuron. For the sake of simplicity, we consider a linear layer for presenting the design. Let w0, (w1, . . . , wm), and (x1, . . . , xm) be the bias, weights, and inputs of a neuron of input size m 1. In the core use case of our interest, these variables are all Boolean numbers. Let L be a logic gate such as AND, OR, XOR, XNOR. The neuron s pre-activation output is given as follows: i=1 L(wi, xi), (1) where the summation is understood as the counting of TRUEs. Mixed Boolean-Real Neuron. To allow for flexible use and co-existence of this Boolean design with real-valued parts of a deep model, two cases of mixed-type data are considered including Boolean weights with real-valued inputs, and real-valued weights with Boolean inputs. These two cases can be addressed by the following extension of Boolean logic to mixed-type data. To this end, we first introduce the essential notations and definitions. Specifically, we denote B := {T, F} equipped with the Boolean logic. Here, T and F indicate TRUE and FALSE, respectively. Definition 3.1 (Three-valued logic). Define M def = B {0} with logic connectives defined according to those of Boolean logic as follows. First, the negation is: T = F, F = T, and 0 = 0. Second, let L be a logic connective, denote by LM and LB when it is in M and in B, respectively, then LM(a, b) = LB(a, b) for a, b B and LM(a, b) = 0 otherwise. Notation 3.2. Denote by L a logic set (e.g., B or M), R the real set, Z the set of integers, N a numeric set (e.g., R or Z), and D a certain set of L or N. Definition 3.3. For x N, its logic value denoted by xlogic is given as xlogic = T x > 0, xlogic = F x < 0, and xlogic = 0 x = 0. Definition 3.4. The magnitude of a variable x, denoted |x|, is defined as its usual absolute value if x N. And for x L: |x| = 0 if x = 0, and |x| = 1 otherwise. Definition 3.5 (Mixed-type logic). For L a logic connective of L and variables a, b, operation c = L(a, b) is defined such that |c| = |a||b| and clogic = L(alogic, blogic). Using Definition 3.5, neuron formulation Eq. 1 directly applies to the mixed Boolean-real neurons. Forward Activation. It is clear that there can only be one unique family of binary activation functions, which is the threshold function. Let τ be a scalar, which can be fixed or learned, the forward Boolean activation is given as: y = T if s τ and y = F otherwise where s is the preactivation. The backpropagation throughout this activation will be described in Appendix C.3. 3.2 Mathematical Foundation In this section we describe the mathematical foundation for our method to train Boolean weights directly in the Boolean domain without relying on FP latent weights. Due to the space limitation, essential notions necessary for presenting the main results are presented here while a comprehensive treatment is provided in Appendix A. Definition 3.6. Order relations < and > in B are defined as follows: F < T, and T > F. Definition 3.7. For a, b B, the variation from a to b, denoted δ(a b), is defined as: δ(a b) def = T if b > a, def = 0 if b = a, and def = F if b < a. Throughout the paper, F(S, T) denotes the set of all functions from source S to image T. Definition 3.8. For f F(B, D), x B, write δf(x x) := δ(f(x) f( x)). The variation of f w.r.t. x, denoted f (x), is defined as: f (x) def = xnor(δ(x x), δf(x x)). Remark 3.9. The usual notation of continuous derivative f is intentionally adopted here for Boolean variation for convenience and notation unification. Its underlying meaning, i.e., continuous derivative or Boolean variation, can be understood directly from the context where function f is defined. Intuitively, the variation of f w.r.t. x is T if f varies in the same direction with x. Example 3.10. Let a B, f(x) = xor(x, a) for x B, the variation of f w.r.t. x can be derived by establishing a truth table (see Table 8 in Appendix A.1) from which we obtain f (x) = a. For f F(Z, N), its derivative, also known in terms of finite differences, has been defined in the literature as f (x) = f(x + 1) f(x), see e.g. [52]. With the logic variation as introduced above, we can make this definition more generic as follows. Definition 3.11. For f F(Z, D), the variation of f w.r.t. x Z is defined as f (x) def = δf(x x + 1), where δf is in the sense of the variation defined in D. Theorem 3.12. The following properties hold: 1. For f F(B, B): ( f) (x) = f (x), x B. 2. For f F(B, N), α N: (αf) (x) = αf (x), x B. 3. For f, g F(B, N): (f + g) (x) = f (x) + g (x), x B. 4. For B f B g D: (g f) (x) = xnor(g (f(x)), f (x)), x B. 5. For B f Z g D, x B, if |f (x)| 1 and g (f(x)) = g (f(x) 1), then: (g f) (x) = xnor(g (f(x)), f (x)). The proof is provided in Appendix A.1. These results are extended to the multivariate case in a straightforward manner. For instance, for multivariate Boolean functions it is as follows. Definition 3.13. For x = (x1, . . . , xn) Bn, denote x i := (x1, . . . , xi 1, xi, xi+1, . . . , xn) for n 1 and 1 i n. For f F(Bn, B), the (partial) variation of f w.r.t. xi, denoted f i(x) or δf(x)/δxi, is defined as: f i(x) δf(x)/δxi def = xnor(δ(xi xi), δf(x x i)). Proposition 3.14. Let f F(Bn, B), n 1, and g F(B, B). For 1 i n: (g f) i(x) = xnor(g (f(x)), f i(x)), x Bn. (2) Example 3.15. From Example 3.10, we have δxor(x, a)/δx = a for a, x B. Using Theorem 3.12- (1) we have: δxnor(x, a)/δx = a since xnor(x, a) = xor(x, a). Example 3.16. Apply Theorem 3.12-(3) to s from Eq. 1: δs/δwi = δL(wi, xi)/δwi and δs/δxi = δL(wi, xi)/δxi. Then, for L = xnor as an example, we have: δs/δwi = xi and δs/δxi = wi. 3.3 Back Propagation With the notions introduced in 3.2, we can write signals involved in the backpropagation process as shown in Fig. 2. Therein, layer l is a Boolean layer of consideration. For the sake of presentation Boolean Layer Layer Figure 2: Illustration of backpropagation signals with a Boolean linear layer. Notice that the subsequent layer can be any FP/Boolean layers or activation functions. simplicity, layer l is assumed a fully-connected layer, and: xl+1 k,j = wl 0,j + i=1 L xl k,i, wl i,j , 1 j n, (3) where L is the utilized Boolean logic, k denotes sample index in the batch, m and n are the usual layer input and output sizes. Layer l is connected to layer l + 1 that can be an activation layer, a batch normalization, an arithmetic layer, or any others. The nature of δLoss/δxl+1 k,j depends on the property of layer l + 1. It can be the usual gradient if layer l + 1 is a real-valued input layer, or a Boolean variation if layer l + 1 is a Boolean-input layer. Given δLoss/δxl+1 k,j , layer l needs to optimize its Boolean weights and compute signal δLoss/δxl k,i for the upstream. Hereafter, we consider L = xnor when showing concrete illustrations of the method. Atomic Variation. First, using Theorem 3.12 and its extension to the multivariate case by Proposition 3.14 in the same manner as shown in Example 3.16, we have: δxl+1 k,j δwl i,j = δL(xl k,i, wl i,j) L=xnor = xl k,i, δxl+1 k,j δxl k,i = δL(xl k,i, wl i,j) L=xnor = wl i,j. (4) Using the chain rules given by Theorem 3.12 (4 & 5), we have: ql i,j,k := δLoss δwl i,j |k = xnor(δLoss δxl+1 k,j , δxl+1 k,j δwl i,j ) L=xnor = xnor(δLoss δxl+1 k,j , xl k,i), (5) gl k,i,j := δLoss δxl k,i |j = xnor(δLoss δxl+1 k,j , δxl+1 k,j δxl k,i ) L=xnor = xnor(δLoss δxl+1 k,j , wl i,j). (6) Aggregation. Atomic variation ql i,j,k is aggregated over batch dimension k while gl k,i,j is aggregated over output dimension j. Let 1( ) be the indicator function. For b B and variable x, define: 1(x = b) = 1 if xlogic = b and 1(x = b) = 0 otherwise. Atomic variations are aggregated as: ql i,j := δLoss δwl i,j = X k 1 ql i,j,k = T |ql i,j,k| X k 1 ql i,j,k = F |ql i,j,k|, (7) gl k,i := δLoss δxl k,i = X j 1 gl k,i,j = T |gl k,i,j| X j 1 gl k,i,j = F |gl k,i,j|. (8) Boolean Optimizer. With ql i,j obtained in Eq. 7, the rule for optimizing wl i,j subjected to making the loss decreased is simply given according to its definition as: wl i,j = wl i,j if xnor ql i,j, wl i,j = T. (9) Eq. 9 is the core optimization logic based on which more sophisticated forms of optimizer can be developed in the same manner as different methods such as Adam, Adaptive Adam, etc. have been developed from the basic gradient descent principle. For instance, the following is an optimizer that accumulates ql i,j over training iterations. Denote by ql,t i,j the optimization signal at iteration t, and by ml,t i,j its accumulator with ml,0 i,j := 0 and: ml,t+1 i,j = βtml,t i,j + ηtql,t+1 i,j , (10) where ηt is an accumulation factor that can be tuned as a hyper-parameter, and βt is an autoregularizing factor that expresses the system s state at time t. Its usage is linked to brain plasticity [31] and Hebbian theory [40] forcing weights to adapt to their neighborhood. For the chosen weight s neighborhood, for instance, neuron, layer, or network level, βt is given as: βt = Number of unchanged weights at t Total number of weights . (11) In the experiments presented later, βt is set to per-layer basis. Finally, the learning process is as described in Algorithm 1. We encourage the readers to check the detailed implementations, practical considerations, and example codes of our proposed method, available in Appendix B and Appendix C. Convergence Analysis. The following result describes how the iterative logic optimization based on Eq. 9 minimizes a predefined loss f, under the standard non-convex assumption. The technical assumptions and the proof are given in Appendix A.2. Theorem 3.17. Under the specified assumptions, Boolean optimization logic converges at: t=0 E h f (wt) 2i A Tη +B η+C η2+Lrd, (12) where A = 2(f(w0) f ) with f being uniform lower bound assumed exists, B = 2Lσ2, C = 4L2σ2 γ (1 γ)2 in which L is the assumed Lipschitz constant, and rd = dκ/2. The bound in Theorem 3.17 contains four terms. The first is typical for a general non-convex target and expresses how initialization affects the convergence. The second and third terms depend on the fluctuation of the minibatch gradients. There is an error bound of 2Ldκ independent of T. This error bound is the cost of using discrete weights as part of the optimization algorithm. Previous work with quantized models also includes such error bounds [61, 62]. Algorithm 1: Illustration with a FC layer. Input : Learning rate η, nb iterations T; Initialize : ml,0 i,j = 0; β0 = 1; 1 for t = 0, . . . , T 1 do /* 1. Forward */ 2 Compute xl+1,t following Eq. 3; /* 2. Backward */ 3 Receive δLoss δxl+1,t k,j from downstream layer; /* 2.1 Backpropagation */ 4 Compute and backpropagate gl,t of Eq. 8; /* 2.2 Weight update process */ 5 Ntot := 0, Nunchanged := 0; 6 foreach wl i,j do 7 Compute ql,t+1 i,j following Eq. 7; 8 Update ml,t+1 i,j = βtml,t i,j + ηtql,t+1 i,j ; 9 Ntot Ntot + 1; 10 if xnor(ml,t+1 i,j , wl,t i,j) = T then 11 wl,t+1 i,j = wl,t i,j; /* invert */ 12 ml,t+1 i,j = 0; 14 wl,t+1 i,j = wl,t i,j ; /* keep */ 15 Nunchanged Nunchanged + 1; 16 Update ηt+1, βt+1 = Nunchanged/Ntot ; Regularization. Exploding and vanishing gradients are two well-known issues when it comes to train deep neural networks. During Boolean Logic training, our preliminary experiments indicated that the backpropagation signal also experiences similar phenomenon, resulting in unstable training. Our idea is to scale the backpropagation signals so as to match their variance. Thanks to the Boolean structure, assumptions on the involved signals can be made so that the scaling factor can be analytically derived in closed-form without need of learning or batch statistics computation. Precisely, through linear layers of output size m, the backpropagation signal is scaled with p 2/m, and for convolutional layers of output size cout, stride v and kernel sizes kx, ky, the backpropagation signal is scaled with 2 p 2v/coutkxky if maxpooling is applied, or p 2v/coutkxky otherwise. The full detail is presented in Appendix C. 4 Experiments Our B LD method achieves extreme compression by using both Boolean activations and weights. We rigorously evaluate its performance on challenging precision-demanding tasks, including image classification on CIFAR10 [55] and IMAGENET [56], as well as super-resolution on five popular datasets. Furthermore, recognizing the necessity of deploying efficient lightweight models for edge computing, we delve into three fine-tuning scenarios, showcasing the adaptability of our approach. Specifically, we investigate fine-tuning Boolean models for image classification on CIFAR10 and CIFAR100 using VGG-SMALL. For segmentation tasks, we study DEEPLABV3 [17] fine-tuned on CITYSCAPES [23] and PASCAL VOC 2012 [29] datasets. The backbone for such a model is our Boolean RESNET18 [39] network trained from scratch on IMAGENET. Finally, we consider an evaluation in the domain of natural language understanding, fine-tuning BERT [26], a transformerbased [100] language model, on the GLUE benchmark [102]. Experimental Setup. To construct our B LD models, we introduce Boolean weights and activations and substitute full-precision (FP) arithmetic layers with Boolean equivalents. Throughout all benchmarks, we maintain the general network design of the chosen FP baseline, while excluding FP-specific components like Re LU, PRe LU activations, or batch normalization (BN) [49], unless specified otherwise. Consistent with the common setup in existing literature [see, e.g., 86, 21, 11], only the first and last layers remain in FP and are optimized using an Adam optimizer [54]. Comprehensive experiment details for reproducibility are provided in Appendix D. Complexity Evaluation. It has been demonstrated that relying solely on FLOPS and BOPS for complexity assessment is inadequate [94, 95, 108, 92]. In fact, these metrics fail to capture the actual load caused by propagating FP data through the BNNs. Instead, energy consumption serves as a crucial indicator of efficiency. Given the absence of native Boolean accelerators, we estimate analytically energy consumption by analyzing the arithmetic operations, data movements within storage/processing units, and the energy cost of each operation. This approach is implemented for the Nvidia GPU (Tesla V100) and Ascend [63] architectures. Further details are available in Appendix E. 4.1 Image Classification Our B LD method is tested on two network configurations: small & compact and large & deep. In the former scenario, we utilize the VGG-SMALL [90] baseline trained on CIFAR10. Evaluation of our Boolean architecture is conducted both without BN [24], and with BN including activation from [69]. These designs achieve 90.29 0.09% (estimated over six repetitions) and 92.37 0.01% (estimated over five repetitions) accuracy, respectively (see Table 2). Notably, without BN, our results align closely with BINARYCONNECT [24], which employs 32-bit activations during both inference and training. Furthermore, BN brings the accuracy within 1 point of the FP baseline. Additional results are provided in the supplementary material for VGG-SMALL models ending with 1 FC layer. Our method requires much less energy than the FP baseline. In particular, it consumes less than 5% of energy for our designs with and without BN respectively. These results highlight the remarkable energy efficiency of our B LD method in both inference and training, surpassing latent-weight based training methods [24, 86, 48] reliant on FP weights. Notably, despite a slight increase in energy consumption, utilizing BN yields superior accuracy. Even with BN, our approach maintains superior efficiency compared to alternative methods, further emphasizing the flexibility of our approach in training networks with a blend of Boolean and FP components. In the large & deep case, we consider the RESNET18 baseline trained from scratch on IMAGENET. We compare our approach to methods employing the same baseline, larger architectures, and additional training strategies such as KD with a RESNET34 teacher or FP-based shortcuts [69]. Our method consistently achieves the highest accuracy across all categories, ranging from the standard model (51.8% accuracy) to larger configurations (70.0% accuracy), as shown in Table 5. Additionally, our B LD method exhibits the smallest energy consumption in most categories, with a remarkable 24.45% for our large architecture with and without KD. Notably, our method outperforms the FP baseline when using 4 filter enlargement (base 256), providing significant energy reduction (24.45%). Furthermore, it surpasses the SOTA POKEBNN [117], utilizing RESNET50 as a teacher. For completeness, we also implemented neural gradient quantization, utilizing INT4 quantization with a logarithmic round-to-nearest approach [21] and statistics-aware weight binning [22]. Our experiments on IMAGENET confirm that 4-bit quantization is sufficient to achieve standard FP performances, reaching 67.53% accuracy in 100 epochs (further details provided in Appendix D.1.4). 4.2 Image Super-resolution Next, we evaluate the efficacy of our B LD method to synthesize data. We use a compact EDSR network [64] as our baseline, referred to as SMALL EDSR, comprising eight residual blocks. Our 2VGG-SMALL with the last FP layer mapping to 100 classes. Table 2: Results with VGG-SMALL on CIFAR10. Cons. is the energy consumption w.r.t. the FP baseline, evaluated on 1 training iteration. Method W/A Acc.(%) Cons.(%) Cons. (%) Ascend Tesla V100 Full-precision [114] 32/32 93.80 100.00 100.00 ( ) BINARYCONNECT [24] 1/32 90.10 38.59 48.49 ( ) XNOR-NET [86] 1/1 89.83 34.21 45.68 ( ) BINARYNET [47] 1/1 89.85 32.60 43.61 ( ) B LD w/o BN [Ours] 1/1 90.29 3.64 2.78 ( ) B LD with BN [Ours] 1/1 92.37 4.87 3.71 Table 3: Super-resolution results measured in PSNR (d B) ( ), using the EDSR baseline [64]. Task Method SET5 SET14 BSD100 URBAN100 DIV2K [12] [113] [46] [72] [1, 97] 2 FULL EDSR (FP) 38.11 33.92 32.32 32.93 35.03 SMALL EDSR (FP) 38.01 33.63 32.19 31.60 34.67 ( ) B LD [Ours] 37.42 33.00 31.75 30.26 33.82 3 FULL EDSR (FP) 34.65 30.52 29.25 31.26 SMALL EDSR (FP) 34.37 30.24 29.10 30.93 ( ) B LD [Ours] 33.56 29.70 28.72 30.22 4 FULL EDSR (FP) 32.46 28.80 27.71 26.64 29.25 SMALL EDSR (FP) 32.17 28.53 27.62 26.14 29.04 ( ) B LD [Ours] 31.23 27.97 27.24 25.12 28.36 Table 4: Image segmentation results. Dataset Model m Io U (%) ( ) CITYSCAPES FP BASELINE 70.7 BINARY DAD-NET [30] 58.1 ( ) B LD [Ours] 67.4 PASCAL VOC 2012 FP BASELINE 72.1 ( ) B LD [Ours] 67.3 Table 5: Results with RESNET18 baseline on IMAGENET. Base is the mapping dimension of the first layer. Energy consumption is evaluated on 1 training iteration. Cons. is the energy consumption w.r.t. the FP baseline. Training Method Acc. Cons. (%) Cons. (%) Modality (%) Ascend Tesla V100 FP BASELINE RESNET18 [39] 69.7 100.00 100.00 ( ) BINARYNET [47] 42.2 ( ) XNOR-NET [86] 51.2 ( ) B LD + BN (Base 64) 51.8 8.77 3.87 FP SHORTCUT ( ) BI-REALNET:18 [69] 56.4 46.60 32.99 LARGE MODELS ( ) BI-REALNET:34 [69] 62.2 80.00 58.24 ( ) BI-REALNET:152 [69] 64.5 ( ) MELIUS-NET:29 [11] 65.8 ( ) B LD (Base 256) 66.9 38.82 24.45 KD: RESNET34 ( ) REAL2BINARY [73] 65.4 ( ) REACTNET-RESNET18 [68] 65.5 45.43 77.89 ( ) BNEXT:18 [36] 68.4 45.48 37.51 ( ) B LD + BN (Base 192)) 65.9 26.91 16.91 ( ) B LD (Base 256) 70.0 38.82 24.45 KD: RESNET50 ( ) POKEBNN-RESNET18 [117] 65.2 Table 6: Results with VGG-SMALL baseline finetuned on CIFAR10 and CIFAR100. FT means Fine-Tuning . Ref. Method Model Init. Train./FT Dataset Bitwidth W/A/G Acc. (%) A FP BASELINE Random CIFAR10 32/32/32 95.27 B FP BASELINE 2 Random CIFAR100 32/32/32 77.27 C ( ) B LD Random CIFAR10 1/1/16 90.29 D ( ) B LD 2 Random CIFAR100 1/1/16 68.43 E FP BASELINE2 A CIFAR100 32/32/32 76.74 F ( ) B LD 2 C CIFAR100 1/1/16 68.37 G FP BASELINE B CIFAR10 32/32/32 95.77 H ( ) B LD D CIFAR10 1/1/16 92.09 B LD model employs Boolean residual blocks without BN. Results, presented in Table 3, based on the official implementation and benchmark3, reveal remarkable similarity to the FP reference at each scale. Particularly noteworthy are the prominent results achieved on SET14 and BSD100 datasets. Our method consistently delivers high PSNR for high-resolution images, such as DIV2K, and even higher for low-resolution ones, like SET5. However, akin to EDSR, our approach exhibits a moderate performance reduction at scale 4 . These findings highlight the capability of our method to perform adequately on detail-demanding tasks while exhibiting considerable robustness across image resolutions. 4.3 Adaptability on New Data Image classification fine-tuning. We aim to assess the adaptability of our method to similar problems but different datasets, a common scenario for edge inference tasks. We employ the VGGSMALL architecture without BN under two training configurations. Firstly, the B LD model is trained from scratch with random initialization on CIFAR10 (REF. C) and CIFAR100 (REF. D). Secondly, we fine-tune the trained networks on CIFAR100 (REF. F) and CIFAR10 (REF. H), respectively. Notably, in Table 6, fine-tuning our trained model on CIFAR100 (REF. F) results in a model almost identical to the model trained entirely from scratch (REF. D). Additionally, a noteworthy result is observed with our model (REF. H), which achieves higher accuracy than the model trained from scratch (REF. C). Image segmentation fine-tuning. Next, we expand the scope of the aforementioned fine-tuning experiment to encompass a larger network and a different task. The baseline is the DEEPLABV3 network for semantic segmentation. It consists of our Boolean RESNET18 (without BN) as the backbone, followed by the Boolean atrous pyramid pooling (ASPP) module [17] . We refrain from utilizing auxiliary loss or knowledge distillation techniques, as these methods introduce additional computational burdens, which are contrary to our objective of efficient on-device training. As demonstrated in Table 4, our method achieves a notable 67.4% m Io U on CITYSCAPES (see Fig. 3 for prediction examples). This result surpasses the SOTA, BINARY DAD-NET [30], and approaches 3https://github.com/sanghyun-son/EDSR-Py Torch the performance of the FP baseline. Likewise, on PASCAL VOC 2012, our methodology nears the performance of the FP baseline. Importantly, these improvements are attained without the intermediate use of FP parameters during training, highlighting the efficiency and effectiveness of our approach. This shows that our method not only preserves the inherent lightweight advantages of highly quantized neural networks but also significantly enhances performance in complex segmentation tasks. BERT fine-tuning for NLU tasks. Finally, we consider fine-tuning BERT [26], a transformer-based model [100], on the GLUE benchmark [102]. We follow the standard experimental protocol as in [26, 6, 82]. Our model and the chosen baselines are employed with 1-bit bitwidth for both weights and activations. Our Boolean BERT model is inspired by BIT [67] for binarizing activations and incorporating KD during training, where the FP teacher guides the student in a layer-wise manner. We follow the experimental setup of BIT, including using the same method for binarizing activations and backpropagation for softmax and attention in the BERT model. As shown in Table 7, all methods suffer from performance drop compared to the FP model as extreme binarization of transformer-based model is not trivial. Nevertheless, our method yields results comparable to BIT [67], the SOTA method on this task, outperforming BINARYBERT [6] and BIBERT [82] on average. This is remarkable as our method natively uses Boolean weights during the training, whereas the baselines heavily rely on FP latent weights. These findings indicate potential for energy-efficient large language models (LLMs) using our method for both training and inference. Reference Image Ground Truth Full-precision B LD (Ours) Figure 3: An example of CITYSCAPES. Table 7: BERT models results. Source code [67]. Method GLUE Benchmark (Accuracy, ) MNLI QQP QNLI SST-2 COLA SST-B MRPC RTE Avg. FP BERT 84.9 91.4 92.1 93.2 59.7 90.1 86.3 72.2 83.9 BINARYBERT 35.6 66.2 51.5 53.2 0.0 6.1 68.3 52.7 41.0 BIBERT 66.1 84.8 72.6 88.7 25.4 33.6 72.5 57.4 63.2 BIT 77.1 82.9 85.7 87.7 25.1 71.1 79.7 58.8 71.0 BIT (Reprod. ) 76.8 87.2 85.6 87.5 24.1 70.5 78.9 58.8 69.7 ( ) B LD 75.6 85.9 84.1 88.7 27.1 68.7 78.4 58.8 70.9 5 Conclusions We introduced the notion of Boolean variation and developed a first framework of its calculus. This novel mathematical principle enabled the development of Boolean logic backpropagation and Boolean optimization replacing gradient backpropagation and gradient descent for binary deep learning. Deep models can be built with native Boolean weights and/or Boolean activations, and trained in Boolean natively by this principled exact Boolean optimization. That brings a key advantage to the existing popular quantized/binarized training approach that suffers from critical bottlenecks (i) performance loss due to an arbitrary approximation of the latent weight gradient through its discretization/binarization function, (ii) training computational intensiveness due to full-precision latent weights. We have extensively explored its capabilities, highlighting: (i) both training and inference are now possible in binary; (iv) deep training complexity can be drastically reduced to unprecedented levels. (iii) Boolean models can handle finer tasks beyond classification, contrary to common belief; (ii) in some applications, suitablely enlarging Boolean model can recover FP performance while still gaining significant complexity reduction. Limitations. Due to current computing accelerators, such as GPUs, primarily designed for real arithmetic, our method could not be assessed on native Boolean accelerator. Nevertheless, its considerable potential may inspire the development of new logic circuits and architectures utilizing Boolean logic processing. It also remains as an open question the approximation capacity of Boolean neural networks. A mathematical result equivent to the existing universal approximation theory of real-valued neural networks would provide a solid guarantee. Acknowledgments This work has been made possible through the invaluable support of various departments and colleagues within Huawei. Van Minh Nguyen would like to extend his sincere thanks to everyone involved, with special appreciation to Jean-Claude Belfiore and the former students who have participated in this project over the years: Valentin Abadie, Tom Huix, Tianyu Li, and Youssef Chaabouni. [1] E. Agustsson and R. Timofte. NTIRE 2017 Challenge on Single Image Super-Resolution: Dataset and Study. In The IEEE Conference on Computer Vision and Pattern Recognition (CVPR) Workshops, July 2017. [2] T. Ajanthan, P. K. Dokania, R. Hartley, and P. H. Torr. Proximal Mean-field for Neural Network Quantization. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), October 2019. [3] T. Ajanthan, K. Gupta, P. Torr, R. Hartley, and P. Dokania. Mirror Descent View for Neural Network Quantization. In Proceedings of The 24th International Conference on Artificial Intelligence and Statistics, volume 130, pages 2809 2817. PMLR, 13 15 Apr 2021. [4] D. Alistarh, D. Grubic, J. Li, R. Tomioka, and M. Vojnovic. QSGD: Communication-Efficient SGD via Gradient Quantization and Encoding. In Advances in Neural Information Processing Systems, volume 30. Curran Associates, Inc., 2017. [5] A. T. L. Bacellar, Z. Susskind, M. Breternitz Jr, E. John, L. K. John, P. M. V. Lima, and F. M. França. Differentiable weightless neural networks. In R. Salakhutdinov, Z. Kolter, K. Heller, A. Weller, N. Oliver, J. Scarlett, and F. Berkenkamp, editors, Proceedings of the 41st International Conference on Machine Learning, volume 235 of Proceedings of Machine Learning Research, pages 2277 2295. PMLR, 21 27 Jul 2024. [6] H. Bai, W. Zhang, L. Hou, L. Shang, J. Jin, X. Jiang, Q. Liu, M. Lyu, and I. King. Binary BERT: Pushing the Limit of BERT Quantization. In C. Zong, F. Xia, W. Li, and R. Navigli, editors, Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 1: Long Papers), pages 4334 4348. Association for Computational Linguistics, 2021. [7] Y. Bai, Y.-X. Wang, and E. Liberty. Prox Quant: Quantized Neural Networks via Proximal Operators. In International Conference on Learning Representations, 2018. [8] C. Baldassi. Generalization Learning in a Perceptron with Binary Synapses. Journal of Statistical Physics, 136(5):902 916, Sep 2009. [9] C. Baldassi and A. Braunstein. A Max-Sum Algorithm for Training Discrete Neural Networks. Journal of Statistical Mechanics: Theory and Experiment, 2015(8):P08008, 2015. [10] C. Baldassi, A. Ingrosso, C. Lucibello, L. Saglietti, and R. Zecchina. Subdominant Dense Clusters Allow for Simple Learning and High Computational Performance in Neural Networks with Discrete Synapses. Physical Review Letters, 115(12):128101, 2015. [11] J. Bethge, C. Bartz, H. Yang, Y. Chen, and C. Meinel. Melius Net: An Improved Network Architecture for Binary Neural Networks. In Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision (WACV), pages 1439 1448, January 2021. [12] M. Bevilacqua, A. Roumy, C. Guillemot, and M. line Alberi Morel. Low-Complexity Single-Image Super-Resolution based on Nonnegative Neighbor Embedding. In Proceedings of the British Machine Vision Conference, pages 135.1 135.10. BMVA Press, 2012. [13] S. Bianco, R. Cadene, L. Celona, and P. Napoletano. Benchmark Analysis of Representative Deep Neural Network Architectures. IEEE Access, 6:64270 64277, 2018. [14] A. Canziani, A. Paszke, and E. Culurciello. An Analysis of Deep Neural Network Models for Practical Applications. ar Xiv preprint ar Xiv:1605.07678, 2016. [15] H. Chen, Y. Wang, C. Xu, B. Shi, C. Xu, Q. Tian, and C. Xu. Adder Net: Do We Really Need Multiplications in Deep Learning? In IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), June 2020. [16] J. Chen, Y. Gai, Z. Yao, M. W. Mahoney, and J. E. Gonzalez. A Statistical Framework for Low-bitwidth Training of Deep Neural Networks. In Advances in Neural Information Processing Systems, volume 33, pages 883 894. Curran Associates, Inc., 2020. [17] L.-C. Chen, G. Papandreou, F. Schroff, and H. Adam. Rethinking Atrous Convolution for Semantic Image Segmentation. ar Xiv preprint ar Xiv:1706.05587, 2017. [18] Y.-H. Chen, J. Emer, and V. Sze. Eyeriss: A Spatial Architecture for Energy-Efficient Dataflow for Convolutional Neural Networks. SIGARCH Computer Architecture News, 44(3):367 379, jun 2016. [19] Y.-H. Chen, T. Krishna, J. S. Emer, and V. Sze. Eyeriss: An Energy-efficient Reconfigurable Accelerator for Deep Convolutional Neural Networks. IEEE Journal of Solid-state Circuits, 52(1):127 138, 2016. [20] Y. Cheng, D. Wang, P. Zhou, and T. Zhang. Model Compression and Acceleration for Deep Neural Networks: The Principles, Progress, and Challenges. IEEE Signal Processing Magazine, 35(1):126 136, 2018. [21] B. Chmiel, R. Banner, E. Hoffer, H. B. Yaacov, and D. Soudry. Logarithmic Unbiased Quantization: Simple 4-bit Training in Deep Learning. ar Xiv:2112.10769, 2021. [22] J. Choi, P. I.-J. Chuang, Z. Wang, S. Venkataramani, V. Srinivasan, and K. Gopalakrishnan. Bridging the Accuracy Gap for 2-Bit Quantized Neural Networks (QNN). ar Xiv preprint ar Xiv:1807.06964, 2018. [23] M. Cordts, M. Omran, S. Ramos, T. Rehfeld, M. Enzweiler, R. Benenson, U. Franke, S. Roth, and B. Schiele. The Cityscapes Dataset for Semantic Urban Scene Understanding. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), June 2016. [24] M. Courbariaux, Y. Bengio, and J.-P. David. Binary Connect: Training Deep Neural Networks with Binary Weights during Propagations. In Advances in Neural Information Processing Systems, volume 28. Curran Associates, Inc., 2015. [25] C. De Sa, M. Leszczynski, J. Zhang, A. Marzoev, C. R. Aberger, K. Olukotun, and C. Ré. High-Accuracy Low-Precision Training. ar Xiv preprint ar Xiv:1803.03383, 2018. [26] J. Devlin, M.-W. Chang, K. Lee, and K. Toutanova. BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), pages 4171 4186. Association for Computational Linguistics, 2019. [27] R. Ding, T.-W. Chin, Z. Liu, and D. Marculescu. Regularizing Activation Distribution for Training Binarized Deep Networks. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), June 2019. [28] Z. Du, R. Fasthuber, T. Chen, P. Ienne, L. Li, T. Luo, X. Feng, Y. Chen, and O. Temam. Shi Dian Nao: Shifting Vision Processing Closer to the Sensor. In Proceedings of the 42nd Annual International Symposium on Computer Architecture, pages 92 104, 2015. [29] M. Everingham, L. Van Gool, C. K. I. Williams, J. Winn, and A. Zisserman. The PASCAL Visual Object Classes Challenge 2012 (VOC2012) Results. http://www.pascalnetwork.org/challenges/VOC/voc2012/workshop/index.html. [30] A. Frickenstein, M.-R. Vemparala, J. Mayr, N.-S. Nagaraja, C. Unger, F. Tombari, and W. Stechele. Binary DAD-Net: Binarized Driveable Area Detection Network for Autonomous Driving. In 2020 IEEE International Conference on Robotics and Automation (ICRA), pages 2295 2301. IEEE, 2020. [31] E. Fuchs, G. Flügge, et al. Adult Neuroplasticity: More than 40 Years of Research. Neural plasticity, 2014, 2014. [32] Y. Gao, Y. Liu, H. Zhang, Z. Li, Y. Zhu, H. Lin, and M. Yang. Estimating GPU Memory Consumption of Deep Learning Models. In Proceedings of the 28th ACM Joint Meeting on European Software Engineering Conference and Symposium on the Foundations of Software Engineering, pages 1342 1352, 2020. [33] E. García-Martín, C. F. Rodrigues, G. Riley, and H. Grahn. Estimation of Energy Consumption in Machine Learning. Journal of Parallel and Distributed Computing, 134:75 88, 2019. [34] A. Gholami, S. Kim, Z. Dong, Z. Yao, M. W. Mahoney, and K. Keutzer. A Survey of Quantization Methods for Efficient Neural Network Inference. In Low-Power Computer Vision, pages 291 326. Chapman and Hall/CRC, 2022. [35] C. Grimm and N. Verma. Neural Network Training on In-Memory-Computing Hardware With Radix-4 Gradients. IEEE Transactions on Circuits and Systems I: Regular Papers I, 69(10):4056 4068, 2022. [36] N. Guo, J. Bethge, C. Meinel, and H. Yang. Join the High Accuracy Club on Image Net with A Binary Neural Network Ticket. ar Xiv preprint ar Xiv:2211.12933, 2022. [37] S. Gupta, A. Agrawal, K. Gopalakrishnan, and P. Narayanan. Deep Learning with Limited Numerical Precision. In Proceedings of the 32nd International Conference on Machine Learning, volume 37, pages 1737 1746, Lille, France, 07 09 Jul 2015. PMLR. [38] S. Han, H. Mao, and W. J. Dally. Deep Compression: Compressing Deep Neural Networks with Pruning, Trained Quantization and Huffman Coding. In International Conference on Learning Representations, 2015. [39] K. He, X. Zhang, S. Ren, and J. Sun. Deep Residual Learning for Image Recognition. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), June 2016. [40] D. O. Hebb. The Organization of Behavior: A Neuropsychological Theory. Psychology press, 2005. [41] K. Helwegen, J. Widdicombe, L. Geiger, Z. Liu, K.-T. Cheng, and R. Nusselder. Latent Weights Do Not Exist: Rethinking Binarized Neural Network Optimization. In Advances in Neural Information Processing Systems, volume 32. Curran Associates, Inc., 2019. [42] M. Horowitz. 1.1 Computing s Energy Problem (and What We Can Do about It). In 2014 IEEE International Solid-State Circuits Conference Digest of Technical Papers (ISSCC), pages 10 14, 2014. [43] L. Hou, Q. Yao, and J. T. Kwok. Loss-aware Binarization of Deep Networks. In International Conference on Learning Representations, 2016. [44] A. G. Howard, M. Zhu, B. Chen, D. Kalenichenko, W. Wang, T. Weyand, M. Andreetto, and H. Adam. Mobile Nets: Efficient Convolutional Neural Networks for Mobile Vision Applications. ar Xiv preprint ar Xiv:1704.04861, 2017. [45] L. Hoyer, D. Dai, and L. Van Gool. DAFormer: Improving Network Architectures and Training Strategies for Domain-Adaptive Semantic Segmentation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 9924 9935, 2022. [46] J.-B. Huang, A. Singh, and N. Ahuja. Single Image Super-Resolution from Transformed Self-Exemplars. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), June 2015. [47] I. Hubara, M. Courbariaux, D. Soudry, R. El-Yaniv, and Y. Bengio. Binarized Neural Networks. In Advances in Neural Information Processing Systems, volume 29. Curran Associates, Inc., 2016. [48] I. Hubara, M. Courbariaux, D. Soudry, R. El-Yaniv, and Y. Bengio. Quantized Neural Networks: Training Neural Networks with Low Precision Weights and Activations. The Journal of Machine Learning Research, 18(1):6869 6898, 2017. [49] S. Ioffe and C. Szegedy. Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift. In Proceedings of the 32nd International Conference on Machine Learning, volume 37, pages 448 456, Lille, France, 07 09 Jul 2015. PMLR. [50] R. Ito and T. Saito. Dynamic Binary Neural Networks and Evolutionary Learning. In The 2010 International Joint Conference on Neural Networks, pages 1 5. IEEE, 2010. [51] Q. Jin, J. Ren, R. Zhuang, S. Hanumante, Z. Li, Z. Chen, Y. Wang, K. Yang, and S. Tulyakov. F8Net: Fixed-Point 8-bit Only Multiplication for Network Quantization. In International Conference on Learning Representations, 2021. [52] C. Jordan. Calculus of Finite Differences. Chelsea Publishing Company, New York, 2nd edition, 1950. [53] S. P. Karimireddy, Q. Rebjock, S. Stich, and M. Jaggi. Error Feedback Fixes Sign SGD and other Gradient Compression Schemes. In Proceedings of the 36th International Conference on Machine Learning, volume 97, pages 3252 3261. PMLR, 09 15 Jun 2019. [54] D. P. Kingma and J. Ba. Adam: A Method for Stochastic Optimization. In International Conference on Learning Representations, 2015. [55] A. Krizhevsky and G. Hinton. Learning Multiple Layers of Features from Tiny Images. Master s thesis, Department of Computer Science, University of Toronto, 2009. [56] A. Krizhevsky, I. Sutskever, and G. E. Hinton. Image Net Classification with Deep Convolutional Neural Networks. In Advances in Neural Information Processing Systems, volume 25. Curran Associates, Inc., 2012. [57] H. Kwon, P. Chatarasi, M. Pellauer, A. Parashar, V. Sarkar, and T. Krishna. Understanding Reuse, Performance, and Hardware Cost of DNN Dataflow: A Data-centric Approach. In Proceedings of the 52nd Annual IEEE/ACM International Symposium on Microarchitecture, pages 754 768, 2019. [58] I. Lavi, S. Avidan, Y. Singer, and Y. Hel-Or. Proximity Preserving Binary Code Using Signed Graph-Cut. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 34, pages 4535 4544, April 2020. [59] Y. Le Cun, Y. Bengio, and G. Hinton. Deep Learning. Nature, 521(7553):436 444, 2015. [60] C. Lee, H. Kim, E. Park, and J.-J. Kim. INSTA-BNN: Binary Neural Network with INSTAnce-aware Threshold. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), pages 17325 17334, October 2023. [61] H. Li, S. De, Z. Xu, C. Studer, H. Samet, and T. Goldstein. Training Quantized Nets: A Deeper Understanding. In Advances in Neural Information Processing Systems, volume 30. Curran Associates, Inc., 2017. [62] Z. Li and C. M. De Sa. Dimension-Free Bounds for Low-Precision Training. In Advances in Neural Information Processing Systems, volume 32. Curran Associates, Inc., 2019. [63] H. Liao, J. Tu, J. Xia, H. Liu, X. Zhou, H. Yuan, and Y. Hu. Ascend: a Scalable and Unified Architecture for Ubiquitous Deep Neural Network Computing : Industry Track Paper. In 2021 IEEE International Symposium on High-Performance Computer Architecture (HPCA), pages 789 801, 2021. [64] B. Lim, S. Son, H. Kim, S. Nah, and K. Mu Lee. Enhanced Deep Residual Networks for Single Image Super-Resolution. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition Workshops, 2017. [65] M. Lin, R. Ji, Z. Xu, B. Zhang, Y. Wang, Y. Wu, F. Huang, and C.-W. Lin. Rotated Binary Neural Network. In Advances in Neural Information Processing Systems, volume 33, pages 7474 7485. Curran Associates, Inc., 2020. [66] C. Liu, W. Ding, P. Chen, B. Zhuang, Y. Wang, Y. Zhao, B. Zhang, and Y. Han. RB-Net: Training Highly Accurate and Efficient Binary Neural Networks with Reshaped Point-wise Convolution and Balanced activation. IEEE Transactions on Circuits and Systems for Video Technology, 32(9):6414 6424, 2022. [67] Z. Liu, B. Oguz, A. Pappu, L. Xiao, S. Yih, M. Li, R. Krishnamoorthi, and Y. Mehdad. Bi T: Robustly Binarized Multi-distilled Transformer. In Advances in Neural Information Processing Systems, volume 35, pages 14303 14316. Curran Associates, Inc., 2022. [68] Z. Liu, Z. Shen, M. Savvides, and K.-T. Cheng. Re Act Net: Towards Precise Binary Neural Network with Generalized Activation Functions. In Proceedings of the European Conference on Computer Vision (ECCV), August 2020. [69] Z. Liu, B. Wu, W. Luo, X. Yang, W. Liu, and K.-T. Cheng. Bi-Real Net: Enhancing the Performance of 1-bit CNNs with Improved Representational Capability and Advanced Training Algorithm. In Proceedings of the European Conference on Computer Vision (ECCV), September 2018. [70] J. Long, E. Shelhamer, and T. Darrell. Fully Convolutional Networks for Semantic Segmentation. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), June 2015. [71] I. Loshchilov and F. Hutter. Decoupled Weight Decay Regularization. In International Conference on Learning Representations, 2017. [72] D. Martin, C. Fowlkes, D. Tal, and J. Malik. A Database of Human Segmented Natural Images and its Application to Evaluating Segmentation Algorithms and Measuring Ecological Statistics. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), July 2001. [73] B. Martinez, J. Yang, A. Bulat, and G. Tzimiropoulos. Training Binary Neural Networks with Real-tobinary Convolutions. In International Conference on Learning Representations, 2020. [74] X. Mei, K. Zhao, C. Liu, and X. Chu. Benchmarking the Memory Hierarchy of Modern GPUs. In IFIP International Conference on Network and Parallel Computing, pages 144 156. Springer, 2014. [75] G. Morse and K. O. Stanley. Simple Evolutionary Optimization Can Rival Stochastic Gradient Descent in Neural Networks. In Proceedings of the Genetic and Evolutionary Computation Conference 2016, pages 477 484, 2016. [76] V. M. Nguyen. Boolean Variation and Boolean Logic Back Propagation. ar Xiv:2311.07427, May 2024. [77] G. Nie, L. Xiao, M. Zhu, D. Chu, Y. Shen, P. Li, K. Yang, L. Du, and B. Chen. Binary Neural Networks as a General-propose Compute Paradigm for On-device Computer Vision. ar Xiv preprint ar Xiv:2202.03716, 2022. [78] A. Paszke, S. Gross, F. Massa, A. Lerer, J. Bradbury, G. Chanan, T. Killeen, Z. Lin, N. Gimelshein, L. Antiga, A. Desmaison, A. Kopf, E. Yang, Z. De Vito, M. Raison, A. Tejani, S. Chilamkurthy, B. Steiner, L. Fang, J. Bai, and S. Chintala. Py Torch: An Imperative Style, High-Performance Deep Learning Library. In Advances in Neural Information Processing Systems, volume 32. Curran Associates, Inc., 2019. [79] F. Petersen, C. Borgelt, H. Kuehne, and O. Deussen. Deep differentiable logic gate networks. In S. Koyejo, S. Mohamed, A. Agarwal, D. Belgrave, K. Cho, and A. Oh, editors, Advances in Neural Information Processing Systems, volume 35, pages 2006 2018. Curran Associates, Inc., 2022. [80] C. Philippenko and A. Dieuleveut. Bidirectional Compression in Heterogeneous Settings for Distributed or Federated Learning with Partial Participation: Tight Convergence Guarantees. ar Xiv preprint ar Xiv:2006.14591, 2020. [81] B. T. Polyak. Introduction to Optimization. Translations Series in Mathematics and Engineering. Optimization Software Inc. Publication Division, New York, 1987. [82] H. Qin, Y. Ding, M. Zhang, Q. Yan, A. Liu, Q. Dang, Z. Liu, and X. Liu. Bi BERT: Accurate Fully Binarized BERT. In International Conference on Learning Representations, 2022. [83] H. Qin, R. Gong, X. Liu, X. Bai, J. Song, and N. Sebe. Binary Neural Networks: A Survey. Pattern Recognition, 105:107281, 2020. [84] H. Qin, R. Gong, X. Liu, M. Shen, Z. Wei, F. Yu, and J. Song. Forward and Backward Information Retention for Accurate Binary Neural Networks. In IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), June 2020. [85] H. Qin, M. Zhang, Y. Ding, A. Li, Z. Cai, Z. Liu, F. Yu, and X. Liu. Bi Bench: Benchmarking and Analyzing Network Binarization. In Proceedings of the 40th International Conference on Machine Learning, volume 202 of Proceedings of Machine Learning Research, pages 28351 28388. PMLR, 23 29 Jul 2023. [86] M. Rastegari, V. Ordonez, J. Redmon, and A. Farhadi. XNOR-Net: Image Net Classification Using Binary Convolutional Neural Networks. In Proceedings of the European Conference on Computer Vision (ECCV), October 2016. [87] A. Sebastian, M. Le Gallo, R. Khaddam-Aljameh, and E. Eleftheriou. Memory Devices and Applications for in-memory Computing. Nature Nanotechnology, 15(7):529 544, 2020. [88] Y. S. Shao and D. Brooks. Energy Characterization and Instruction-Level Energy Model of Intel s Xeon Phi Processor. In International Symposium on Low Power Electronics and Design (ISLPED), pages 389 394, 2013. [89] J. Sim, S. Lee, and L.-S. Kim. An Energy-Efficient Deep Convolutional Neural Network Inference Processor With Enhanced Output Stationary Dataflow in 65-nm CMOS. IEEE Transactions on Very Large Scale Integration (VLSI) Systems, 28(1):87 100, 2019. [90] K. Simonyan and A. Zisserman. Very Deep Convolutional Networks for Large-Scale Image Recognition. In International Conference on Learning Representations, 2015. [91] D. Soudry, I. Hubara, and R. Meir. Expectation Backpropagation: Parameter-Free Training of Multilayer Neural Networks with Continuous or Discrete Weights. In Advances in Neural Information Processing Systems, volume 27. Curran Associates, Inc., 2014. [92] E. Strubell, A. Ganesh, and A. Mc Callum. Energy and Policy Considerations for Deep Learning in NLP. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, pages 3645 3650, Florence, Italy, Jul 2019. Association for Computational Linguistics. [93] X. Sun, N. Wang, C.-Y. Chen, J. Ni, A. Agrawal, X. Cui, S. Venkataramani, K. El Maghraoui, V. V. Srinivasan, and K. Gopalakrishnan. Ultra-Low Precision 4-bit Training of Deep Neural Networks. In Advances in Neural Information Processing Systems, volume 33, pages 1796 1807. Curran Associates, Inc., 2020. [94] V. Sze, Y.-H. Chen, T.-J. Yang, and J. S. Emer. Efficient Processing of Deep Neural Networks: A Tutorial and Survey. Proceedings of the IEEE, 105(12):2295 2329, 2017. [95] V. Sze, Y.-H. Chen, T.-J. Yang, and J. S. Emer. How to Evaluate Deep Neural Network Processors: Tops/w (Alone) Considered Harmful. IEEE Solid-State Circuits Magazine, 12(3):28 41, 2020. [96] M. Tan and Q. Le. Efficient Net: Rethinking Model Scaling for Convolutional Neural Networks. In K. Chaudhuri and R. Salakhutdinov, editors, Proceedings of the 36th International Conference on Machine Learning, volume 97 of Proceedings of Machine Learning Research, pages 6105 6114. PMLR, 09 15 Jun 2019. [97] R. Timofte, E. Agustsson, L. Van Gool, M.-H. Yang, L. Zhang, B. Lim, et al. NTIRE 2017 Challenge on Single Image Super-Resolution: Methods and Results. In The IEEE Conference on Computer Vision and Pattern Recognition (CVPR) Workshops, July 2017. [98] H. Touvron, A. Vedaldi, M. Douze, and H. Jegou. Fixing the Train-Test Resolution Discrepancy. In Advances in Neural Information Processing Systems, volume 32. Curran Associates, Inc., 2019. [99] Z. Tu, X. Chen, P. Ren, and Y. Wang. Ada Bin: Improving Binary Neural Networks with Adaptive Binary Sets. In Proceedings of the European Conference on Computer Vision (ECCV), October 2022. [100] A. Vaswani, N. Shazeer, N. Parmar, J. Uszkoreit, L. Jones, A. N. Gomez, L. u. Kaiser, and I. Polosukhin. Attention is All you Need. In Advances in Neural Information Processing Systems, volume 30. Curran Associates, Inc., 2017. [101] N. Verma, H. Jia, H. Valavi, Y. Tang, M. Ozatay, L.-Y. Chen, B. Zhang, and P. Deaville. In-Memory Computing: Advances and Prospects. IEEE Solid-State Circuits Magazine, 11(3):43 55, 2019. [102] A. Wang, A. Singh, J. Michael, F. Hill, O. Levy, and S. R. Bowman. GLUE: A Multi-Task Benchmark and Analysis Platform for Natural Language Understanding. In International Conference on Learning Representations, 2019. [103] E. Wang, J. J. Davis, D. Moro, P. Zielinski, J. J. Lim, C. Coelho, S. Chatterjee, P. Y. Cheung, and G. A. Constantinides. Enabling Binary Neural Network Training on the Edge. In Proceedings of the 5th International Workshop on Embedded and Mobile Deep Learning, pages 37 38, 2021. [104] J. Wangni, J. Wang, J. Liu, and T. Zhang. Gradient sparsification for communication-efficient distributed optimization. In S. Bengio, H. Wallach, H. Larochelle, K. Grauman, N. Cesa-Bianchi, and R. Garnett, editors, Advances in Neural Information Processing Systems, volume 31. Curran Associates, Inc., 2018. [105] S. Williams, A. Waterman, and D. Patterson. Roofline: An Insightful Visual Performance Model for Multicore Architectures. Communications of the ACM, 52(4):65 76, apr 2009. [106] G. Xiao, J. Lin, M. Seznec, H. Wu, J. Demouth, and S. Han. Smooth Quant: Accurate and Efficient Post Training Quantization for Large Language Models. In Proceedings of the 40th International Conference on Machine Learning, volume 202, pages 38087 38099. PMLR, 23 29 Jul 2023. [107] X. Xing, Y. Li, W. Li, W. Ding, Y. Jiang, Y. Wang, J. Shao, C. Liu, and X. Liu. Towards Accurate Binary Neural Networks via Modeling Contextual Dependencies. In Proceedings of the European Conference on Computer Vision (ECCV), October 2022. [108] T.-J. Yang, Y.-H. Chen, J. Emer, and V. Sze. A Method to Estimate the Energy Consumption of Deep Neural Networks. In 2017 51st Asilomar Conference on Signals, Systems, and Computers, pages 1916 1920, October 2017. [109] T.-J. Yang, Y.-H. Chen, and V. Sze. Designing Energy-Efficient Convolutional Neural Networks Using Energy-Aware Pruning. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), July 2017. [110] X. Yang, M. Gao, Q. Liu, J. Setter, J. Pu, A. Nayak, S. Bell, K. Cao, H. Ha, P. Raina, et al. Interstellar: Using Halide s Scheduling Language to Analyze DNN Accelerators. In Proceedings of the Twenty-Fifth International Conference on Architectural Support for Programming Languages and Operating Systems, pages 369 383, 2020. [111] Z. Yang, Y. Wang, K. Han, C. XU, C. Xu, D. Tao, and C. Xu. Searching for Low-Bit Weights in Quantized Neural Networks. In Advances in Neural Information Processing Systems, volume 33, pages 4091 4102. Curran Associates, Inc., 2020. [112] S. Yu and P.-Y. Chen. Emerging Memory Technologies: Recent Trends and Prospects. IEEE Solid-State Circuits Magazine, 8(2):43 56, 2016. [113] R. Zeyde, M. Elad, and M. Protter. On Single Image Scale-up using Sparse-Representations. In Curves and Surfaces: 7th International Conference, Avignon, France, June 24-30, 2010, Revised Selected Papers 7, pages 711 730. Springer, 2012. [114] D. Zhang, J. Yang, D. Ye, and G. Hua. LQ-Nets: Learned Quantization for Highly Accurate and Compact Deep Neural Networks. In Proceedings of the European Conference on Computer Vision (ECCV), September 2018. [115] H. Zhang, M. Cisse, Y. N. Dauphin, and D. Lopez-Paz. Mixup: Beyond Empirical Risk Minimization. In International Conference on Learning Representations, 2018. [116] R. Zhang, A. G. Wilson, and C. De Sa. Low-Precision Stochastic Gradient Langevin Dynamics. In K. Chaudhuri, S. Jegelka, L. Song, C. Szepesvari, G. Niu, and S. Sabato, editors, Proceedings of the 39th International Conference on Machine Learning, volume 162, pages 26624 26644. PMLR, 17 23 Jul 2022. [117] Y. Zhang, Z. Zhang, and L. Lew. Poke BNN: A Binary Pursuit of Lightweight Accuracy. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 12475 12485, June 2022. [118] Z. Zhang. Derivation of Backpropagation in Convolutional Neural Network (CNN). University of Tennessee, Knoxville, TN, 22:23, 2016. [119] B. Zhuang, C. Shen, M. Tan, L. Liu, and I. Reid. Structured Binary Neural Networks for Accurate Image Classification and Semantic Segmentation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), June 2019. Table of Contents A Details of the Boolean Variation Method 18 A.1 Boolean Variation Calculus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 A.2 Convergence Proof . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 B Code Sample of Core Implementation 26 C Training Regularization 28 C.1 Assumptions and Notations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 C.2 Backpropagation Scaling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 C.3 Back Propagation Through Boolean Activation Function . . . . . . . . . . . . . . . 31 D Experimental Details 31 D.1 Image Classification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 D.2 Image Super-resolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 D.3 Semantic Segmentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 D.4 Boolean BERT Fine-tuning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 E Energy Estimation 40 E.1 Hardware Specification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 E.2 Compute Energy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 E.3 Memory Energy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 F Broader Impacts 44 A Details of the Boolean Variation Method A.1 Boolean Variation Calculus This section provides supplementary details of the Boolean Variation method, a sole development can be found in [76]. With reference to Example 3.10, Table 8 gives the variation truth table of f(x) = xor(a, x), for a, x B. Table 8: Variation truth table of f(x) = xor(a, x), a, x B. a x x δ(x x) f(a, x) f(a, x) δf(x x) f (x) T T F F F T T F T F T T T F F F F T F F T F F T F F T T F T T T We now proceed to the proof of Theorem 3.12. Definition A.1 (Type conversion). Define: T, if x > 0, 0, if x = 0, F, if x < 0. (13) +1, if a = T, 0, if a = 0, 1, if a = F. (14) p projects a numeric type in logic, and e embeds a logic type in numeric. The following properties are straightforward: Proposition A.2. The following properties hold: 1. x, y N: p(xy) = xnor(p(x), p(y)). 2. a, b L: e(xnor(a, b)) = e(a) e(b). 3. x, y N: x = y |x| = |y| and p(x) = p(y). In particular, property Proposition A.2(2) implies that by the embedding map e( ), we have: ({T, F}, xor) = ({ 1}, ), (15) ({T, F}, xnor) = ({ 1}, ), (16) where = and stand for isomorphic relation, and the real multiplication, resp. A consequence is that by e( ), a computing sequence of pointwise XOR/XNOR, counting, and majority vote is equivalent to a sequence of pointwise multiplications and accumulation performed on the embedded data. This property will be used in Appendices A.2 and C for studying Boolean method using some results from BNNs literature and real analysis. Proposition A.3. The following properties hold: 1. a L, x N: xnor(a, x) = e(a)x. 2. x, y N: xnor(x, y) = xy. 3. x {L, N}, y, z N: xnor(x, y + z) = xnor(x, y) + xnor(x, z). 4. x {L, N}, y, λ N: xnor(x, λy) = λxnor(x, y). 5. x {L, N}, y N: xor(x, y) = xnor(x, y). Proof. The proof follows definitions 3.5 and A.1. Following Definition 3.1 we have t M, xnor(T, t) = t, xnor(F, t) = t, and xnor(0, t) = 0. Put v = xnor(a, x). We have |v| = |x| and p(v) = xnor(a, p(x)). Hence, a = 0 p(v) = 0 v = 0; a = T p(v) = p(x) v = x; a = F p(v) = p(x) v = x. Hence (1). The result is trivial if x = 0 or y = 0. For x, y = 0, put v = xnor(x, y), we have |v| = |x||y| and p(v) = xnor(p(x), p(y)). According to Definition A.1, if sign(x) = sign(y), we have p(v) = T v = |x||y| = xy. Otherwise, i.e., sign(x) = sign(y), p(v) = F v = |x||y| = xy. Hence (2). (3) and (4) follow (1) for x L and follow (2) for x N. For (5), write u = xor(x, y) and v = xnor(x, y), we have |u| = |v| and p(u) = xor(p(x), p(y)) = xnor(p(x), p(y)) = p(v). Thus, sign(u) = sign(v) u = v. Proposition A.4. For f, g F(B, B), x, y B the following properties hold: 1. δf(x y) = xnor(δ(x y), f (x)). 2. ( f) (x) = f (x). 3. (g f) (x) = xnor(g (f(x)), f (x)). Proof. The proof is by definition: 1. x, y B, there are two cases. If y = x, then the result is trivial. Otherwise, i.e., y = x, by definition we have: f (x) = xnor(δ(x x), δf(x x)) δf(x x) = xnor(δ(x x), f (x)). Hence the result. 2. x, y B, it is easy to verify by truth table that δ( f(x y)) = δf(x y). Hence, by definition, ( f) (x) = xnor(δ(x x), δ( f(x x))) = xnor(δ(x x), δf(x x)) = xnor(δ(x x), δf(x x)) 3. Using definition, property (i), and associativity of xnor, x B we have: (g f) (x) = xnor(δ(x x), δg(f(x) f( x))) = xnor(δ(x x), xnor(δf(x x), g (f(x)))) = xnor(g (f(x)), xnor(δ(x x), δf(x x))) = xnor(g (f(x)), f (x)). Proposition A.5. For f F(B, N), the following properties hold: 1. x, y B: δf(x y) = xnor(δ(x y), f (x)). 2. x B, α N: (αf) (x) = αf (x). 3. x B, g F(B, N): (f + g) (x) = f (x) + g (x). Proof. The proof is as follows: 1. For x, y B. Firstly, the result is trivial if y = x. For y = x, i.e., y = x, by definition: f (x) = xnor(δ(x x), δf(x x)). Hence, |δf(x x)| = |f (x)| since |δ(x x)| = 1, and p(f (x)) = xnor(δ(x x), p(δf(x x))) p(δf(x x)) = xnor(δ(x x), p(f (x))), where p( ) is the logic projector Eq. 13. Thus, δf(x x) = xnor(δ(x x), f (x)). Hence the result. 2. Firstly x, y B, we have δ(αf(x y)) = αf(y) αf(x) = αδf(x y). Hence, by definition, (αf) (x) = xnor(δ(x x), δ(αf(x x))) = xnor(δ(x x), αδf(x x)) = α xnor(δ(x x), δf(x x)), due to Proposition A.3(4) 3. For f, g F(B, N), (f + g) (x) = xnor(δ(x x), δ(f + g)(x x)) = xnor(δ(x x), δf(x x) + δg(x x)) ( ) = xnor(δ(x x), δf(x x)) + xnor(δ(x x), δg(x x)), = f (x) + g (x), where ( ) is due to Proposition A.3(3). Proposition A.6 (Composition rules). The following properties hold: 1. For B f B g D: (g f) (x) = xnor(g (f(x)), f (x)), x B. 2. For B f Z g D, x B, if |f (x)| 1 and g (f(x)) = g (f(x) 1), then: (g f) (x) = xnor(g (f(x)), f (x)). Proof. The proof is as follows. 1. The case of B f B g B is obtained from Proposition A.4(3). For B f B g N, by using Proposition A.5(1), the proof is similar to that of Proposition A.4(3). 2. By definition, we have (g f) (x) = xnor(δ(x x), δg(f(x) f( x))). (17) Using property (1) of Proposition A.5, we have: f( x) = f(x) + δf(x x) = f(x) + xnor(δ(x x), f (x)). (18) Applying Eq. 18 back to Eq. 17, the result is trivial if f (x) = 0. The remaining case is |f (x)| = 1 for which we have xnor(δ(x x), f (x)) = 1. First, for xnor(δ(x x), f (x)) = 1, we have: δg(f(x) f( x)) = δg(f(x) f(x) + 1) = xnor(g (f(x)), 1) = xnor(g (f(x)), xnor(δ(x x), f (x))). (19) Substitute Eq. 19 back to Eq. 17, we obtain: (g f) (x) = xnor(δ(x x), δg(f(x) f( x))) = xnor(δ(x x), xnor(g (f(x)), xnor(δ(x x), f (x)))) = xnor(g (f(x)), f (x)), where that last equality is by the associativity of xnor and that xnor(x, x) = T for x B. Similarly, for xnor(δ(x x), f (x)) = 1, we have: δg(f(x) f( x)) = δg(f(x) f(x) 1) = g (f(x) 1) = xnor(g (f(x) 1), 1) = xnor(g (f(x) 1), xnor(δ(x x), f (x))). (20) Substitute Eq. 20 back to Eq. 17 and use the assumption that g (f(x)) = g (f(x) 1), we have: (g f) (x) = xnor(δ(x x), δg(f(x) f( x))) = xnor(δ(x x), xnor(g (f(x) 1), xnor(δ(x x), f (x)))) = xnor(g (f(x)), f (x)). Hence the result. The results of Theorem 3.12 are from Propositions A.4 to A.6. A.2 Convergence Proof To the best of our knowledge, in the quantized neural network literature and in particular BNN, one can only prove the convergence up to an irreducible error floor [61]. This idea has been extended to SVRG [25], and recently to SGLD in [116], which is also up to an error limit. In this section we provide complexity bounds for Boolean Logic in a smooth non-convex environment. We introduce an abstraction to model its optimization process and prove its convergence. A.2.1 Continuous Abstraction Boolean optimizer is discrete, proving its convergence directly is a hard problem. The idea is to find a continuous equivalence so that some proof techniques existing from the BNN and quantized neural networks literature can be employed. We also abstract the logic optimization rules as compressor Q0(), Q1(), and define gradient accumulator at as at+1 = at + ϕ(qt). When η is constant, we recover the definition (10) and obtain mt = ηat. Our analysis is based on the following standard non-convex assumptions on f: A. 1. Uniform Lower Bound: There exists f R s.t. f(w) f , w Rd. A. 2. Smooth Derivatives: The gradient f(w) is L-Lipschitz continuous for some L > 0, i.e., w, v Rd: f(w) f(v) L w v . A. 3. Bounded Variance: The variance of the stochastic gradients is bounded by some σ2 > 0, i.e., w Rd: E h f(w) i = f(w) and E h f(w) 2i σ2. A. 4. Compressor: There exists γ < 1 s.t. w, v Rd, Q1(v, w) v 2 γ v 2. A. 5. Bounded Accumulator: There exists κ R + s.t. t and i [d], we have |at|i κ. A. 6. Stochastic Flipping Rule: For all w Rd, we have E[Q0(w)|w] = w. In existing frameworks, quantity f( ) denotes the stochastic gradient computed on a random minibatch of data. Boolean framework does not have the notion of gradient, it however has an optimization signal (i.e., ϕ(q) or its accumulator mt (10)) that plays the same role as f( ). Therefore, these two notions, i.e., continuous gradient and Boolean optimization signal, can be encompassed into a generalized notion. That is the root to the following continuous relaxation in which f( ) standards for the optimization signal computed on a random mini-batch of data. Within this continuous relaxation framework, A. 6 expresses our assumption that the flipping rule is stochastic and unbiased. Note that this assumption is standard in the literature related to (stochastic) quantization, see e.g., [4, 81, 104]. For reference, the original Boolean optimizer as formulated in 3 is summarized in Algorithm 2 in which flip(wt, mt+1) flips weight and reset(wt, mt+1) resets its accumulator when the flip condition is triggered. Algorithm 2: Boolean optimizer 1 mt+1 βtmt + ηϕ(qt) ; 2 wt+1 flip(wt, mt+1); 3 mt+1 reset(wt, mt+1); Algorithm 3: Equivalent formulation of Boolean optimizer Data: Q0, Q1 quantizer 1 mt η f(wt) + et; 2 t Q1(mt, wt); 3 wt+1 Q0(wt t); 4 et+1 mt t; Algorithm 3 describes an equivalent formulation of Boolean optimizer. Therein, Q0, Q1 are quantizers which are specified in the following. Note that EF-SIGNSGD (SIGNSGD with Error-Feedback) algorithm from [53] is a particular case of this formulation with Q0() = Identity() and Q1() = sign(). For Boolean Logic abstraction, they are given by: Q1(mt, wt) = wt(Re Lu(wtmt 1) + 1 2 sign(wtmt 1) + 1 2), Q0(wt) = sign(wt). (21) The combination of Q1 and Q0 is crucial to take into account the reset property of the accumulator mt. Indeed in practice, t := Q1(mt, wt) is always equal to 0 except when |mt| > 1 and sign(mt) = sign(wt) (i.e., when the flipping rule is applied). As wt has only values in { 1}, Q0 acts as identity function, except when t is non-zero (i.e., when the flipping rule is applied). With the choices (21), we can identify flip(wt, mt) = Q0(wt Q1(mt, wt)). We do not have closed-form formula for reset(wt, mt+1) from Algorithm 2, but the residual errors et play this role. Indeed, et+1 = mt except when t is non-zero (i.e., when the flipping rule is applied and et+1 is equal to 0). The main difficulty in the analysis comes from the parameters quantization Q0(). Indeed, we can follow the derivations in Appendix B.3 from [53] to bound the error term E et 2 , but we also have additional terms coming from the quantity: ht = Q0(wt Q1(mt, wt)) (wt Q1(mt, wt)). (22) As a consequence, assumptions 1 to 6 enable us to obtain E[ht] = 0 and to bound the variance of ht. Remark A.7. Assumptions 1 to 3 are standard. Assumptions 4 to 6 are non-classic but dedicated to Boolean Logic strategy. A. 4 is equivalent to assuming Boolean Logic optimization presents at least one flip at every iteration t. A. 4 is classic in the literature of compressed SGD [53, 4, 80]. Moreover, A. 5 and A. 6 are not restrictive, but algorithmic choices. For example, rounding (Q0 function) can be stochastic based on the value of the accumulator mt. Similar to STE clipping strategy, the accumulator can be clipped to some pre-defined value κ before applying the flipping rule to verify A. 5. Remark A.8. Our proof assumes that the step size η is constant over iterations. But in practice, we gently decrease the value of η at some time steps. Our proof can be adapted to this setting by defining a gradient accumulator at such that at+1 = at + ϕ(qt). When η is constant we recover the definition (10) and we obtain mt = ηat. In the proposed algorithm, gradients are computed on binary weight wt and accumulated in at. Then, one applies the flipping rule on the quantity wt = ηat ( wt = mt when η is constant), and one (may) reset the accumulator at. We start by stating a key lemma which shows that the residual errors et maintained in Algorithm 3 do not accumulate too much. Lemma A.9. Under A. 3 and A. 4, the error can be bounded as E et 2 2γ (1 γ)2 η2σ2. Proof. We start by using the definition of the error sequence: et+1 2 = Q1(mt, wt) mt 2. Next we make use of A. 4: et+1 2 γ mt 2. We develop the accumulator update: et+1 2 γ et + η f(wt) 2. We thus have a recurrence relation on the bound of et. Using Young s inequality, we have that for any β > 0, et+1 2 γ(1 + β) et 2 + γ(1 + 1 β )η2 f(wt) 2. Rolling the recursion over and using A. 3 we obtain: E et+1 2 γ(1 + β)E et 2 + γ(1 + 1 β )η2E h f(wt) 2i γ(1 + β)E et 2 + γ(1 + 1 r (γ(1 + β))rγ(1 + 1 1 γ(1 + β)η2σ2. Take β = 1 γ 2γ and plug it in the above bounds gives: E et+1 2 2γ (1 γ)2 η2σ2. Then, the next Lemma allows us to bound the averaged norm-squared of the distance between the Boolean weight and wt Q1(mt, wt). We make use of the previously defined quantity ht (22) and have: Lemma A.10. Under assumptions A. 5 and A. 6: E ht 2 ηdκ. Proof. Let consider a coordinate i [d]. Q0|i as 1 or +1 for value with some probability pi,t. For the ease of presentation, we will drop the subscript i. Denote ut := wt Q1(mt, wt). Hence, ht can take value (1 ut) with some probability pt and ( 1 ut) with probability 1 pt. Assumption A. 6 yields 2pt 1 = ut. Therefore, we can compute the variance of ht as follows: i 1 + (wt Q1(mt, wt))2 2Q0(wt Q1(mt, wt)(wt Q1(mt, wt) i ((1 ut)2pt + ( 1 ut)2(1 pt)) i (1 u2 t). The definition of ut leads to 1 u2 t = 1 (1 + Q1(mt, wt)2 2wt Q1(mt, wt)) = Q1(mt, wt)(2wt Q1(mt, wt)). When mt < 1, we directly have Q1(mt, wt)(2wt Q1(mt, wt)) = 0 ηκ. When mt 1, we apply the definition of Q1 to obtain: Q1(mt, wt)(2wt Q1(mt, wt)) mt(2 mt) ηκ. Therefore, we can apply this result to every coordinate, and conclude that: E ht 2 ηdκ. (23) A.2.2 Proof of Theorem 3.17 We now can proceed to the proof of Theorem 3.17. Proof. Consider the virtual sequence xt = wt et. We have: xt+1 = Q0(wt t) (mt t) = (Q0(wt t) + t et) η f(wt). Considering the expectation with respect to the random variable Q0 and the gradient noise, we have: E[xt+1|wt] = xt η f(wt). We consider Et[ ] the expectation with respect to every random process know up to time t. We apply the L-smoothness assumption A. 2, and assumptions A. 3, A. 6 to obtain: Et[f(xt+1) f(xt)] η f(xt), f(wt) + L 2 Et h (Q0(wt t) + t) η f(wt) wt 2i . We now reuse ht from (22) and simplify the above: Et[f(xt+1) f(xt)] η f(xt), f(wt) + L 2 Et h ht η f(wt) 2i η f(xt) f(wt) + f(wt), f(wt) + L 2 Et h ht η f(wt) 2i . Using Young s inequality, we have that for any β > 0, Et[f(xt+1) f(xt)] η f(xt) f(wt) + f(wt), f(wt) 2 (1 + β)Et ht 2 + L Making use again of smoothness and Young s inequality we have: Et[f(xt+1) f(xt)] η f(wt) 2 η f(xt) f(wt), f(wt) 2 (1 + β)Et ht 2 + L η f(wt) 2 + ηρ 2 f(wt) 2 + η 2ρ f(xt) f(wt) 2 2 (1 + β)Et ht 2 + L η f(wt) 2 + ηρ 2 f(wt) 2 + ηL2 2ρ xt wt 2 | {z } et 2 2 (1 + β)Et ht 2 + L Under the law of total expectation, we make use of Lemma A.9 and Lemma A.10 to obtain: E[f(xt+1)] E[f(xt)] η(1 ρ 2)E f(wt) 2 + ηL2 2ρ 4γ (1 γ)2 η2σ2 8 η(1 + β)dκ + L Rearranging the terms and averaging over t gives for ρ < 2 (we can choose for instance ρ = β = 1): t=0 f(wt) 2 2(f(w0) f ) η(T + 1) + 2Lσ2η + 4L2σ2 γ (1 γ)2 η2 + L The bound in Theorem 3.17 contains 4 terms. The first term is standard for a general non-convex target and expresses how initialization affects convergence. The second and third terms depend on the fluctuation of the minibatch gradients. Another important aspect of the rate determined by Theorem 3.17 is its dependence on the quantization error. Note that there is an error bound of L 2 dκ that remains independent of the number of update iterations. The error bound is the cost of using discrete weights as part of the optimization algorithm. Previous work with quantized models also includes error bounds [61, 62]. B Code Sample of Core Implementation In this section we provide example codes in Python of a Boolean linear layer that employs xor logic kernel. This implementation is in particular based on Py Torch [78]. The class of Boolean linear layer is defined in Algorithm 4; and its backpropagation mechanism, overwritten from autograd, is shown in Algorithm 5. Here, we consider both cases of the received backpropagation signal Z as described in Fig. 2, which are either Boolean (see Algorithm 6) or real-valued (see Algorithm 7). An example code of the Boolean optimizer is provided in Algorithm 8. Notice that our custom XORLinear layer can be flexibly combined with any FP Py Torch modules to define a model. The parameters of this layer are optimized by the Boolean Optimizer, whereas those of FP layers are optimized by a common FP optimizer like Adam [54]. Algorithm 4: Python code of XOR linear layer 1 import torch 2 3 from torch import Tensor , nn , autograd 4 from typing import Any , List , Optional , Callable 5 6 7 class XORLinear(nn.Linear): 8 9 def __init__(self , in_features : int , out_features : int , bool_bprop : bool , ** kwargs): 10 super(XORLinear , self).__init__(in_features , out_features , ** kwargs) 11 self.bool_bprop = bool_bprop 12 13 def reset_parameters (self): 14 self.weight = nn.Parameter(torch.randint (0, 2, self.weight.shape)) 15 16 if self.bias is not None: 17 self.bias = nn.Parameter(torch.randint (0, 2, (self.out_features ,))) 18 19 def forward(self , X): 20 return XORFunction .apply(X, self.weight , self.bias , self.bool_bprop) Algorithm 5: Python code of the backpropagation logic of XOR linear layer 1 class XORFunction(autograd.Function): 2 3 @staticmethod 4 def forward(ctx , X, W, B, bool_bprop : bool): 5 ctx. save_for_backward (X,W,B) 6 ctx.bool_bprop = bool_bprop 7 8 # Elementwise XOR logic 9 S = torch. logical_xor(X[:,None ,:], W[None ,: ,:]) 10 11 # Sum over the input dimension 12 S = S.sum(dim =2) + B 13 14 # 0-centered for use with Batch Norm when preferred 15 S = S - W.shape [1]/2 16 17 return S 18 19 @staticmethod 20 def backward(ctx , Z): 21 if ctx.bool_bprop: 22 G_X , G_W , G_B = backward_bool (ctx , Z) 23 else: 24 G_X , G_W , G_B = backward_real (ctx , Z) 25 26 return G_X , G_W , G_B , None Algorithm 6: Backpropagation logic with Boolean received backpropagation 1 def backward_bool (ctx , Z): 2 """ 3 Variation of input: 4 - delta(xor(x,w))/delta(x) = neg w 5 - delta(Loss)/delta(x) = xnor(z,neg w) = xor(z,w) 6 Variation of weights: 7 - delta(xor(x,w))/delta(w) = neg x 8 - delta(Loss)/delta(x) = xnor(z,neg x) = xor(z,x) 9 Variation of bias: 10 - bias = xnor(bias ,True) ==> Variation of bias is driven in 11 the same basis as that of weight with xnor logic and input True. 12 Aggregation : 13 - Count the number of TRUEs = sum over the Boolean data 14 - Aggr = TRUEs - FALSEs = TRUEs - (TOT - TRUEs) = 2TRUES - TOT 15 where TOT is the size of the aggregated dimension 16 """ 17 X, W, B = ctx. saved_tensors 18 19 # Boolean variation of input 20 G_X = torch. logical_xor(Z[:,:, None], W[None ,: ,:]) 21 22 # Aggregate over the out_features dimension 23 G_X = 2 * G_X.sum(dim =1) - W.shape [0] 24 25 # Boolean variation of weights 26 G_W = torch. logical_xor(Z[:,:, None], X[:,None ,:]) 27 28 # Aggregate over the batch dimension 29 G_W = 2 * G_W.sum(dim =0) - X.shape [0] 30 31 # Boolean variation of bias 32 if B is not None: 33 # Aggregate over the batch dimension 34 G_B = 2 * Z.sum(dim =0) - Z.shape [0] 35 36 # Return 37 return G_X , G_W , G_B Algorithm 7: Backpropagation logic with real received backpropagation 1 def backward_real (ctx , Z): 2 X, W, B = ctx. saved_tensors 3 4 """ 5 Boolean variation of input processed using torch avoiding loop: 6 -> xor(Z: Real , W: Boolean) = -Z * emb(W) 7 -> emb(W): T->1, F->-1 => emb(W) = 2W-1 8 => delta(Loss)/delta(X) = Z*(1 -2W) """ 9 G_X = Z.mm(1 -2*W) 10 11 """ 12 Boolean variation of weights processed using torch avoiding loop: 13 -> xor(Z: Real , X: Boolean) = -Z * emb(X) 14 -> emb(X): T->1, F->-1 => emb(X) = 2X-1 15 => delta(Loss)/delta(W) = Z T * (1-2X) """ 16 G_W = Z.t().mm(1 -2*X) 17 18 """ Boolean variation of bias """ 19 if B is not None: 20 G_B = Z.sum(dim =0) 21 22 # Return 23 return G_X , G_W , G_B Algorithm 8: Python code of Boolean optimizer 1 class Boolean Optimizer (torch.optim.Optimizer): 2 3 def __init__(self , params , lr: float): 4 super(Boolean Optimizer , self).__init__(params , dict(lr=lr)) 5 for param_group in self. param_groups : 6 param_group [ accums ] = [torch.zeros_like(p.data) for p in param_group [ params ]] 7 param_group [ ratios ] = [0 for p in param_group [ params ]] 8 self._nb_flips = 0 9 10 @property 11 def nb_flips(self): 12 n = self._nb_flips 13 self._nb_flips = 0 14 return n 15 16 def step(self): 17 for param_group in self. param_groups : 18 for idx , p in enumerate( param_group [ params ]): 19 self.update(p, param_group , idx) 20 21 def update(self , param: Tensor , param_group : dict , idx: int): 22 accum = param_group [ ratios ][ idx] * param_group [ accums ][ idx] + param_group [ lr ] * param.grad.data 23 param_group [ accums ][ idx] = accum 24 param_to_flip = accum * (2* param.data -1) >= 1 25 param.data[ param_to_flip ] = torch. logical_not (param.data[ param_to_flip ]) 26 param_group [ accums ][ idx ][ param_to_flip ] = 0. 27 param_group [ ratios ][ idx] = 1 - param_to_flip .float ().mean () 28 self._nb_flips += float( param_to_flip .float ().sum ()) C Training Regularization C.1 Assumptions and Notations We use capital letters to denote tensors. So, W l, Xl, Sl, and Zl denote weight, input, pre-activation, and received backpropagation tensors of a layer l. We also use Proposition A.2 and the discussion therein for studying Boolean logic in its embedding binary domain. It follows that in this section B denotes the binary set { 1}. Let N(µ, σ2) denote the Gaussian distribution of mean µ and variance σ2, and B(p) denote Bernoulli distribution on B with p [0, 1]. Note that for X B(p), if E[X] = 0, then E X2 = 1. We assume that the backpropagation signal to each layer follows a Gaussian distribution. In addition, according to experimental evidence, cf. Fig. 4, we assume that their mean µ can be neglected w.r.t. their variance σ2. It follows that: Zl N(µ, σ2), with µ σ. (24) We also assume that signals are mutually independent, i.e., computations are going to be made on random vectors, matrices and tensors, and it is assumed that the coefficients of these vectors, matrices and tensors are mutually independent. We assume that forward signals, backpropagation signals, and weights (and biases) of the layers involved are independent. Consider a Boolean linear layer of input size n and output size m, denote: Boolean weights: W l Bm n; Boolean inputs: Xl Bn; Pre-activation and Outputs: Sl [| n, n|]m, Xl+1 Bm; Downstream backpropagated signal: Zl Rm; Upstream backpropagated signal: Zl 1 Rn. In the forward pass, we have: Sl = xor(W l, Xl), and Xl+1 = maj(Sl). With the following notations: W l = (W l ij)i