Organizations: University of São Paulo∗ · ∗Instituto de Ciências Matemáticas e de Computação (ICMC), University of São Paulo. · São Paulo State University
We introduce a parallelizable simplification of Neural Turing Machine (NTM), referred to as P-NTM, which redesigns the core operations of the original architecture to enable efficient scan-based parallel execution. We evaluate the proposed architecture on a synthetic benchmark of algorithmic problems involving state tracking, memorization, and basic arithmetic, solved via autoregressive decoding. We compare it against a revisited stable implementation of the standard NTM, as well as conventional recurrent and attention-based architectures. Results show that, despite its simplifications, the proposed model attains length generalization performance comparable to the original, learning to solve all problems, including unseen sequence lengths, with perfect accuracy. It also improves training efficiency, with parallel execution of P-NTM being up to an order of magnitude faster than the standard NTM. Ultimately, this work contributes toward the development of efficient neural architectures capable of expressing a broad class of algorithms.
Figures & tables
Figure 1: Illustration of the NTM architecture. Adapted from Graves et al. (2014) .
Figure 2: Illustration of the parallel computation of P-NTM.
Task
Example Input
Example Output
Parity Check (PC)
aaabba
010001
Cycle Navigation (CN)
siidis
012122
Reverse String (RS)
aabba
abbaa
Duplicate String (DS)
aabba
aabbaaabba
Modular Arithmetic (MA)
1+2−4
+10+21−434
Binary Addition (BA)
01101+101
11011
Table 1: Algorithmic tasks with input and output examples. Final answers are underlined. Detailed descriptions of each task are provided in Appendix A .
Architecture
PC
CN
RS
DS
MA
BA
LSTM
0.09
0.04
0.14
0.09
0.06
0.12
minGRU
0.07
0.04
0.09
0.09
0.08
0.10
Transformer
0.27
0.56
0.21
0.65
0.42
0.22
NTM
1.00
1.00
1.00
1.00
1.00
1.00
P-NTM
1.00
1.00
1.00
1.00
1.00
1.00
Table 2: Maximum exact match accuracy scores across runs for each architecture and task on problems of unseen length ( ℓ=41 to ℓ=120 ). Perfect scores are highlighted in bold.
Figure 3: Exact match accuracy scores across runs for different architectures and tasks on problems of unseen length ( ℓ=41 to ℓ=120 ).
Figure 4: Speedup of P-NTM sequential and parallel execution relative to the standard NTM execution across input batches of varying sequence lengths.
Appendix figures & tables7 assets
Supplementary material from the paper’s appendix.
Appendix
Figure 5: High-level structure shared by all evaluated models. An encoder maps input tokens to embeddings, a sequence-processing module transforms them, and a decoder produces vocabulary logits.
Figure 6: Residual block structure used by the minGRU, Transformer, and P-NTM models. Each block applies a sequence-wise sublayer (self-attention, minGRU, or P-NTM layer) over the full sequence, followed by a position-wise feedforward network. Both sublayers use pre-normalization and residual connections. LSTM and NTM architectures do not adopt this structure.
Architecture
Hidden Size
Depth
Heads
Cell Size
Parameters
LSTM
192
—
—
—
∼ 298 K
minGRU
64
5
—
—
∼ 289 K
Transformer (NoPE)
64
5
8
—
∼ 248 K
Transformer (ALiBi)
64
5
8
—
∼ 248 K
Transformer (RoPE)
64
5
8
—
∼ 248 K
Transformer (FIRE)
64
5
8
—
∼ 249 K
Appendix
Table 3: Hyperparameters and parameter counts for all evaluated models. Dashes (—) indicate the hyperparameter is not applicable to that specific architecture.
Pos. Encoding
PC
CN
RS
DS
MA
BA
NoPE
0.16
0.19
0.18
0.24
0.19
0.22
RoPE
0.06
0.07
0.05
0.05
0.04
0.06
ALiBi
0.27
0.56
0.21
0.65
0.38
0.20
FIRE
0.23
0.44
0.19
0.28
0.42
0.19
Appendix
Table 4: Maximum exact match accuracy scores across runs for each task and Transformer positional encoding scheme. Best results boldfaced.
Figure 7: Exact match accuracy across varying input lengths for NTM and P-NTM. Each curve represents a separate run on a specific task, with the shaded area indicating the training distribution ( ℓ=1 to ℓ=40 ). While NTM generally maintains non-zero accuracy at extended lengths, P-NTM exhibits a sharp performance degradation, frequently dropping to zero accuracy for longer inputs.
Input Length
NTM
P-NTM (Sequential)
P-NTM (Parallel)
23=8
0.0011±0.0000
0.0007±0.0000
0.0003±0.0000
24=16
0.0019±0.0001
0.0012±0.0000
0.0004±0.0000
25=32
0.0035±0.0000
0.0023±0.0000
0.0005±0.0000
26=64
0.0068±0.0001
0.0043±0.0000
0.0006±0.0000
27=128
0.0128±0.0000
0.0083±0.0000
0.0011±0.0001
28=256
0.0209±0.0003
0.0164±0.0000
0.0017±0.0002
Appendix
Table 5: Mean execution time ( ± standard deviation), measured in seconds, across batches of input sequences of varying lengths for NTM and P-NTM. The P-NTM results include both sequential and parallel execution.
Figure 8: Memory interaction patterns of the heads of a trained P-NTM on a parity check sequence. The top row displays write heads , and the bottom row displays read heads . For each head, the upper panel visualizes addressing weights across memory locations over time, while the lower strip shows the read or write vector at each timestep (normalized per head). Write Head 4 and Read Head 4 exhibit the sharpest addressing weights.
College of Pharmacy Chungnam National University Daejeon, South Korea · Department of Computer Science & Engineering Chungnam National University Daejeon, South Korea