Skip to main content

Self-Play Pretraining with Zero Data

Implementation of Self-Play Pretraining with Zero Data

Paper review by @hu-po

Install

$ pip install self-play-pretrain-zero-data

Usage

import torch
from self_play_pretrain_zero_data import Brainfuck, SelfPlay, Transformer

executor = Brainfuck()

generator = Transformer(num_tokens = executor.num_tokens, dim = 512, depth = 6)
learner = Transformer(num_tokens = 256 + 1, dim = 512, depth = 6)

self_play = SelfPlay(generator, learner, executor)
self_play(epochs = 10)

torch.save(learner.state_dict(), './learner.pt')

Program Pool

By default the learner trains on programs sampled from the current generator.

The paper (appendix G) mixes three program sources:

  • fresh - sampled from the current generator
  • mutation - an archived program with a small edit
  • replay - an archived program, replayed as is

The archive holds the programs mutation and replay draw from. Passing one turns on all three sources with equal weights:

from self_play_pretrain_zero_data import QualityDiversityArchive

archive = QualityDiversityArchive(executor = executor)

self_play = SelfPlay(
    generator,
    learner,
    executor,
    archive = archive,
    proposals = dict(fresh = 1., mutation = 1., replay = 1.)  # default when an archive is passed
)

Weights control the share of each source, e.g. fresh = 2., mutation = 1., replay = 1. draws twice as many fresh programs. A weight of 0 skips the source.

Custom sources are functions returning programs, wrapped with self_play.program_batch:

import random

def uniform_programs(self_play, num_programs, **generation_kwargs):
    return self_play.program_batch([''.join(random.choice('><+-.,[]') for _ in range(8)) for _ in range(num_programs)])

self_play.proposals = {'fresh': 1., uniform_programs: 1.}

Replication script

Self-play discovers arithmetic, geometric and fibonacci programs from zero data, far above uniform sampling, with the dashboard opening automatically.

$ uv run experiments/replicate_table1.py

Citations

@misc{cowsik2026selfplaypretrainingzerodata,
    title    = {Self-Play Pretraining with Zero Data},
    author   = {Aditya Cowsik and Kfir Dolev and Michael Y. Li and G. Bruno De Luca and Nourya Cohen and Noah D. Goodman and Yoav Levine},
    year     = {2026},
    eprint   = {2609.30063},
    archivePrefix = {arXiv},
    primaryClass = {cs.AI},
    url      = {https://arxiv.org/abs/2609.30063},
}
@software{Morehead_JVP_Flash_Attention_2025,
    author  = {Morehead, Alex},
    doi     = {10.5281/zenodo.17050188},
    license = {MIT},
    month   = {sep},
    title   = {JVP Flash Attention},
    url     = {https://github.com/amorehead/jvp_flash_attention},
    version = {0.14.0},
    year    = {2025}
}
@misc{bloem2025universalpretrainingiteratedrandom,
    title   = {Universal pre-training by iterated random computation},
    author  = {Peter Bloem},
    year    = {2025},
    eprint  = {2506.20057},
    archivePrefix = {arXiv},
    primaryClass = {cs.LG},
    url     = {https://arxiv.org/abs/2506.20057},
}
@misc{lee2026traininglanguagemodelsneural,
    title    = {Training Language Models via Neural Cellular Automata},
    author   = {Dan Lee and Seungwook Han and Akarsh Kumar and Pulkit Agrawal},
    year     = {2026},
    eprint   = {2603.10055},
    archivePrefix = {arXiv},
    primaryClass = {cs.LG},
    url      = {https://arxiv.org/abs/2603.10055},
}

Metadata

Release files for self-play-pretrain-zero-data 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for self-play-pretrain-zero-data 0.1.2
File Size Uploaded Provenance Actions
self_play_pretrain_zero_data-0.1.2.tar.gz 27.4 kB Without provenance Details for self_play_pretrain_zero_data-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for self-play-pretrain-zero-data 0.1.2
File Interpreter ABI Platform Actions
self_play_pretrain_zero_data-0.1.2-py3-none-any.whl Python 3 none any Details for self_play_pretrain_zero_data-0.1.2-py3-none-any.whl

Total release size: 58.7 kB

Release files / self_play_pretrain_zero_data-0.1.2.tar.gz

Download URL self_play_pretrain_zero_data-0.1.2.tar.gz
Size 27.4 kB
Tags Source
SHA-256 checksum
How to use checksums
26ee7c34c58c3a90a37e4291f2e1dad5bc6b774b791bd07f35bca39e40d3017e
BLAKE2b-256 checksum
How to use checksums
cca37b3cc733a1a221812fb72645bc7bd63a6a978c562e5ba8cb27daa7d4fc8d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.17

Release files / self_play_pretrain_zero_data-0.1.2-py3-none-any.whl

Download URL self_play_pretrain_zero_data-0.1.2-py3-none-any.whl
Size 31.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7ce805793c29df509a2d3a988d6b796d578ed2f33d805a3e23de98788bf6c6e9
BLAKE2b-256 checksum
How to use checksums
c6b7edd29a54e2de420f79949f927d97d625d07aefcc13757005621ea4161be3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.17

Security for self-play-pretrain-zero-data 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page