cross-prime-v1 β€” Modular Arithmetic Challenge

A compliant submission to the SAIR Modular Arithmetic Challenge: a neural network that learns to compute (a Β· b) mod p for a prime p and integers a, b that may be far larger than p.

Team MCSC (MAC01-T00008).

What it is

A prime-conditioned joint Transformer encoder (~3.2M parameters). The digits of a mod p, b mod p, and p are tokenized (base-10, fixed width 5, with learned token / position / segment embeddings) and a 6-layer encoder attends over all three operands jointly, reading out the answer as 5 base-10 digits via per-position linear heads.

It deliberately does not use the discrete-log / additive bottleneck of the reference dlp_grokking model β€” whose own ablation showed that bias is not the limiting factor; the wall is generalizing across primes. This model instead lets attention learn the field operation directly, conditioned on p.

Results (official pipeline, public benchmark, 100 problems/tier)

Tier p bits this model dlp_grokking (best reference)
1 1–3 1.00 1.00
2 4–8 0.35 0.12
3–10 9–2048 ~0.02 ~0.02
overall_accuracy 0.150 0.127
highest_tier_above_90 1 1

Beats the strongest shipped baseline on overall_accuracy; tier 2 ~3Γ—. Scores identically on CPU and MPS (deterministic), and runs the full 1100-problem set in ~35s (budget: 5 min).

How it stays compliant

The answer comes from trained parameters, not a hand-coded algorithm (SAIR rules/evaluation.md, Principle 2 β€” perturbing the weights collapses accuracy):

  • preprocess_{a,b,p} are pure per-argument identities (no cross-argument leakage).
  • predict_digits reduces a % p and b % p (two operands at a time β€” the same legal normalization the reference baselines use) and never forms a Β· b, never computes (aΒ·b) % p, and uses no lookup table. The network argmax is the answer.
  • No sympy / gmpy2 / Barrett / CRT in the forward path. For p β‰₯ 10⁡ (outside the trained width) it emits a constant 0 β€” an honest out-of-regime fallback, not an answer shortcut.

Files

  • model.py β€” architecture + the ModularMultiplicationModel entry class.
  • manifest.json β€” entry class, output_base = 10, required descriptions.
  • weights.pt β€” {state_dict, config}.

Limitations

Tiers 3+ (thousands of distinct primes) sit near the floor: the model memorizes the per-prime multiplication tables it was trained on but does not yet generalize the operation to unseen primes β€” the open problem at the heart of the challenge. A reciprocal/learned-Barrett variant is under development to attack exactly that.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support