Skip to content
sophtangPublic

About

Official Code for Discrete Beckmann Transport Models for One-Step Language Modeling and Reasoning

Topics

Resources

Stars

16 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

Discrete Beckmann Transport Models
for One-Step Language Modeling and Reasoning

Sophia Tang1,†, Shiyi Wang2,3,4
1 University of Pennsylvania · 2 Harvard University · 3 Kempner Institute · 4 IAIFI
† Work done while a visiting researcher at Harvard University.

arXiv 2609.15903 alphaXiv Project Page Hugging Face Model Weights Blog Talk

Discrete Beckmann Transport Models overview and OpenWebText generation frontiers

Setup · Checkpoints · Training · Inference

News

TL;DR

DBTM learns a time-independent transport map that can turn noise into discrete tokens in one network function evaluation (NFE). With more evaluations, the sampler commits confident tokens, re-noises the remaining positions, and reapplies the same map. Refinement-in-loop training (RIL) trains the map on states like those encountered during this process.

Setup

Run these commands from the repository root for DBTM and TinyGSM. FlashAttention requires a compatible NVIDIA GPU, such as Ampere or Hopper. If it builds from source, make sure a C++ compiler and the CUDA toolkit matching your PyTorch build are available, with nvcc on your path. See the FlashAttention installation guide.

conda create -n dbtm python=3.11 -y && conda activate dbtm
pip install -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cu129
pip install packaging psutil ninja
pip install flash-attn==2.8.3.post1 --no-build-isolation

For the FLM/FMLM FLOP counter, also run pip install entmax. The FMLM+ case requires a Posterior Refinement checkout and POSTERIOR_REFINEMENT_ROOT set to its path.

Pretrained Checkpoints

The Hugging Face model repository provides the main DBTM and DBTM + RIL inference weights. Download the checkpoints to the Git-ignored checkpoints/ directory.

hf download sophtang/DBTM --include '*.ckpt' --local-dir checkpoints

Language results are paper Gen-PPL (entropy). Reasoning results are exact-solve accuracy on Sudoku and final-answer accuracy on GSM8K.

Dataset Experiment Checkpoint Training step Result
LM1B lm1b lm1b_dit_dbtm.ckpt 175,000 119.99 (4.20) at 4 NFEs
LM1B lm1b_ril lm1b_dit_dbtm_ril.ckpt 200,000 73.54 (4.04) at 4 NFEs
OpenWebText owt_attn owt_dit_dbtm.ckpt 110,000 123.1 (5.18) at 4 NFEs
OpenWebText owt_attn_ril owt_dit_dbtm_ril.ckpt 40,000 RIL 115.5 (5.42) at 4 NFEs
OpenWebText owt_lin owt_linear_dbtm.ckpt 125,000 52.2 (5.26) at 4 NFEs
OpenWebText owt_lin_ril owt_linear_dbtm_ril.ckpt 45,000 RIL 57.5 (5.52) at 4 NFEs
Sudoku Easy sudoku sudoku_easy_dit_dbtm_ril.ckpt 96,757 99.90% at 16 NFEs
Sudoku Medium sudoku sudoku_medium_dit_dbtm_ril.ckpt 115,306 99.35% at 16 NFEs
Sudoku Hard sudoku sudoku_hard_dit_dbtm_ril.ckpt 142,880 97.30% at 16 NFEs (substitute)
TinyGSM → GSM8K TinyGSM launcher tinygsm_dit_dbtm_ril.ckpt 250,000 RIL 16.76% at 32 NFEs

RIL steps in the table are counted from the start of the fork. The original Sudoku Hard checkpoint at step 132,853 is unavailable. The released step 142,880 solves 1,712/2,000 puzzles at 4 NFEs and 1,946/2,000 at 16 NFEs.

Datasets

Datasets are built on the first run and cached under ./data, or under $DBTM_DATA if set.

experiment dataset tokenizer length
owt_* OpenWebText (last 100k documents held out for validation) GPT-2 1024
lm1b* LM1B bert-base-uncased 128
sudoku 48,000 train and 2,000 held-out puzzles per difficulty, generated with seed 42 12 tokens (empty, digits, row separator, BOS) 180

OpenWebText and LM1B are downloaded from the Hugging Face hub, tokenized, and packed (wrapped) with BOS/EOS separators.

Sudoku puzzles have a unique solution and 40 (easy), 35 (medium) or 30 (hard) clues, chosen with data.difficulty. A sequence is [BOS] puzzle [BOS] solution, and the loss covers the solution only. Each puzzle has its own seed, so data.num_workers=<n> parallelizes generation without changing the puzzles. With one worker, medium and hard together take about 4 hours.

TinyGSM training data is downloaded on the first run. The TinyGSM recipe uses the bundled GSM8K test set and the SmolLM-135M tokenizer.

Inference

dbtm.evaluate samples eval.num_samples sequences at each NFE in eval.rounds. For each NFE it reports Gen-PPL under GPT-2 Large and the mean within-sequence unigram entropy. The seed is reset before every NFE. EMA weights are used unless eval.disable_ema=true. Set eval.output_path to save the language samples and metrics or the per-puzzle Sudoku results.

python -m dbtm.evaluate experiment=owt_lin eval.checkpoint_path="$PWD/checkpoints/owt_linear_dbtm.ckpt" \
  sampling.refinement_threshold=0.3 sampling.repetition_penalty=1.0 sampling.temperature=0.0 \
  eval.num_samples=1024 eval.rounds=[1,2,4,8,16,128,256,1024] eval.output_path=samples.json

Use the same command with owt_lin_ril and owt_linear_dbtm_ril.ckpt for linear RIL, owt_attn and owt_dit_dbtm.ckpt for DiT, or owt_attn_ril and owt_dit_dbtm_ril.ckpt for DiT RIL. See Pretrained Checkpoints for training steps.

The LM1B rows use the following settings for 1, 2, and 4 NFEs. For the full NFE and entropy-frontier sweeps, use the appendix recipes and per-point sampler settings in the paper.

python -m dbtm.evaluate experiment=lm1b eval.checkpoint_path="$PWD/checkpoints/lm1b_dit_dbtm.ckpt" algo.noise_scale=0.6 \
  seed=0 eval.batch_size=128 eval.rounds=[1,2,4] sampling.refinement_threshold=0.9 \
  sampling.repetition_penalty=1.0 sampling.refinement_fresh_noise=true sampling.temperature=0.0

For lm1b_ril, use experiment=lm1b_ril, eval.checkpoint_path="$PWD/checkpoints/lm1b_dit_dbtm_ril.ckpt" and algo.noise_scale=1.0.

For Sudoku, dbtm.evaluate reports exact-solve accuracy over the 2,000 held-out puzzles at each NFE in eval.rounds. The paper used κ = 0.999.

python -m dbtm.evaluate experiment=sudoku data.difficulty=easy \
  eval.checkpoint_path="$PWD/checkpoints/sudoku_easy_dit_dbtm_ril.ckpt" \
  seed=0 sampling.refinement_threshold=0.999 eval.rounds=[4,16]

For Medium, use data.difficulty=medium and checkpoints/sudoku_medium_dit_dbtm_ril.ckpt. For a Hard rerun, use data.difficulty=hard and checkpoints/sudoku_hard_dit_dbtm_ril.ckpt. This later checkpoint scores 85.60% and 97.30% at 4 and 16 NFEs. The original paper checkpoint was step 132,853.

For the GSM8K main-table result, run the following from the repository root. Omit ROUNDS=32 to run the full sweep.

ROUNDS=32 bash tinygsm/scripts/eval_phi_atm_tinygsm_nfe.sh

Training

Each language or Sudoku run uses a Hydra experiment.

experiment model objective
owt_lin linear attention (9 gated-delta + 3 attention blocks) DBTM
owt_lin_ril linear attention DBTM + ril
owt_attn DiT (12 attention blocks) DBTM
owt_attn_ril DiT DBTM + ril
lm1b DiT, L=128 DBTM
lm1b_ril DiT, L=128 DBTM + ril, distillation off until 100k steps, then ramped in over 50k
sudoku DiT (512 wide, 8 blocks), L=180 DBTM + ril, one run per data.difficulty
python -m dbtm.train experiment=owt_lin

loader.global_batch_size is split across all visible GPUs. Gradient accumulation is derived from loader.batch_size (per GPU), so a different number of GPUs gives the same effective batch.

For the paper’s OpenWebText RIL recipe, set training.finetune_path to the base checkpoint at step 52,500 for linear attention or 62,500 for DiT.

Each run keeps two checkpoints in checkpoints/:

  • latest.ckpt, rewritten every 2,500 steps
  • best.ckpt: for language, the lowest validation Gen-PPL among checkpoints whose sample entropy clears eval.entropy_gate_threshold; for Sudoku, the highest validation solve accuracy

The LM1B runs also keep <epoch>-<step>.ckpt every 25k steps. The paper checkpoints are step 175k for lm1b and step 200k for lm1b_ril. The Sudoku paper checkpoints are each difficulty's best.ckpt.

The LM1B runs used 2 GPUs and Sudoku used 1. trainer.val_check_interval counts micro-batches, so with another GPU count, rescale it to keep validation every 2,500 (LM1B) or 500 (Sudoku) optimizer steps.

In the Sudoku ril term, each training step runs one refinement chain of algo.ril_rounds=4 rounds. After each round, the cells that agree most with the solution are committed with their true digits and the rest are renoised. The map is trained to complete those states, and the quality head is fit on them.

To resume training, use a full training checkpoint and point Hydra to the original run directory.

python -m dbtm.train experiment=owt_lin hydra.run.dir=/path/to/run checkpointing.resume=true

Logging to Weights & Biases is off by default. Turn it on with wandb=default wandb.entity=YOUR_ENTITY.

TinyGSM uses a base stage and a RIL fork. See the TinyGSM training commands.

Key Arguments

Sampler settings are under sampling., except for the prior scale.

knob meaning
refinement_threshold (κ) commit every token whose confidence is at least κ. A top-k floor also commits enough tokens to finish within the NFE budget.
temperature 0 commits the argmax; >0 samples the committed token
repetition_penalty divides a token's probability by (1 + times already committed in the sequence)^λ
refinement_fresh_noise renoise uncommitted positions with fresh Gaussian noise each round
quality_refinement rank commits by the learned quality head q_φ instead of the softmax peak
algo.noise_scale (σ) prior scale of the Gaussian latent

Results

Gen-PPL (GPT-2 Large, lower is better) and entropy (higher is better), from 1,024 samples, with NFE = refinement rounds.

dataset model NFE 1 NFE 2 NFE 4
LM1B DBTM 201.20 (4.03) 167.05 (4.19) 119.99 (4.20)
LM1B DBTM + ril 85.50 (3.92) 81.00 (4.05) 73.54 (4.04)
OWT DBTM (lin) 188.2 (4.97) 76.2 (5.14) 52.2 (5.26)
OWT DBTM + ril (lin) 65.2 (4.95) 62.2 (5.38) 57.5 (5.52)
OWT DBTM (attn) 249.8 (4.77) 156.3 (5.06) 123.1 (5.18)
OWT DBTM + ril (attn) 133.0 (4.94) 109.6 (5.24) 115.5 (5.42)

Paper Sudoku exact-solve accuracy (%) on the 2,000 held-out puzzles at κ = 0.999.

NFE easy medium hard
4 99.50 97.30 84.60
16 99.90 99.35 97.45

On GSM8K, DBTM + RIL solves 11/1,319 questions at 1 NFE and 221/1,319 at 32 NFEs (0.83% and 16.76%).

OpenWebText rerun

Ran the four main checkpoints on A100 with PyTorch 2.6.0 and Transformers 4.50.3. Each run used the release evaluator, 1,024 samples, seed 1, generation batch size 16, threshold 0.3, temperature 0, repetition penalty 1, fresh noise, and GPT-2 Large.

Backbone 1 NFE 2 NFEs 4 NFEs
DiT 248.88 (4.772) 156.05 (5.062) 122.53 (5.171)
DiT + RIL 133.01 (4.930) 110.94 (5.238) 116.29 (5.423)
Linear attention 186.80 (4.965) 76.50 (5.134) 52.36 (5.261)
Linear attention + RIL 64.90 (4.949) 62.03 (5.380) 57.41 (5.521)

Cells report Gen-PPL (entropy). Across the 12 main-table cells, the maximum relative Gen-PPL deviation from the paper is 1.22% and the maximum entropy deviation is 0.010. The DiT one-step check gave Gen-PPL 249.26 at batch size 8, 248.88 at 16, and 250.06 at 32. At a fixed batch size of 16 or 32, the same DiT check produced identical samples and scores under PyTorch 2.11.0 with Transformers 4.55.4.

Release Scope

  • dbtm/ holds the shared evaluator and trainer for LM1B, OpenWebText, and Sudoku.
  • tinygsm/ holds the conditional program-generation recipe, including prompt masking, TinyGSM tokenization, and answer scoring. It preserves the trainer and checkpoint layout used for the published GSM8K result.
  • ablations/ holds revised-paper diagnostics and experimental trainers. Some recipes require archived checkpoints, raw sweeps, or external baselines.
  • Full-paper reproduction also requires the original Sudoku Hard snapshot, the simplex attractor figure generation code, and the verifier-guided GSM8K post-training recipe and weights. The supplied GSM8K checkpoint covers the main result before post-training.

Citation

@article{tang2026discrete,
  title={Discrete Beckmann Transport Models for One-Step Language Modeling and Reasoning},
  author={Sophia Tang and Shiyi Wang},
  journal={arXiv preprint arXiv:2609.15903},
  year={2026},
  url={https://arxiv.org/abs/2609.15903}
}

Acknowledgements

License

The DBTM code and model weights are licensed under Apache 2.0. The adapted TVM kernels are covered by CC BY-NC-SA 4.0. See NOTICE for upstream attributions.

About

Official Code for Discrete Beckmann Transport Models for One-Step Language Modeling and Reasoning

Topics

Resources

Stars

16 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages