    On Exact Bit-level Reversible Transformers Without Changing Architecture


                                  Guoqiang Zhang 1 J.P. Lewis 2 W. Bastiaan Kleijn 3


                         Abstract                                    1. Introduction
                                                                     An active research trend in deep learning is to scale up
     In this work we present the BDIA-transformer,                   the size of both the deep neural networks (DNNs) and the
     which is an exact bit-level reversible transformer              training data, with the aim of obtaining universal machine-
     that uses an unchanged standard architecture for                learning models that are capable of accomplishing vari-
     inference. The basic idea is to first treat each                ous tasks. Examples are large language models (LLMs)
     transformer block as the Euler integration approx-              such as GPT-4 (Achiam et al., 2023) and Llama 2 (Tou-
     imation for solving an ordinary differential equa-              vron et al., 2023), which can, for example, have informative
     tion (ODE) and then incorporate the technique of                and friendly conversations with humans, solve mathemat-
     bidirectional integration approximation (BDIA)                  ical problems, and produce high-quality source codes for
     (originally designed for diffusion inversion) into              programming tasks. A major bottleneck for training those
     the neural architecture, together with activation               large DNNs is that they often require large on-chip memory
     quantization to make it exactly bit-level reversible.           and large inter-chip communication bandwidth across many
     In the training process, we let a hyper-parameter               chips to accommodate both the DNN model and the interme-
     γ in BDIA-transformer randomly take one of the                  diate activations of the input data-batch in back-propagation
     two values {0.5, −0.5} per training sample per                  (Gholami et al., 2024), which is referred to as memory wall
     transformer block for averaging every two con-                  in the literature.
     secutive integration approximations. As a result,               One promising technique to alleviate the issue of memory
     BDIA-transformer can be viewed as training an                   wall is to design and train reversible DNNs (Dinh et al.,
     ensemble of ODE solvers parameterized by a set                  2014; 2016; Behrmann et al., 2019; Mangalam et al., 2023).
     of binary random variables, which regularizes the               By doing so, the intermediate activations in the forward
     model and results in improved validation accu-                  pass do not have to be stored in the memory to allow for
     racy. Lightweight side information is required to               back-propagation. Instead, they can be recomputed on-
     be stored in the forward process to account for                 the-fly in the backward pass by exploiting the reversibility
     binary quantization loss to enable exact bit-level              of the DNN, thus saving memory consumption by a large
     reversibility. In the inference procedure, the ex-              margin for deep DNNs. The procedure essentially reduces
     pectation E(γ) = 0 is taken to make the resulting               memory consumption at the cost of a reasonable amount of
     architecture identical to transformer up to acti-               additional computation. The reduction in memory also has
     vation quantization. Our experiments in natural                 the potential to improve throughput by increasing the batch
     language generation, image classification, and lan-             size.
     guage translation show that BDIA-transformers
     outperform their conventional counterparts signif-              Early reversible DNNs, such as NICE (Dinh et al., 2014), the
     icantly in terms of validation performance while                methods of (Rezende & Mohamed, 2015), Real NVP (Dinh
     also requiring considerably less training memory.               et al., 2016), and Inverse Autoregressive Flow (Kingma
     Thanks to the regularizing effect of the ensemble,              et al., 2016) are differentiable transformations that were
     the BDIA-transformer is particularly suitable for               aimed at facilitating generative modeling. For an overview
     fine-tuning with limited data. Source-code can be               of such early normalizing flows see (Kobyzev et al., 2020).
     found via this link.                                            Inspired by these works, a range of reversible residual
    1
                                                                     models were proposed subsequently, including RevNet
      Department of Computer Science, University of Exeter, UK
2
 NVDIA, USA 3 School of Engineering and Computer Science,
                                                                     (Gomez et al., 2017), Glow (Kingma & Dhariwal, 2018),
Victoria University of Wellington, New Zealand. Correspondence       i-RevNet (Jacobsen et al., 2018), i-ResNet (Behrmann et al.,
to: Guoqiang Zhang <guoqiang.x.zhang@gmail.com>.                     2019), layerwise inversion (Hascoet et al., 2019), Fourier-
                                                                     transformation based CNN inversion (Finzi et al., 2019),
Proceedings of the 42 nd International Conference on Machine         and Mintnet (Song et al., 2019). Another line of research
Learning, Vancouver, Canada. PMLR 267, 2025. Copyright 2025
by the author(s).
                                                                     enforces reversibility in deep learning from the perspec-

                                                                 1
                          On Exact Bit-level Reversible Transformers Without Changing Architecture

tive of ordinary differential equations (ODEs), which in-              mance over that of the corresponding baseline transformers
cludes FFJORD (Grathwohl et al., 2018), leapfrog networks              and simultaneously reduces training memory significantly.
(Chang et al., 2017), momentum residual networks (Sander               The improved performance results from the model regu-
et al., 2021), and neural ODE inversion (Stam, 2022).                  larization imposed by a set of γ random variables. Our
                                                                       empirical study also indicates that RevViT from (Mangalam
Recently, the research on reversibility has moved to other
                                                                       et al., 2023) produces either inferior or comparable valida-
types of neural networks. The authors in (Mangalam et al.,
                                                                       tion performance to that of its original counterparts.
2023; Zhu & Mangalam, 2023) proposed reversible vision
transformers (referred to as RevViT) due to the popular-               2. Related Works
ity of LLMs. (Wallace et al., 2023) utilized a reversible              In recent years, various quantization strategies (Yang et al.,
diffusion sampling method for the task of diffusion based              2019; Wu et al., 2018; Wang et al., 2018) have been pro-
image editing. To our best knowledge, all the above existing           posed in the training and/or inference processes of DNN
reversible DNNs either require non-standard architectures              models on low-precision devices. For instance, the work
or are constructed by modifying the original DNN architec-             (Wu et al., 2018) successfully performed quantization on
tures considerably to enable reversibility.                            DNN weights, activations, gradients and errors in the train-
In this paper, we propose BDIA-transformer, a new type of              ing and inference processes and obtained promising results.
reversible transformer that uses an unchanged, standard ar-            The recent work (Ma, 2024) demonstrated that LLMs with
chitecture for the inference procedure. It is based on the bidi-       a quantization of 1.58 bits per model parameter exhibit com-
rectional integration approximation (BDIA), which was re-              parable performance to non-quantized models. In summary,
cently proposed in (Zhang et al., 2023a) to enable diffusion           it was found that the validation performance of DNN models
inversion for round-trip image editing. To be able to incor-           that incorporate those quantization operations is comparable
porate BDIA into transformers for online back-propagation,             with that of conventional DNN models. In our work, we
we follow the common practice of treating each transformer             only need to apply activation quantization to enable exact
block as an Euler integration approximation for solving an             bit-level reversibility in training BDIA-transformers.
ordinary differential equation (ODE).                                  We note that in general, model quantization and design of
We make two main contributions in this work. Firstly, we               reversible DNN models are two complimentary strategies
propose BDIA-transformers by introducing a random hyper-               for reducing memory consumption in the training process,
parameter γ ∈ {−0.5, 0.5} per transformer block per train-             where the first strategy operates on the model parameters
ing sample to regularize the DNN models for improvement                and the second one operates on the activation values. With
of validation performance. Each γ parameter intends to aver-           the development of new model quantization methods such
age every two consecutive integration approximations. The              as (Ma, 2024), advancing the research frontier of reversible
training procedure becomes training of an ensemble of ODE              DNN models has become of great interest.
solvers parameterized by a set of binary random variables.             In addition to reversible DNNs, other memory-saving tech-
In the inference procedure, the expectation E[γ] = 0 is uti-           niques have been proposed in recent years, such as gradient
lized, which reduces BDIA-transformers to conventional                 checkpointing (Feng & Huang, 2021), and activation of-
transformers. As a result, our method is a good candidate              floading (Wu et al., 2024). At least in principle, the above
for fine-tuning existing transformer-based models such as              techniques can be combined with the BDIA algorithm to
LLMs.1                                                                 save training memory for a broad class of residual-type
Secondly, we perform activation quantization to allow for              neural architectures.
exact bit-level reversibility of BDIA-transformers. Note that
the special setup of the γ values in the subset {−0.5, 0.5}            3. Preliminary
when performing activation quantization leads to a 1 bit
information loss per activation value per transformer block.           Neural networks as ODEs: (Chen et al., 2018) highlighted
Therefore, lightweight side information per transformer                the interpretation that passing a hidden state across layers
block needs to be stored during training to recover this               that add a correction to that state can be viewed as Euler inte-
1 bit information loss. Despite this, the overall memory use           gration. While that paper identified architectures including
is significantly reduced.                                              residual nets and normalizing flows as following this pat-
                                                                       tern, it is equally true of diffusion models and transformers.
Experimental results for natural language generation (NLG),            This interpretation emphasizes the importance of consider-
image classification, and language translation show that the           ing more accurate integration schemes (Karras et al., 2022).
BDIA technique significantly improves the validation perfor-           The need for improved integration is particularly apparent
   1
   See Subsection 5.1 for full fine-tuning and Appendix E for          in round-trip image editing in diffusion models, where sig-
LoRA-based fine-tuning.                                                nificant integration error will result in unintended visible


                                                                   2
                             On Exact Bit-level Reversible Transformers Without Changing Architecture

alterations to the image.                                                inversion for round-trip image editing. By reformulating
                                                                         (3), z i−1 can be easily computed in terms of (z i , z i+1 ). We
Diffusion sampling via solving ODE: Recently, the work
                                                                         note that due to the nature of the floating-point datatype,
(Zhang et al., 2023a) proposed the BDIA technique to enable
                                                                         there might be error accumulation in round-trip image re-
diffusion inversion for effective round-trip image editing.
                                                                         construction, where the corresponding diffusion states in the
From a high level point of view, BDIA can be viewed as a
                                                                         forward and reverse process are not identical. In practice,
time-reversible ODE solver. Given an initial diffusion state
                                                                         error accumulation of BDIA in diffusion inversion is not
z T at time step T , the diffusion-based sampling process
                                                                         a big issue (Zhang et al., 2023a) due to the fact that the
for generating realisic images z ϵ at time t = ϵ > 0 can
                                                                         number of timesteps is generally set to be small (e.g., 50
be realized by solving a probability ordinary differential
                                                                         timesteps in either forward or reverse process) to make the
equation (ODE)
                                                                         time complexity reasonable.
                          dz = d(z, t)dt                      (1)        One main difference between diffusion inversion and re-
over the time interval t ∈ [T, ϵ]. The gradient vector d(z, t)           versible transformers is that no gradient needs to be back-
includes the output of a pre-trained DNN model with (z t , t)            propagated in diffusion inversion for updating the DNN
as its input. The common practice for solving the above                  model. As a result, even if there is error accumulation in dif-
ODE is to first discretize the continuous time interval [T, ϵ]           fusion inversion, it is less severe than in reversible transform-
properly into a set of timesteps {ti |i = 0, . . . , N } with            ers where error accumulation in online back-propagation
t0 = T and tN = ϵ, and then perform certain integration ap-              would slow down the training convergence or even make the
proximation per small time-interval sequentially to compute              training fail especially for very deep models like LLMs. In
the final diffusion state z N = z ϵ .                                    next section, we will explain how to design exact bit-level
                                                                         reversible transformers in the training process to avoid any
BDIA: Suppose we would like to estimate the next diffu-                  error-accumulation while at the same time, maintaining the
sion state z i+1 = z ti+1 by solving (1) based on the re-                architectures of the transformer in the inference procedure.
cent information (z i , ti ) and (z i−1 , ti−1 ), where z j = z tj
for j = i − 1, i. The basic idea of BDIA is to com-
pute z i+1 by performing both the                                        4. Exact Bit-Level Reversible Transformers via
                                       forward              ap-
                                                   integration
                                           R ti+1
proximation ∆(ti → ti+1 |z i ) ≈ ti d(z, t)dt and
                                                                            BDIA

 backward
the                  approximation ∆(ti → ti−1 |z i )
             integration                                                 In this section, we first briefly review the transformer update
     R ti
  ≈ − ti−1 d(z, t)dt conditioned on z i . One popular                    expressions from the ODE viewpoint. We then propose the
                                                                         BDIA-transformer that enables exact bit-level reversibility
method for implementing ∆(ti → ti+1 |z i ) and ∆(ti →
                                                                         with activation quantization. Specially, we will demonstrate
ti−1 |z i ) in the literature of diffusion models is by employ-
                                                                         how each of the two γ values {−0.5, 0.5} averages consec-
ing the DDIM update expression (see (Song et al., 2021;
                                                                         utive integration approximations. The training of a BDIA-
Zhang et al., 2023b;a) for details). With the above two
                                                                         transformer can then be interpreted as employing different
integration approximations, z i+1 can be expressed as
                                                                         ODE solvers for different training samples in a random
 z i+1 =z i−1 −(1 − γ)(z i−1 − z i ) − γ∆(ti → ti−1 |z i )               manner. In addition, we explain why additional lightweight
              |                   {z
                                     Rt
                                                        }                side-information is required to be stored to account for the
                                    ≈ ti     d(z,t)dt
                                       i−1                               binary quantization loss in online back-propagation.
          + ∆(ti → ti+1 |z i )                                (2)
            |     {z
                R ti+1
                            }                                            4.1. Revisiting transformer update expression
              ≈ t        d(z,t)dt
                    i
                                                                         A typical transformer block consists of the attention function
       =γz i−1 + (1 − γ)z i − γ∆(ti → ti−1 |z i )
                                                                         (denoted as f (·)) and the function of feed-forward network
          + ∆(ti → ti+1 |z i ),                               (3)        (FFN) (denoted as g(·)), of which the trainable parameters
where γ = (0, 1] averages ∆(ti → ti−1 |z i ) and (z i−1 −z i )           are generally different for different block indices. Accord-
for the time-slot [ti−1 , ti ]. The minus sign in front of the           ingly, the output xk+1 of the kth transformer block can be
two quantities are due to the reverse integration direction.             mathematically represented in terms of the input xk as
The quantity −(z i−1 − z i ) is the previously computed in-
                                 R ti                                           xk+1 = xk + f k (xk ) + g k (xk + f k (xk )),         (4)
tegration approximation for ti−1      d(z, t)dt. We note that                               |               {z             }
                                                                                                             hk (xk )
negative γ values are not applicable to the diffusion models
considered in (Zhang et al., 2023a).
                                                                         where we use hk (xk ) to denote the overall residual quan-
On reversibility of BDIA: The update expression (3) is care-             tity that includes both the attention and FFN functions.
fully designed in (Zhang et al., 2023a) to enable diffusion              For simplicity, we omit the pre-normalisation operations

                                                                     3
                         On Exact Bit-level Reversible Transformers Without Changing Architecture

in (4), since these in fact do not affect the design of BDIA-
transformers later on.                                                              90


It is well known from the literature (Chen et al., 2018) that                       88
the kth forward step in (4) can be roughly viewed as the




                                                                        val. acc.
Euler integration approximation of an ODE at timestep tk :                          86


                                                                                    84
                                        ∆(tk →tk+1 |xk )                                                                                    ViT
                              z           }|        {                                                                                       BDIA-ViT

  xk+1 = xk + hk (xk ) = xk + d̃(xk , tk )(tk+1 − tk ) (5)                          82
                                                                                     -0.5    -0.4   -0.3    -0.2   -0.1   0   0.1   0.2   0.3   0.4    0.5
                               Z tk+1
                       ≈ xk +          d̃(x, t)dt,                    Figure 1. Validation performance of different ODE solvers param-
                                   tk
                                                                      eterized by a single γ parameter after training ViT and BDIA-ViT
                                                                      over CIFAR10. See Subsection 5.2 on how ViT and BDIA-ViT
where d̃(xk , tk ) denotes the gradient vector with (xk , tk )
                                                                      were trained. Each ODE solver in the inference procedure is re-
as the input. Both d̃(xk , tk ) and (tk+1 − tk ) are implic-          alized by selecting γ from [−0.5, 0.5], which is fixed across all
itly learned via the composite function hk (xk ), which is            the transformer blocks for the same input image. The validation
alternatively denoted as ∆(tk → tk+1 |xk ).                           performance of BDIA-ViT is more robust than that of ViT.
As explained later on, we will introduce BDIA into the up-
date expression of (5). Note that (5) is a general update
                                                                      In the inference stage, E(γ) = 0 is taken to replace γ in
expression that not only includes the transformer but also
                                                                      (10), which leads to a simpler update expression that only
ResNet (He et al., 2015) and its variants. It is noted in
                                                                      involves (xk , xk+1 ):
(Dupont et al., 2019) that ResNet can represent more func-
tions than neural ODEs. Despite the less powerfulness of
the ODE framework, we employ the framework to facilitate                                                   xk+1 = xk + hk (xk ),                        (11)
the design of reversible transformer and obtain promising
empirical results.
                                                                      which is identical to the original transformer update expres-
4.2. BDIA-transformer without quantization                            sion (4)-(5).
                                                                      The above analysis suggests that the BDIA training tech-
In this subsection, we first derive the update expressions of
                                                                      nique is a good candidate for fine-tuning transformer-based
BDIA-transformer without quantization as an extension of
                                                                      models because BDIA retains the standard architecture in
(5), and then study the impact of the γ values in {0.5, −0.5}.
                                                                      the inference procedure. Fine-tuning a pre-trained model
When k = 0, x1 can be computed by following (5) as
                                                                      is typically performed on a small or intermediate-sized
       x1 = x0 + h0 (x0 ) = x0 + ∆(t0 → t1 |x0 ).           (6)       dataset, which is prone to overfitting. Subsection 5.1 and
                                                                      Appendix E demonstrate successfully applying BDIA to
The update expression for xk+1 in the training process,               fine-tune GPT2 medium using a small dataset.
K − 1 ≥ k ≥ 1, can be obtained by utilizing (2)-(3). Based            Impact of γ parameter: We now study the impact of the
on (5), we let                                                        γ parameter in (10). When γ = 0.5, itR follows from (2)-(3)
                                                                                                               tk
                                                                      and (7)-(8) that the two integrations tk−1   d̃(xτ , τ )dτ and
              ∆(tk → tk−1 |xk ) = −hk (xk )                 (7)       R tk+1
                                                                             d̃(xτ , τ )dτ of the transformer ODE are approximated
              ∆(tk → tk+1 |xk ) = hk (xk ).                 (8)        tk
                                                                      as
By combining (7)-(8) and (2)-(3) with i = k, the update
                                                                        Z tk
expression xk+1 , K − 1 ≥ k ≥ 1, can be represented as
                                                                                            d̃(xτ , τ )dτ ≈ 0.5(xk −xk−1 )+0.5hk (xk )                  (12)
                                                                         tk−1
 xk+1 = xk−1 +(1−γ)(xk −xk−1 )+(1 + γ)hk (xk ) (9)                      Z tk+1
       = γxk−1 +(1−γ)xk +(1+γ)hk (xk ),                    (10)                              d̃(xτ , τ )dτ ≈ hk (xk ),                                  (13)
                                                                                    tk
where γ is recommended to take values from {0.5, −0.5}
with equal probability per training sample per transform              where the integration over [tk−1 , tk ] is computed as the
block, the impact of which will be explained in detail in the         weighted average of two consecutive integration approxima-
following. This is different from the work of BDIA-based              tions: (xk − xk−1 ) and hk (xk ).
diffusion inversion (Zhang et al., 2023a) where γ has to be                                                 R tk
positive.                                                             When γ = −0.5, the two integrations tk−1    d̃(xτ , τ )dτ and

                                                                  4
                           On Exact Bit-level Reversible Transformers Without Changing Architecture
R tk+1
         d̃(xτ , τ )dτ are approximated differently, given by                                     10-3
 tk                                                                                         2
                                                                                                                        without quantization
 Z tk                                                                                                                   with quantization and side info.
                                                                                           1.5
          d̃(xτ , τ )dτ ≈ (xk −xk−1 )                      (14)




                                                                            recon. error
  tk−1
 Z tk+1                                                                                     1

           d̃(xτ , τ )dτ ≈ 0.5hk (xk )+0.5(xk −xk−1 ). (15)                                0.5
  tk

                                                                                            0
In this case, the integration over [tk , tk+1 ] is computed by
                                                                                             x0     x1   x2   x3   x4   x5    x6     x7    x8     x9   x10
averaging (xk − xk−1 ) and hk (xk ).                                                                          blockwise activations

Training via an ensemble of ODE solvers: We use γk to                 Figure 2. Demonstration of the accumulated reconstruction errors
denote the random variable for the kth transformer block              for two scenarios when training BDIA-GPT2 with 12 transformer
taking values in {0.5, −0.5} with equal probability. The              blocks using the setup γk ∈ {0.5, −0.5}, k = 1, . . . , 11. The two
                                                                      scenarios are BDIA without quantization by following (16), and
above analysis of (12)-(15) implies that each training sam-
                                                                      BDIA with quantization and side information by following (24).
ple goes through a particular ODE solver determined by
                                                                      See also Fig. 6 for visualization of the reconstruction errors.
sampling a set of K − 1 random variables {γk }K−1 k=1 , which
specifies the integration path from the bottom transformer            maintaining the original DNN architectures in the inference
block until the top one. Due to randomness, different train-          procedure. See Table 3 for ablation study of the impact
ing samples will go through different ODE solvers. There              of the {γk }K−1
                                                                                  k=1 parameter on the validation performance
are in total 2K−1 different ODE solvers, where each one               when training BDIA-transformer for image classification.
corresponds to a unique integration path across the K trans-
former blocks. Intuitively speaking, if we assume that each           4.3. On exact bit-level reversibility of BDIA-transformer
of the individual ODE solvers is well behaved (i.e., its train-             with quantization
ing loss decays to a small value), then a convex combination          As explained in Section 1, one strategy for reducing memory
will also converge to a small value.                                  consumption in training transformer models like LLMs is to
In principle, different ODE solvers can also be applied in            perform online back-propagation. That is, the intermediate
the inference procedure. For instance, one can set γ to be            activation outputs from the top transformer block until the
constant within [−0.5, 0.5] in (10) across all the transformer        bottom one are computed online when performing back-
blocks for the same input. Fig. 1 demonstrates the vali-              propagation to update the model. In this subsection, we
dation performance of those different ODE solvers in the              first discuss the reversibility issue of the update expression
inference procedure for both trained BDIA-ViT and ViT                 (10). We then consider performing activation quantization to
over CIFAR10. It is clear that the validation performance of          enable exact bit-level reversibility. We note that lightweight
BDIA-ViT is much more insensitive to the single γ parame-             side information is required to be stored per transformer
ter than that of ViT. The reason for the sensitivity of ViT to        block for lossless online back-propagation.
γ in Fig. 1 is because only a single ODE solver is trained            Limitation of the reversibility of (10): The update expres-
for ViT.                                                              sion (10) is only theoretically reversible. That is, xk−1 can
On similarity to dropout technique: From a high level                 be computed in terms of (xk , xk+1 ) as
point of view, the training of BDIA-transformer is similar to                                     1         1− γk      1+γk
the conventional dropout technique (Srivastava et al., 2014)              xk−1 =                     xk+1 −       xk −      hk (xk ),                        (16)
                                                                                                  γk         γk         γk
to a certain extent. Dropout essentially attempts to train an
ensemble of subnetworks of the entire DNN model when                  where we use γk to indicate that different transformer blocks
minimizing the objective function while BDIA-transformer              have their respective random variables. In practice, the setup
intends to train an ensemble of different ODE solvers. In             γk ∈ {0.5, −0.5}, k = 1, . . . , K − 1, would lead to non-
the inference procedure, an average of the ensemble of sub-           negligible error accumulation especially for very deep trans-
networks in dropout is utilized while in BDIA-transformer,            former models. The factor γ1k = ±2 in front of xk+1 would
the expectation E[γk ] = 0 is employed to replace γk . In             amplify the error when k decreases from K −1 to 1, making
the experiments we investigated the joint impact of dropout           the online back-propagation unstable. Fig. 2 illustrates that
and BDIA for the image classification task, and obtained              the reconstruction error without quantization increases sig-
positive results. See Table 5 for details.                            nificantly when applying the online-back-propagation from
                                                                      the last transformer block back to the first.
Remark 4.1. If reversibility is not of concern, one can freely
specify the values for the random variables {γk }K−1
                                                   k=1 in the         BDIA-transformer with quantization: To allow for loss-
training process for performance improvement as long as its           less online back-propagation, we propose to perform acti-
distribution is symmetric around 0 such that E[γk ] = 0 for           vation quantization. In particular, we use Ql [·] to denote

                                                                  5
                          On Exact Bit-level Reversible Transformers Without Changing Architecture

quantization to the bit-level precision of 2−l , given by              See Appendix C for the proof. The lossless reconstruc-
                                                                       tion (24) ensures that the computed gradients in the online
                 Ql [y] = round[y/2−l ]2−l .                (17)       back-propagation would not deviate from those in conven-
Upon introducing Ql [·], the new update expression for                 tional back-propagation, which is desirable in very deep
BDIA-transformer can be represented as                                 transformer models. In Fig. 2, the blue line shows the ex-
                                                                       act reconstruction of the intermediate activation values, as
       x0 ← Ql [x0 ],                                       (18)       enabled by (24) during online back-propagation.
       x1 = x0 + Ql [h0 (x0 )]                 (19)
                                                                       Finally we briefly consider the inference procedure. Again
                               −l
           
            1 if mod(xk−1 [m]/2 , 2) = 1                               we replace γk in (21) by E(γk ) = 0. As a result, the update
 sk−1 [m]=                               k ≥ 1 (20)
            0 otherwise                                                expression (21) can be simplified to be
     xk+1 = Ql [γk (xk−1 + sk−1 2−l )]
                                                                                   xk+1 = Ql [xk + hk (xk )] k ≥ 1.              (25)
           +Ql [(1−γk )xk +(1+γk )hk (xk )] k ≥ 1, (21)
where γk ∈ {0.5, −0.5}, and xk−1 [m] denotes the mth                   The only difference of (25) w.r.t. the original transformer
element of xk−1 . The mth element sk−1 [m] indicates if the            update expression (4) is that the quantization operation Ql [·]
integer value xk−1 [m]/2−l is odd or not.                              is performed for each activation output.
Lemma 4.2. Suppose {xk }K                                              Remark 4.5. The particular choice of γk ∈ {0.5, −0.5} is
                            k=0 are computed sequentially
by following (18)-(21). Then the intermediate activation               also motivated by exact bit-level reversibility. When γ is
output xk has fixed-point precision of 2−l :                           a power of two such as 0.5 = 2−1 , the result of a product
                                                                       γ · x is equivalent to shifting the mantissa of x by one bit
               xk = Ql [xk ]      K ≥ k ≥ 0.                (22)       or decrementing its exponent, so at most exactly one bit is
                                                                       lost. This property is not true for arbitrary (non-power-of-2)
                                                                       values of γ.
We refer to the binary vector sk−1 in (20) as the lightweight
side information computed based on xk−1 . The vector                   Limitations of BDIA-transformer: To our best knowledge,
sk−1 essentially captures the 1-bit quantization loss of               all existing reversible DNN models do not need to store any
Ql [γk xk−1 ] per element, and is crucial for recovering xk−1          lightweight side information in the forward process. The pri-
exactly from (xk , xk+1 ). We now characterize the first               mary objective of most existing works is to design reversible
quantization operation on the right hand side (RHS) of (21)            DNN models (e.g., RevViT) that produce comparable vali-
with the following proposition:                                        dation performance as the original counterparts. From the
Proposition 4.3. Suppose the conditions in Lemma 4.2 hold.             perspective of memory reduction, existing reversible DNN
Then for any k ≥ 1, we have                                            models are more efficient than BDIA-transformer.
 Ql [γk (xk−1 + sk−1 2−l )] = γk (xk−1 + sk−1 2−l ). (23)              On the other hand, BDIA-transformer is designed to not only
                                                                       save training memory but also improve the generalization
                                                                       performance via model regularization. Our method is the
The proof for Proposition 4.3 can be found in Appendix B.
                                                                       first of its kind that attempts to maintain the transformer
Equ. (23) indicates that the quantization operation has no
                                                                       architecture in the inference procedure.
effect on γk (xk−1 + sk−1 2−l ), which naturally facilitates
the exact reconstruction of xk−1 from (xk , xk+1 ).
                                                                       5. Experiments
On reversibility of (21) by storing lightweight side in-
formation: Suppose in each forward pass in the training                We evaluated BDIA-transformer for four different tasks:
                                          k=K−1
process, all the side information {sk−1 }k=1       is stored in        (1) fine-tuning GPT2 using the BDIA training technique
the memory. Then exact bit-level reversibility is guaranteed:          for natural language generation (NLG); (2) training BDIA-
Proposition 4.4. Suppose the conditions in Lemma 4.2 hold              ViT for image classification; (3) training BDIA-transformer
and the side information {sk−1 }k=1k=K−1
                                           is available. Then          for language translation; (4) training BDIA-GPT2 for text
{xk−1 }K−1     can  be reconstructed exactly   in the reverse          generation. The hyper-parameter l for quantization in all
        k=1
order with the initial state-pair (xK−1 , xK ):                        four tasks was set to l = 9. Four open-source repositories
                                                                       were used in the experiments (see Table 7 in Appendix G).
               1                                                       Due to the space constraint, we put the experimental results
     xk−1 =       xk+1 −sk−1 2−l
               γk                                                      for the fourth task in Appendix F.
              1
          −      Ql [(1−γk )xk +(1+γk )hk (xk )],           (24)       In brief, the obtained results from the first three tasks in-
              γk
                                                                       dicate that the BDIA technique significantly improves the
where k = K − 1, . . . , 1.                                            validation performance of the original counterparts due to

                                                                   6
                                            On Exact Bit-level Reversible Transformers Without Changing Architecture

                                                                                                              the table that results for FT-BDIA are consistently better
Table 1. Performance for fine-tunning GPT-2 medium (M) on the
                                                                                                              than those for FT. On the other hand, even though the LoRA
E2E NLG Challenge. For all metrics, higher is better.
                                                                                                              technique is light-weight, its performance is promising.
                          trainable                                                                           Remark 5.1. We have also investigated the joint impact of
             Method                     BLEU         NIST              MET    ROUGE-L        CIDEr
                            param.
              LoRA         0.35M        69.0         8.70              46.4       71.3       2.51
                                                                                                              LoRA and BDIA when fine-tuning GPT2 M for NLG, and
               FT         354.92M       66.8         8.52              46.3       70.3       2.37
                                                                                                              again we obtained positive results. See Appendix E for
                                                                                                              details. In brief, BDIA helps with improving the validation
             FT-BDIA      354.92M       68.6         8.65              46.6       71.3       2.49
                                                                                                              performance for LoRA based fine-tuning for the considered
                                                                                                              task. To enhance the impact of BDIA in the fine-tuning
                                                                1.35
                                                                                  LoRA                        process, it is recommended to set a high value for the α
             2.6                                                                  FT
                                                                 1.3                                          parameter in LoRA.
                                                                                  FT-BDIA

             2.4                                                1.25
                                                                                                              5.2. On training BDIA-ViT
train loss




                                                     val loss




                                                                 1.2
                                                                                                              In this experiment, we trained BDIA-ViT with K=6 trans-
             2.2                                                                                              former blocks on CIFAR10 and CIFAR100 by using a single
                                                                1.15                                          2080 Ti GPU. The performance of ViT and RevViT (Man-
              2                                                                                               galam et al., 2023) was also evaluated to facilitate compari-
                          LoRA
                          FT
                                                                 1.1                                          son. When implementing BDIA-ViT, the {γk }K−1     k=1 param-
                          FT-BDIA                                                                             eters were drawn from {−0.5, 0.5} with equal probability
             1.8                                                1.05
                    0.5   1      1.5    2      2.5                     0.5    1        1.5   2      2.5       per training sample. In addition, we utilized the SET-Adam
                           iterations       10 4                              iterations         10 4         optimizer (Zhang, 2024) in the training process with the
                                                                                                              configuration (η0 , β1 , β2 , ϵ) = (1e−4, 0.9, 0.999, 1e−18),
Figure 3. Performance comparison when fine-tuning GPT2                                                        where η0 denotes the initial learning rate. The dropout rate
Medium for the E2E challenge. {γk }K−1  k=1 in the BDIA training                                              was set to 0.1 to reduce over-fitting. The remaining training
procedure were randomly drawn from {±0.5} per training sam-                                                   setups follow directly from the original open source (i.e., the
ple. FT-BDIA refers to “fine-tuning via BDIA training technique”                                              first github link of Table 7). Three experimental repetitions
while FT refers to “fine-tuning directly”.
                                                                                                              were performed for each training setup to mitigate the effect
the model regularization effect of the random {γk }K−1                                                        of the random seed.
                                                   k=1 vari-
ables. The results for the 4th task demonstrate that BDIA-                                                    Performance comparison: Table 2 summarizes the ob-
GPT2 alleviates the overfitting issue of GPT2 significantly                                                   tained validation accuracy, the peak memory usages, and
for limited training data. RevViT from (Mangalam et al.,                                                      the average training time per epoch. It is clear that BDIA-
2023) was also tested for the second task. It was found that                                                  ViT produces significantly higher validation accuracy than
RevViT does not always improve the performance of ViT.                                                        ViT and RevViT for both CIFAR10 and CIFAR100. Fig. 4
                                                                                                              further visualizes the training and validation curves. It is
5.1. On fine-tuning GPT2 medium (M) for NLG                                                                   seen that even though the training loss of BDIA-ViT is
In the first experiment, we consider fully fine-tuning GPT2                                                   higher than the other two models across all the epochs, the
medium (354.92M parameters in total) for the natural lan-                                                     validation accuracy improves remarkably in the end of train-
guage generation (NLG) task by using the E2E dataset                                                          ing. This indicates that training an ensemble of ODE solvers
(Novikova et al., 2017). We adopt the open-source for GPT2                                                    parameterized (see Subsection 4.2) by {γk }K−1
                                                                                                                                                           k=1 indeed reg-
(LoRA) in (Hu et al., 2021) (the second github link of Ta-                                                    ularizes BDIA-transformer properly.
ble 7) to evaluate the BDIA training technique. For com-
                                                                                                              In contrast, RevViT yields either inferior or comparable val-
parison, we also fine-tune GPT2 directly and via the LoRA
                                                                                                              idation performance to ViT (Table 2). This may be because
technique with the default setup of (rank, α) = (4, 32). It
                                                                                                              RevViT modifies the architectures of ViT considerably to
is worth noting that the LoRA technique only needs to train
                                                                                                              enable reversibility and therefore implicitly imposes uncon-
a very small number of parameters.
                                                                                                              trolled regularization on the original transformer model.
It is clear from Fig. 3 that the BDIA training technique leads                                                On the other hand, the regularisation introduced in our
to the best validation performance in the end of training                                                     technique is motivated by averaging consecutive integra-
while direct fine-tuning of GPT2 exhibits the over-fitting                                                    tion approximations of an ODE in the original transformer,
issue. It is plausible that the validation losses for LoRA are                                                which leads to consistent performance gain across different
larger than those for FT-BDIA because LoRA only trains a                                                      datasets.
small number of parameters.
                                                                                                              It is also clear from Table 2 that RevViT is most memory-
Table 1 summarizes results for 5 metrics. It is seen from                                                     efficient. BDIA-ViT improves on the validation perfor-

                                                                                                          7
                                                 On Exact Bit-level Reversible Transformers Without Changing Architecture


Table 2. Validation accuracy (in percentage), peak memory consumption, and average training time per epoch for training three models
over CIFAR10 and CIFAR100. {γk }K−1   k=1 in the BDIA training procedure were drawn from {±0.5} per training sample. The peak
memory includes both the model parameters and the training states for a batchsize of 128. The dropout rate was set to 0.1. See also Fig. 7
for training curves on CIFAR-10 plotted against wall-clock time.
                                     RevViT (Mangalam et al., 2023)                                                           ViT                                                  BDIA-ViT
                                                                train. time                                                                train. time                                                 train. time
                               val. acc.    peak memory                                     val. acc.         peak memory                                    val. acc.           peak memory
                                                                per epoch                                                                  per epoch                                                   per epoch
   CIFAR10                    86.22±0.42           572.7MB                     41.8 s      88.15±0.55              1570.6MB                  30.6 s         89.10±0.38            693.4MB                47.0 s
  CIFAR100                    61.89±0.31           572.7MB                     41.8 s      61.86±0.47              1570.6MB                  30.6 s         66.09±0.80            693.4MB                47.0 s


                                                            for CIFAR10                                                                                  for CIFAR100
                        0.2                                               90                                                  0.2                                           67
                                                 ViT                                ViT                                                          ViT                               ViT
                       0.18                      RevVit                             RevVit                                   0.18                RevVit                     66     RevVit
                                                 BDIA-ViT                 89        BDIA-ViT                                                     BDIA-ViT                          BDIA-ViT
                       0.16                                                                                                  0.16                                           65
                                                                          88
                                                                                                                                                                            64
                       0.14                                                                                                  0.14
                                                                          87                                                                                                63
                       0.12                                                                                                  0.12
        taining loss




                                                                                                              taining loss
                                                               val. acc




                                                                                                                                                                 val. acc
                                                                                                                                                                            62
                        0.1                                               86                                                  0.1
                                                                                                                                                                            61
                       0.08                                                                                                  0.08
                                                                          85                                                                                                60
                       0.06                                                                                                  0.06
                                                                                                                                                                            59
                                                                          84
                       0.04                                                                                                  0.04                                           58
                                                                          83
                       0.02                                                                                                  0.02                                           57

                         0                                                82                                                   0                                            56
                                  100      200    300   400                        100    200     300   400                         100    200     300    400                     100    200     300    400
                                        epochs                                           epochs                                           epochs                                        epochs

Figure 4. Performance comparison of ViT, RevViT (Mangalam et al., 2023), and BDIA-ViT for image classification over CIFAR10 and
                 K−1
CIFAR100. {γk }k=1   in the training procedure of BDIA-ViT were drawn from {±0.5} per training sample. The dropout rate was 0.1.

mance of RevViT at the cost of slightly more memory,                                                                         operations were turned off in BDIA-transformer. We em-
needed to store the lightweight side information {sk }3k=0                                                                   phasize that the non-zero γk values were only utilized in
of the first 4 transformer blocks. We can also conclude                                                                      the training process. At the inference stage, E[γk ] = 0 was
from the table that online back-propagation does indeed                                                                      used for computing the validation accuracy, which in fact
significantly reduce the training memory.                                                                                    reduces to the standard transformer architecture.
Lastly, we briefly discuss the average training time per
epoch. It is clear from the table that both ReViT and BDIA-                                                                  Table 3. Impact of the {γk }K−1
                                                                                                                                                          k=1 parameter in BDIA-ViT (w.o.
ViT require additional training time for recomputation of the                                                                quantization and w.o. online back-propagation) on the validation
intermediate activation values in online-backpropagation.                                                                    accuracy in percentage over CIFAR10. The dropout rate was 0.1.
BDIA-ViT needs slightly more time than ReViT because                                                                          {γk }K−1
                                                                                                                                   k=1            0.0            {±0.25}                 {±0.5}            {±0.6}
the method needs to handle the side information, the binary                                                                    CIFAR10       88.15±0.55         88.79±0.29           89.12±0.22          88.89±0.15
random variables, and quantization. See Fig. 7 for training
curves on CIFAR-10 plotted against wall-clock time.                                                                          Table 2 summarizes the obtained validation accuracy for
                                                                                                                             different setups of the {γk }K−1k=1 parameters. It is clear
Ablation study regarding the {γk }K−1     k=1 parameters:
                                                                                                                             that when {|γk | > 0}K−1  k=1   , the performance of BDIA-
As we mentioned in Remark 4.1, if reversibility is
                                                                                                                             transformer improves considerably in comparison to that
not of primary concern, different values for {γk }K−1    k=1
                                                                                                                             of the conventional ViT (i.e., corresponding to BDIA-ViT
can be employed for model regularisation. We con-
                                                                                                                             with {γk = 0.0}K−1  k=1 ). The setup of {γk = ±0.5}k=1
                                                                                                                                                                                      K−1
ducted ablation study by evaluating the impact of γk ∈
                                                                                                                             performs the best. In general, the larger the magnitude of
{0.0, ±0.25, ±0.5, ±0.6}, k = 1, . . . , K − 1, on the valida-                                                                        K−1
                                                                                                                             the {γk }k=1  parameters in [0, 0.6], the slower the training
tion performance of BDIA-transformer for CIFAR10. For
                                                                                                                             speed (see Fig. 4). In practice, one can tune the magnitude of
doing so, both the quantization and online back-propagation
                                                                                                                             the {γk }K−1
                                                                                                                                      k=1 parameters within [0, 0.6] to trade-off between


                                                                                                          8
                                         On Exact Bit-level Reversible Transformers Without Changing Architecture
                                                                                                     1.6                                            1.6
the training speed and the validation performance.                                                                 transformer                                    transformer
                                                                                                                   BDIA-transformer                                BDIA-transformer
                                                                                                     1.4
                                                                                                                                                    1.5
Ablation study regarding the quantization level: We have




                                                                                      taining loss
                                                                                                     1.2
also investigated the impact of the quantization levels of




                                                                                                                                        val. loss
                                                                                                                                                    1.4
{5, 0, −2} on the performance of both ViT and BDIA-ViT                                                1
over CIFAR10, where l = −2 corresponds to a very coarse                                                                                             1.3
                                                                                                     0.8
quantization operation. The {γk }K−1
                                  k=1 variables in BDIA-
ViT were drawn randomly from {±0.5} per training sample.                                             0.6                                            1.2

                                                                                                           50    100     150      200                     50    100      150      200
                                                                                                                epochs                                         epochs
Table 4. Impact of the quantization level in ViT and BDIA-ViT                         Figure 5. Performance comparison for English to French transla-
on the validation accuracy in percentage over CIFAR10.                                tion. {γk }K−1
                                                                                                 k=1 in the BDIA training procedure were randomly
                 quantization level l         5           0     -2                    drawn from {±0.5} per training sample.
                           ViT              87.90     87.76    84.31
                     BDIA-ViT               89.50     88,.47   84.16                  existing open-source repository (i.e., the third github link of
                                                                                      Table 7) in our experiment. The dataset being used is from
As shown in Table 4, when the quantization level l drops
                                                                                      Kaggle (Kelly, 2020). The tested BDIA-transformer has six
from 5 to -2, the performance of ViT and BDIA-ViT de-
                                                                                      transformer blocks in both the encoder and decoder, respec-
creases as expected. One can also observe from the table
                                                                                      tively. The BDIA update expressions were implemented
that when l ∈ {5, 0}, BDIA-ViT performs consistently and
                                                                                      in both the encoder and decoder. The performance of the
significantly better than ViT. When l = −2, there is a large
                                                                                      conventional transformer was tested as a reference.
performance drop in both methods due to the very coarse
quantization effect. For that case, ViT performs slightly                             Fig. 5 visualizes the training and validation losses of the
better than BDIA-ViT. This likely is because the very coarse                          two tested models. It is clear that the obtained curves in
quantization dominates the performance and negatively af-                             Fig. 5 exhibit similar properties to those in Fig. 4. That is,
fects the BDIA-training technique.                                                    even though the training loss of BDIA-transformer is higher
                                                                                      than the conventional transformer across all the epochs, its
Ablation study regarding the dropout rates: As we dis-
                                                                                      validation loss is significantly lower after epoch 200.
cussed earlier, the dropout technique trains an ensemble
of subnetworks, while BDIA trains an ensemble of ODE                                  6. Conclusions
solvers. It is of great interest to investigate the joint impact
                                                                                      We have proposed the BDIA training algorithm for trans-
of dropout and BDIA. We conducted additional experiments
                                                                                      formers. Firstly, each transformer block is taken as the Euler
by setting the dropout rate to 0.0 and 0.2 when testing BDIA-
                                                                                      integration approximation for solving an ODE. The BDIA
ViT. Table 5 shows the obtained validation accuracies, where
                                                                                      technique is then applied to average every two consecutive
the results for dropout rate of 0.1 are from Table 2.
                                                                                      integration approximations in a transformer as a regular-
                                                                                      izer via a set of random variables {γk }K−1
                                                                                                                                k=1 , one variable
Table 5. Impact of dropout rates in ViT and BDIA-ViT on the                           per transformer block. The training process can then be
validation accuracy percentage. In BDIA training {γk }K−1
                                                      k=1 were                        understood as training an ensemble of ODE solvers parame-
randomly drawn from {±0.5} per training sample.                                       terized by {γk }K−1
                                                                                                       k=1 . Exact reversibility for lossless online
  dropout rate              0.0                     0.1                0.2            back-propagation is achieved by activation quantization and
                    ViT     BDIA-ViT         ViT    BDIA-ViT    ViT    BDIA-ViT       storing only lightweight side information. In the inference
    CIFAR10        86.27         89.20      88.15     89.10    87.24    88.22         procedure, the variables γk are replaced with their expecta-
   CIFAR100        59.13         64.45      61.86     66.09    61.68    64.24         tion E[γk ] = 0, which reduces the update expression to that
                                                                                      of a conventional transformer up to activation quantization.
It is seen from Table 5 that for different dropout rates and
different datasets, the BDIA training technique improves                              Experiments on natural language generation, translation,
the validation performance consistently and considerably.                             and image classification show that BDIA-transformer pro-
In brief, the dropout and BDIA are complimentary regular-                             duces significantly better validation performance than the
ization techniques when training transformers.                                        corresponding baseline transformers while, at the same
                                                                                      time, reducing training memory by performing online back-
                                                                                      propagation. In comparison, the experiments with RevVit
5.3. On training BDIA-transformer for English-French                                  demonstrate that it yields either inferior or comparable val-
     translation                                                                      idation performance to that of ViT. BDIA-transformer is
Language translation is a classical natural language pro-                             also attractive for fine-tuning since it requires minimal ar-
cessing (NLP) task where the transformer shows a large                                chitecture changes, needs very little extra memory, and is
performance gain over other DNN models. We adopted an                                 complementary to LoRA.

                                                                                  9
                            On Exact Bit-level Reversible Transformers Without Changing Architecture

Impact Statement                                                             Finzi, M., Izmailov, P., Maddox, W., Kirichenko, P., and Wilson.,
                                                                               A. G. Invertible convolutional networks. In Workshop on
Transformer architectures are widely used in various con-                       Invertible Neural Nets and Normalizing Flows, 2019.
texts including, for example, LLMs for natural language pro-
                                                                             Gholami, A., Yao, Z., Kim, S., Hooper, C., Mahoney, M. W., and
cessing and diffusion models for image and video process-
                                                                               Keutzer, K. AI and Memory Wall. IEEE Micro, 44(3):33–39,
ing. Fine-tuning these models with either small or interme-                    2024.
diate data sizes for diverse downstream tasks is a common
practice. Our BDIA training technique offers an attractive                   Gomez, A. N., Ren, M., Urtasun, R., and Grosse, R. B. The
approach for fine-tuning. This is because BDIA trains an                       reversible residual network: Backpropagation without storing
                                                                               activations. arXiv:1707.04585v1 [cs.CV], 2017.
ensemble of ODE solvers to reduce over-fitting and lower
training memory requirements while simultaneously retain-                    Grathwohl, W., Chen, I. S. R. T. Q., Bettencourt, J., and Duve-
ing the original transformer architecture in the inference                     naud, D. Ffjord: Free-form continuous dynamics for scalable
procedure.                                                                     reversible generative models. arXiv:1810.01367, 2018.

                                                                             Hascoet, T., Febvre, Q., W. Zhuang, Y. A., and Takiguchi, T.
References                                                                     Layer-wise invertibility for extreme memory cost reduction of
                                                                               cnn training. In Proceedings of the IEEE/CVF International
Achiam, J., Adler, S., Agarwal, S., Lama Ahmad, Ilge Akkaya,                   Conference on Computer Vision Workshops, 2019.
  F. L. A., Almeida, D., Altenschmidt, J., Altman, S., Anad-
  kat, S., Avila, R., Babuschkin, I., Balaji, S., Balcom, V., Bal-           He, K., Zhang, X., Ren, S., and Sun, J. Deep Residual Learning
  tescu, P., Bao, H., Bavarian, M., Belgum, J., Bello, I., Berdine,            for Image Recognition. In IEEE conference on Computer Vision
  J., Bernadett-Shapiro, G., Christopher Berner, L. B., Boiko,                 and Pattern Recognition (CVPR), 2015.
  O., Boyd, M., Brakman, A.-L., Brockman, G., Brooks, T.,
  Brundage, M., Button, K., Cai, T., Campbell, R., Cann, A.,                 Hu, E. J., Shen, Y., Wallis, P., Allen-Zhu, Z., Li, Y., Wang, S.,
  Carey, B., Carlson, C., Carmichael, R., Chan, B., Chang, C.,                 Wang, L., and Chen, W. LoRA: Low-Rank Adaptation of Large
  Chantzis, F., Chen, D., Chen, S., Chen, R., Chen, J., Chen, M.,              Language Models. arXiv:2106.09685 [cs.CL], 2021.
  Chess, B., Cho, C., Chu, C., Chung, H. W., Cummings, D., Cur-
  rier, J., Dai, Y., Decareaux, C., Degry, T., Deutsch, N., Deville,         Jacobsen, J.-H., Smeulders, A., and Oyallon, E. i-revnet deep
  D., Dhar, A., Dohan, D., Dowling, S., Dunning, S., Ecoffet, A.,               invertible networks. In ICLR, 2018.
  Eleti, A., Eloundou, T., Farhi, D., Fedus, L., Felix, N., Fishman,
  S. P., Forte, J., Fulford, I., Gao, L., Georges, E., Gibson, C.,           Karras, T., Aittala, M., Alia, T., and Laine, S. Elucidating the De-
  Goel, V., Gogineni, T., Goh, G., Gontijo-Lopes, R., Gordon, J.,              sign Space of Diffusion-Based Generative Models. In 36th Con-
  Grafstein, M., Gray, S., Greene, R., Gross, J., Gu, S. S., Guo,              ference on Nueral Information Processing Systems (NeurIPS),
  Y., Hallacy, C., Han, J., Harris, J., He, Y., Heaton, M., Heidecke,          2022.
  J., Hesse, C., Hickey, A., Hickey, W., Hoeschele, P., Houghton,
                                                                             Kelly, C. Language translation (english-french), 2020. URL
  B., Hsu, K., Hu, S., Hu, X., Huizinga, J., Jain, S., and Jain, S.
                                                                               https://www.kaggle.com/dsv/1067156.
  Gpt-4 technical report. arXiv:2307.09288 [cs.CL], 2023.
                                                                             Kingma, D. P. and Dhariwal, P. Glow: Generative flow with
Behrmann, J., Grathwohl, W., Chen, R. T. Q., Duvenaud, D., and                 invertible 1x1 convolutions. In Advances in neural information
  Jacobsen, J.-H. Invertible Residual Networks. In Proceedings                 processing systems, 2018.
  of the International Conference on Machine Learning (ICML),
  2019.                                                                      Kingma, D. P., Salimans, T., Jozefowicz, R., Chen, X., Sutskever,
                                                                               I., and Welling, M. Improved variational inference with inverse
Chang, B., Meng, L., Haber, E., Ruthotto, L., Begert, D., and                  autoregressive flow. Advances in neural information processing
  Holtham, E. Reversible Architectures for Arbitrarily Deep                    systems, 29, 2016.
  Residual Neural Networks. arXiv:1709.03698v2 [cs.CV], 2017.
                                                                             Kobyzev, I., Prince, S. J., and Brubaker, M. A. Normalizing Flows:
Chen, R. T. Q., Rubanova, Y., Bettencourt, J., and Duvenaud, D.                An Introduction and Review of Current Methods. PAMI, (11):
  Neural ordinary differential equations. In 32nd Conference on                3964–3979, 2020.
  Neural Information Processing Systems (Neurips), 2018.
                                                                             Lin, Y., Ma, X., Chu, X., Jin, Y., Yang, Z., Wang, Y., and Mei, H.
Dinh, L., Krueger, D., and Bengio, Y. Nice: Non-linear indepen-                LoRA dropout as a sparsity regularizer for overfitting control.
  dent components estimation. arXiv preprint arXiv:1410.8516,                  arXiv:2404.09610 [cs.LG], 2024.
  2014.
                                                                             Ma, S. The Era of 1-bit LLMs: All Large Language Models are in
                                                                              1.58 Bits. arXiv:2402.17764v1, 2024.
Dinh, L., Sohl-Dickstein, J., and Bengio, S. Density estimation
  using real nvp. arXiv preprint arXiv:1605.08803, 2016.                     Mangalam, K., adn Y. Li, H. F., Qu, C.-Y., Xiong, B., Feicht-
                                                                              enhofer, C., and Malik, J. Reversible vision transformers.
Dupont, E., Doucet, A., and Teh, Y. W. Augmented neural odes.                 arXiv:2302.04869v1 [cs.CV], 2023.
  arXiv:1904.01681v3, 2019.
                                                                             Novikova, J., Dusek, O., and Rieser, V. The e2e dataset:
Feng, J. and Huang, D. Optimal gradient checkpoint search for                  New challenges for end-to-end generation. arXiv preprint
  arbitrary computation graphs. In CVPR, 2021.                                 arXiv:1706.09254, 2017.

                                                                        10
                            On Exact Bit-level Reversible Transformers Without Changing Architecture

Rezende, D. and Mohamed, S. Variational inference with normal-               Zhu, T. and Mangalam, K. Pareprop: Fast parallelized reversible
  izing flows. In International conference on machine learning,                backpropagation. arXiv:2306.09342v1 [cs.LG], 2023.
  pp. 1530–1538. PMLR, 2015.
Sander, M. E., P. Ablin, M. B., and Peyre, G. Momentum residual
  neural networks. arXiv:2102.07870, 2021.
Song, J., Meng, C., and Ermon, S. Denoising Diffusion Implicit
  Models. In ICLR, 2021.
Song, Y., Meng, C., and Ermon, S. Mintnet: Building invertible
  neural networks with masked convolutions. arXiv:1907.07945,
  2019.
Srivastava, N., Hinton, G., Krizhevsky, A., Sutskever, I., and
   Salakhutdinov, R. Dropout: A Simple Way to Prevent Neu-
   ral Networks from Overfitting. Journal of Machine Learning
   Research, pp. 1929–1958, 2014.
Stam, J. An exact bitwise reversible integrator. arXiv:2207.07695
   [cs.GR], 2022.
Touvron, H., Martin, L., K. Stone, P. A., Almahairi, A., Babaei,
  Y., Bashlykov, N., Batra, S., Bhargava, P., Bhosale, S., Bikel,
  D., Blecher, L., Ferrer, C. C., Chen, M., Cucurull, G., Es-
  iobu, D., Fernandes, J., Fu, J., Fu, W., Fuller, B., Gao, C.,
  Goswami, V., Goyal, N., Hartshorn, A., Hosseini, S., Hou, R.,
  Inan, H., Kardas, M., Kerkez, V., Khabsa, M., Kloumann, I.,
  Korenev, A., Koura, P. S., Lachaux, M.-A., Lavril, T., Lee, J.,
  Diana Liskovich, Y. L., Mao, Y., Martinet, X., Mihaylov, T.,
  Mishra, P., Molybog, I., Yixin Nie, A. P., Reizenstein, J., Rungta,
  R., Saladi, K., Schelten, A., Silva, R., Smith, E. M., Subrama-
  nian, R., Tan, X. E., Tang, B., Taylor, R., Adina Williams, J.
  X. K., Xu, P., Yan, Z., Zarov, I., Zhang, Y., Fan, A., Kam-
  badur, M., Sharan Narang, A. R., Stojnic, R., Edunov, S., and
  Scialom, T. Llama 2: Open foundation and fine-tuned chat
  models. arXiv:2307.09288 [cs.CL], 2023.
Wallace, B., Gokul, A., Ermon, S., and Naik, N. End-to-End
  Diffusion Latent Optimization Improves Classifier Guidance.
  arXiv:2303.13703v2 [cs.CV], 2023.
Wang, N., Choi, J., Brand, D., Chen, C.-Y., and Gopalakrishnan, K.
  Training deep neural networks with 8-bit floating point numbers.
  In NeurIPS, 2018.
Wu, K., Park, J. B., Zhang, X., Hidayetoglu, M., Mailthody, V. S.,
 Huang, S., Lumetta, S. S., and Hwu, W. Ssdtrain: An activation
 offloading framework to ssds for faster large language model
 training. arXiv:2408.10013 [cs.DC], 2024.
Wu, S., Li, G., Chen, F., and Shi, L. Training and inference
 with integers in deep neural networks. In ICLR, 2018. URL
 https://openreview.net/forum?id=HJGXzmspb.
Yang, G., Zhang, T., Kirichenko, P., Bai, J., Wilson, A. G., and Sa,
  C. D. SWALP: Stochastic Weight Averaging in Low-Precision
  Training. In ICML, 2019.
Zhang, G. On Suppressing Range of Adaptive Stepsizes of Adam
  to Improve Generalisation Performance. In ECML, 2024.
Zhang, G., Lewis, J. P., and Kleijn, W. B. Exact diffusion inversion
  via bidirectional integration approximation. arXiv:2307.10829
  [cs.CV], 2023a.
Zhang, G., Niwa, K., and Kleijn, W. B. On Accelerating Diffusion-
  Based Sampling Processes by Improved Integration Approxi-
  mation. arXiv:2304.11328 [cs.LG], 2023b.

                                                                        11
                          On Exact Bit-level Reversible Transformers Without Changing Architecture

A. Demonstration of Reversibility Issue of BDIA Without Quantization on a Log Scale
We note that the reconstruction errors in Fig. 2 are plotted on a linear-scale. To better visualize the results, we include Fig. 6
for the case of BDIA without quantization by following (16). The errors are plotted on a log scale.
                                              100



                                             10-5

                              recon. error

                                             10-10



                                             10-15

                                                                        blockwise activations

Figure 6. Demonstration of the accumulated reconstruction error in log-scale by following (16) with the setup γk ∈ {0.5, −0.5},
k = 1, . . . , K−1, when training BDIA-GPT2 with 12 transformer blocks.


B. Proof of Proposition 4.3
Proof. Equation (23) in Proposition 4.3 can be proved by simple algebra. It is known from Lemma 4.2 that Ql [xk−1 ] = xk−1
holds for any k ≥ 1. For each element of the expression on the left hand side (LHS) of (23), we have
                                                       Ql [γk (xk−1 [m] + sk−1 [m]2−l )]
                                                                h                          i
                                                       = round γk (xk−1 [m]/2−l + sk−1 [m]) 2−l .                            (26)

By using (17) and the definition of sk−1 [m] from (20), it is immediate that the scalar (xk−1 [m]/2−l + sk−1 [m]) in (26)
is an even integer number. Since γk ∈ {−0.5, 0.5}, the round operation in (26) has no real effect and can be removed.
Therefore, (26) can be rewritten as
                                                          Ql [γk (xk−1 [m] + sk−1 [m]2−l )]
                                                              h                             i
                                                          = γk (xk−1 [m]/2−l + sk−1 [m]) 2−l
                                                          = γk (xk−1 [m] + sk−1 [m]2−l ).                                    (27)
The proof is complete.

C. Proof of Proposition 4.4
Proof. Also (24) in Proposition 4.4 can be proved by simple algebra. Firstly, plugging (23) into (21) produces
                             xk+1 = γk (xk−1 + sk−1 2−l ) +Ql [(1−γk )xk +(1+γk )hk (xk )] .                                 (28)
                             | {z }    |      {z       } |               {z              }
                             1st term                        2nd term                           3rd term

It is known from Lemma 4.2 and (20) that all three terms in (28) have a fixed-point precision of 2−l . As a result, the equality
in (28) holds without any error. Multiplying with γ1 = ±2 on both sides of (28) and rearranging the quantities produces
                                                                    k

                                                     1                   1
                            xk−1 =                      xk+1 − sk−1 2−l − Ql [(1−γk )xk +(1+γk )hk (xk )],                   (29)
                                                     γk                  γk
which again holds without any error. The proof is complete.

D. Training Time Comparison
This Appendix discuses training effort in more detail. Table 2 includes the average training time per epoch for CIFAR10
and CIFAR100 for three algorithms and that Fig. 4 shows the training and validation curves over 400 epochs. Fig. 7 in this
Appendix shows the training curves for CIFAR10 against wall-clock time for 400 epochs.

                                                                                12
                         On Exact Bit-level Reversible Transformers Without Changing Architecture

It is seen from Fig. 7 that BDIA-ViT with online backpropagation needs slightly more time to cover 400 epochs than RevViT
with online backpropagation. This is because BDIA-ViT needs to handle the lightweight side information, binary random
variables, and quantization. ViT is most time efficient as it does not need to recompute the intermediate activation values as
the other two methods.
While the final training loss of BDIA-ViT is higher, as indicated in Fig. 7, its validation accuracy is better than those of
the other two methods (see Fig. 4). The above property can be explained by the fact that BDIA trains an ensemble of ViT
models using different ODE solvers and thus can be viewed as a complimentary regularization technique to dropout.

                                             0.25
                                                               ViT
                                                               RevViT with online backpropogation
                                              0.2              BDIA-ViT with online backpropogation
                              taining loss




                                             0.15


                                              0.1


                                             0.05


                                               0
                                                    50   100          150     200     250      300
                                                                 time (min)

Figure 7. Training time comparison of ViT, RevViT with online backpropagation (Mangalam et al., 2023), and BDIA-ViT with online
backpropagation for image classification over CIFAR10. Each training curve corresponds to 400 training epochs. Note that the BDIA
technique can outperform in validation accuracy even when the training loss is higher, as seen in Fig. 4.


E. Evaluation of Joint Impact of LoRA and BDIA
It has become common practice to adopt the LoRA adapter when fine-tuning an LLM with either small or intermediate data
sizes. One major advantage of using LoRA is that it accelerates the training process with limited computational resources as
it requires only a relatively small number of parameters to be trained. Since the original LLM model parameters are kept
frozen throughout the process, the knowledge learned in the pre-training is less likely to be forgotten. On the other hand, it
has been reported in the literature that, even with the LoRA approach, overfitting can still occur (Lin et al., 2024).
We performed an additional experiment studying the joint impact of LoRA and BDIA when fine-tuning GPT2 M for NLG.
Since the validation performance is our primary concern, the LoRA+BDIA training procedure was implemented without
online back-propagation and quantization. Differently from Subsection 5.1, {γk }K−1
                                                                                k=1 in the LoRA+BDIA procedure were
randomly drawn from {0.5, 0, −0.5} per training sample.
Next we briefly discuss the setup for LoRA’s α parameter in the LoRA+BDIA procedure. In order for the BDIA approach to
have a significant effect on the performance, it is recommended to use large values for the α parameter. This is because
a large α value in LoRA resembles the full fine-tuning scenario to a certain extent. It is known from the main paper that
BDIA is designed to average every two consecutive integration approximations in a random manner via {γk }K−1k=1 . A large
α parameter allows the averaging operations in BDIA to have a substantial effect. In the experiment, we tested a range of
configurations with α ∈ {512, 1024} and LoRA rank ∈ {32, 128}.
Fig. 8 visualizes the training and validation performance for both LoRA and LoRA+BDIA. Similarly to the results in the
main paper, the training loss of LoRA+BDIA is higher than that of LoRA alone due to the regularization effect of BDIA. On
the other hand, the validation loss of LoRA+BDIA is lower than that of LoRA at the end of training, which is consistent
with our expectation.
Table 6 summarizes the quality of the generated texts for four training setups evaluated with five different metrics. It is clear

                                                                     13
                             On Exact Bit-level Reversible Transformers Without Changing Architecture




                                                    LoRA                               1.25                                      LoRA
                                                    LoRA+BDIA                                                                    LoRA+BDIA
                 2.6
    train loss




                                                                            val loss
                                                                                        1.2

                 2.4
                                                                                       1.15

                 2.2                                                                    1.1
                       0.5     1         1.5          2          2.5                             0.5          1            1.5     2    2.5
                                                                      4
                                   iterations                    10                                               iterations            10 4




                 2.7                                LoRA                               1.25                                      LoRA
                                                    LoRA+BDIA                                                                    LoRA+BDIA
                 2.6
    train loss




                                                                            val loss


                                                                                        1.2
                 2.5

                 2.4                                                                   1.15

                 2.3
                                                                                        1.1
                       0.5     1         1.5          2          2.5                             0.5          1            1.5     2    2.5
                                   iterations                         4                                           iterations                 4
                                                                 10                                                                     10
Figure 8. Performance comparison of LoRA nad LoRA+BDIA when fine-tuning GPT2 Medium for the E2E challenge. {γk }K−1
                                                                                                                k=1 in the
BDIA training procedure were randomly drawn from {0.5, 0, −0.5} per training sample.


Table 6. Performance of LoRA and LoRA+BDIA for fine-tuning GPT-2 medium (M) on the E2E NLG Challenge. For all metrics, higher
                K−1
is better. {γk }k=1 in the BDIA training procedure were randomly drawn from {0.5, 0, −0.5} per training sample.

                                                       Method             BLEU         NIST   MET    ROUGE-L       CIDEr
                                                          LoRA                                46.8
                                               
                                    rank = 32                             68.8         8.66            71.6         2.46
                                    α = 1024          LoRA+BDIA           69.9         8.79   46.7     71.9         2.53

                                                          LoRA
                                               
                                   rank = 128                             68.0         8.58   46.1     70.9         2.49
                                    α = 512           LoRA+BDIA           69.0         8.70   46.5     71.5         2.52




that for all tested scenarios, the LoRA+BDIA training procedure outperforms the LoRA procedure for almost all metrics.
This suggests that the BDIA training approach can help LoRA in fine-tuning transformer-based LLMs.

F. On Training BDIA-GPT2
In this experiment, we train BDIA-GPT2 on the openwebtext dataset utilizing the 4th github link of Table 7. Our primary
objective for this task is to find out if BDIA can help to alleviate the over-fitting issue of GPT2 (we omit the phase “nano”
for simplicity) for a very small training dataset. In doing so, we only took a small (i.e., 0.05%) subset from the entire dataset

                                                                          14
                         On Exact Bit-level Reversible Transformers Without Changing Architecture

when training the model. The performance of GPT2 was evaluated as a reference. Both models have 12 transformer blocks.
We did not perform hyperparameter exploration and it is possible that the performance of BDIA-GPT2 would improve with
such exploration.
Fig. 9 shows the training and validation curves for the two models. Similarly to Fig.4-5, BDIA-GPT2 exhibits a slower
training speed than GPT2. Considering the validation performance, the two validation curves for the two models exhibit the
over-fitting issue. GPT2 produces the lower validation loss in the middle of the training. However, at the end of training, the
validation loss of BDIA-GPT2 is significantly lower than that of GPT2. This demonstrates that BDIA indeed alleviates the
over-fitting issue of GPT2 for a very small training dataset.
                                                  12                                                 11
                                                                           GPT2                                               GPT2
                                                                           BDIA-GPT2                                          BDIA-GPT2
                                                  10                                                 10

                                                  8
                                   taining loss


                                                                                                     9




                                                                                         val. loss
                                                  6
                                                                                                     8

                                                  4
                                                                                                     7
                                                  2
                                                                                                     6
                                                  0
                                                       0   5000     10000       15000                     0   5000     10000       15000
                                                              iterations                                         iterations

Figure 9. Performance comparison when training GPT2. {γk }K−1
                                                          k=1 in the training procedure of BDIA-ViT were randomly drawn from
{±0.5} per training sample.

G. Repositories in the Experiments

                                   Table 7. Repositories being used in the experiments
 image classification   https://github.com/kentaroy47/vision-transformers-cifar10
   natural language
                        https://github.com/microsoft/LoRA/tree/main/examples/NLG
  generation (NLG)
 language translation   https://debuggercafe.com/language-translation-using-pytorch-transformer/
      nanoGPT           https://github.com/karpathy/nanoGPT




                                                                                        15
