Carry Memory Lab Exposes Why Bit Accuracy Can Hide Integer Addition Failures

Carry Memory Lab · Machine Learning: Carry Memory Lab reveals high bit accuracy can mask total calculation failures.

A newly released project called Carry Memory Lab examines how recurrent neural networks learn integer addition, uncovering critical blind spots in standard evaluation metrics. Developed by Renchao Wu and published under the Apache 2.0 license, the release provides synthetic data, model weights, and evaluation scripts from a frozen training batch. According to the project documentation, the network features a compact architecture consisting of 106 parameters, including two input bits, eight tanh hidden coordinates, an 8×8 recurrent matrix, and two softmax outputs. Trained on operands across widths 1 through 6, the model processes numbers least significant bit first to study how internal memory handles mathematical carries.

Recurrent Versus Reset Inference Modes

To test the network's reliance on memory, the evaluation compares two inference modes using the exact same trained weights. Recurrent mode passes the accumulated hidden state from step to step, whereas reset mode clears the hidden state to zero before every input bit without altering the model weights. Using a default held-out pair of 1 and 15 at width 6, the study highlights how divergence occurs between the two approaches. While recurrent mode correctly predicts 16 across all output positions, reset mode predicts 14 and fails at intermediate positions corresponding to carry operations. Because reset mode lacks the prior hidden state, it stumbles on positions where the exact incoming carry dictates a specific target bit, demonstrating that recurrence is essential for this configuration rather than relying solely on local operand values.

Why Padding Skews Evaluation Metrics

The investigation exposes a significant evaluation pitfall: high bit-level accuracy can easily mask complete failures in whole-number arithmetic. When the same 1 and 15 operands are padded to width 64 with high leading zeros, the underlying integer value remains identical, but the metric landscape shifts dramatically. Recurrent mode continues to score perfectly, but reset mode achieves a misleading 96.01 percent bit accuracy while its integer accuracy remains entirely stagnant. This discrepancy occurs because the denominator for bit accuracy includes every added leading-zero step and the terminal step. Since leading zeros consisting of zero-zero inputs with no incoming carry are trivial for the network to output correctly, padding artificially inflates the overall score. Across a complete inventory of 64,856 unique cases, reset mode fails on 58,566 integer sums despite maintaining a seemingly acceptable bit score of nearly 60 percent. For engineers and researchers building arithmetic models, this finding serves as a warning against relying on aggregate bit metrics alone. A model can pass a high percentage of individual bit evaluations while completely failing to compute valid whole-number results, highlighting the necessity of strict integer-level verification when assessing numerical competence in machine learning systems.

Verification and Artifacts

Researchers can audit the findings using the provided static app bundle and verification scripts. The project includes a Python 3 script that reads compressed JSON predictions and evaluation results directly from fixed repository paths without writing local files. Additionally, an interactive browser demo hosted on Hugging Face Spaces allows users to test canonical decimal strings from 0 up to 2 to the 64th power minus 1 across widths 1 through 64. The author notes that while these tools provide transparent access to saved model states and outputs, real-world numerical calculations should always rely on exact integer arithmetic rather than neural approximations.

Editorial graphic and headline text by Signal Titans.

Source: Why bit accuracy can hide a wrong sum · Why bit accuracy can hide a wrong sum

Share this article
FacebookThreadsLinkedInX

Leave a Reply

Your email address will not be published. Required fields are marked *