torchtsetlin: Fast, Interpretable Tsetlin Machines for PyTorch
Thambawita et al. in Inference & systems
Can Tsetlin rules learn at GPU speed?
torchtsetlin: Fast, Interpretable Tsetlin Machines for PyTorch
The model is a readable rule voter
- 1
Include or exclude
Each automaton controls whether one Boolean feature or its negation enters a clause.
- 2
Build a clause
Included literals are ANDed, giving a rule that can be inspected directly.
- 3
Vote by class
Matching positive and negative clauses cast signed votes; the highest-vote class is predicted. Evaluation uses bitwise operations and counting.
- 4
Learn by feedback
Reward and penalty shift automaton states; training does not use gradients.
The missing piece was the software boundary
They kept automata in native buffers behind separate APIs, outside PyTorch tensor state.
It uses ordinary PyTorch modules with tensor-buffer automata: .to(device), state_dict() and update(x, y) work in the framework. Variants include weighted, coalesced, regression, convolutional, segmentation and graph machines.
The interface gap is a contribution in its own right.
Batched feedback becomes event counting
- 1
Evaluate from one snapshot
The batch is Booleanized, then clauses and class votes are computed from automata at call start.
- 2
Select and count feedback
Per-example Type I/II feedback selections produce counts of each automaton's transition events.
- 3
Sample transition totals
For each transition type, equal-probability Bernoulli trials sum to a binomial draw instead of serial updates.
- 4
Commit the batch
One commit updates the batch; when it fits one chunk, fused Triton code counts events, samples draws and writes state and include mask.
Batching changes when feedback takes effect
Each example updates the automata immediately, so the next example's votes use that changed state.
All examples use the batch-start state and votes. Margin-based feedback can stack several pushes on an automaton before the commit.
Batch size affects learning fidelity; sequential mode preserves the per-example algorithm.
B7: a faster convolutional MNIST epoch
B7 convolutional weighted MNIST; b100 means batch size 100. RTX 3090 GPU, median seconds/epoch (epochs 2–30), one run.
The timing pattern spans multiple workloads

Each ratio is comparison-library time divided by torchtsetlin's GPU batch time; values above 1 mean torchtsetlin is faster. Training and test-set prediction are shown; B8–B10 include GPU libraries only.
Accuracy mostly matches, with one exception
B4 MNIST; final-epoch accuracy, mean ± SD over five GPU seeds. pyTM-CUDA is the strongest comparator.
Batch size changes accuracy and cost

Batch size vs clauses per class. Left: test accuracy at best validation epoch; right: GPU hours to reach it. Batches 16–64 were most accurate and cheapest across flat, 2-D and 3-D models; one seed per cell.
The speedup has clear boundaries
Large-batch fidelity
Examples share their starting state; larger batches can stack updates before feedback is recalculated and degrade accuracy.
CPU training
Dense tensor operations miss the bit-level tricks of C kernels, so CPU training is slow; B4 CPU inference was fastest among CPU libraries.
One-machine comparison
Cross-library tests used one machine and published settings without tuning; they do not establish performance on other hardware.
Why it matters
- On B7, torchtsetlin's 100-example GPU batch cut epoch time from 9.53 to 3.99 seconds versus pyTM-CUDA.
- Start with 16–64 examples per batch; use sequential feedback when matching the exact online update matters.
- Do these speed and fidelity trade-offs persist on hardware beyond the single machine tested?
11 slides, 3 min
25 Nov 2026