Skip to main content
Change of provenance

The repository or configuration that created this release differ from a previous release. View details.

ParticleGAN

ParticleGAN — conceptual artwork of luminous particles flowing into distinct clusters

Tests

GANs with a learnable particle prior, for PyTorch.

A GAN usually draws its latent code from a fixed Gaussian. ParticleGAN replaces that noise with a table of learnable latent vectors (particles), optimized together with the generator, so that the prior itself can move toward the data's modes. You write an ordinary PyTorch GAN loop, or call GANTrainer, and a recipe builds the optimizers, critic penalty and prior regularizer.

Install

Requires Python 3.11+. PyTorch and NumPy are installed as dependencies.

python -m pip install particlegan           # the library (0.10.0)

To run the examples, experiments and tests, install from source with the extras you need:

git clone https://github.com/255BITS/ParticleGAN.git
cd ParticleGAN
python -m pip install -e '.[dev,experiments]'   # tests plus examples/experiments (the toy100 CI job)
python -m pip install -e '.[dev,experiments,images,lunar]'   # what the main CI test job installs
Extra Adds Needed for
dev pytest the test suite
experiments NumPy, Matplotlib, Pillow, PyYAML, POT, SciPy examples, python -m experiments.forge and the toy benchmarks
images torchvision, Pillow, torch-fidelity, SciPy <1.18, tqdm CIFAR and other image experiments, FID
mog SciPy faster exact nearest-neighbour calibration of mixture-of-Gaussians priors (falls back to Torch without it)
gym Gymnasium with Box2D Gym control experiments
lunar the gym extra plus rich, Pillow and imageio the Lunar Lander world model and controllers

Version pins live in pyproject.toml. For CUDA, install a torch/torchvision build that matches your driver before installing the extras.

Train a GAN

You supply ordinary PyTorch modules. GANTrainer binds the recipe's optimizers, critic penalty and prior regularizer:

import torch
from torch import nn
from particlegan import GANTrainer, get_recipe, init

def real_batch(n):  # replace with your DataLoader: 8 Gaussians on a ring
    angle = torch.randint(8, (n, 1)) * torch.pi / 4
    return torch.cat([angle.cos(), angle.sin()], 1) + 0.05 * torch.randn(n, 2)

recipe = get_recipe(total_steps=2000)
G = nn.Sequential(nn.Linear(recipe.z_dim, 128), nn.LeakyReLU(0.2), nn.Linear(128, 2))
D = nn.Sequential(nn.Linear(2, 128), nn.LeakyReLU(0.2), nn.Linear(128, 1))
init.deterministic_orthogonal_(G, seed=0)
init.deterministic_orthogonal_(D, seed=1)
prior = init.deterministic_orthogonal_(recipe.make_prior())
trainer = GANTrainer(recipe, G, D, prior=prior, seed=0)
for _ in range(recipe.total_steps):
    trainer.step(real_batch(recipe.batch_size))
samples = trainer.sample(1024)

get_recipe() returns the default recipe, RHBI (Relativistic Hellinger-Born-Infeld Transport, DEFAULT_RECIPE = "rhbi_optimized" in particlegan/recipes.py). It pairs debiased slack-screened Kantorovich-Hellinger Sinkhorn generator transport (RHBIGANLoss) with a Weyl-phased balanced Born-Infeld geodesic chord and thermal-settling critic penalty (RHBICriticPenalty), SBNP particle prior regularization (prior_reg = 0.02), and zero-momentum DualNorm (polar_cpu_v1, native SVD, float32) at constant rates. Explicit get_recipe("empf"), get_recipe("rhbi") and get_recipe("bispf_optimized") retain earlier named presets. The acronyms are expanded in the research glossary, and the recipe settings and evidence explain the configuration.

Without prior=, the trainer builds a randomly drawn particle table. Networks and device placement belong to the caller. The trainer does not reinitialize supplied modules, so load pretrained weights before constructing it and initialize only fresh parameters. Optimizers exclude frozen parameters while retaining gradients through frozen modules to trainable inputs.

Caller-owned loops use the recipe's role-named factories, including make_optimizers, make_critic_penalty and make_prior_regularizer. Save the resolved recipe.to_dict() and the complete trainer.state_dict() for continuation; restore the recipe with Recipe.from_dict(saved_fields). Changing the current default does not migrate an old run. Bare or partial Recipe(...) calls raise an error: use get_recipe() to select the current public recipe for new runs. See the API reference for component ownership and optimizer contracts.

For categorical data and wide continuous feature vectors, see the BISPF input-domain walkthrough. It includes a checked numerical example and a runnable four-category GAN with training GIF, quality metrics and checkpoint continuation.

Results and status

The single current status page is the technique inventory. It shows every recipe family against the same declared tests, failures included, with links to gates, metrics, receipts and training GIFs. Other report pages are historical records.

What the evidence does and does not show today:

  • The default is a research selection, not a qualified winner. In the technique inventory, the selected RHBI recipe (rhbi-v12, DEFAULT_RECIPE = "rhbi_optimized") ties empf (empf-v8) at 83/115 counted view requirements (27/27 Tier 1 PASS, 56/78 Tier 2 with 2 not run, 0/10 Tier 3 with 10 not run) while leading on the 64-test fixed suite at 33 PASS, 7 FAIL, 8 not measured and 16 blocked (vs empf's 23/64 PASS, 17 FAIL, 8 not measured and 16 blocked) and on stretch view assignments at 35/63 (vs empf's 0/63), ahead of bispf_optimized at 81/115 and 18/64. Forge's screening calibration (BLOCKED), Tier 2/3 full-tier gates and untouched holdout confirmation remain open.

  • Controlled prior comparison (matched prior ablation, 2026-10-25). Each arm changes only the prior policy. Architecture, data, budget, seed 0 and the initial table are the same. These are one-seed diagnostics with no qualification credit.

    Prior Toy tests passed (15 graded in all arms) Ring16 high-quality fraction CIFAR-10 DDGAN FID50k ↓
    Learned particle table (default) 7 0.95 79.7
    Frozen table 5 0.61 108.5*
    Fresh N(0, I) latent 5 0.53 82.7

    * Final checkpoint only; the same run scored 80.8 FID5k at step 7500, so this is most likely a bad excursion. All FIDs are single point estimates.

    On the toy suite the learned table buys sample precision at seed 0: it alone passes ring16_acquisition and mode_hold (2 of the 15 matched tests, both at a +0.00 margin with no recorded noise floor). The fixed priors cover the 100-mode grids more evenly but less precisely, and every arm fails those grids. On CIFAR the gaps are inside the run's own checkpoint-to-checkpoint and rerun noise (up to 9.4 FID5k between same-config reruns), so no image-scale prior effect is established.

  • BISPF shape/step-gate ablation (bispf_shape_gates=False). In the same 2026-10-25 ablation study (Arm A4, bispf-pure-global-v1), disabling all 10 shape/step gates in BISPFGates drops full-suite passes from 19/49 to 13/49 (and from 7/15 to 5/15 on the matched sampled-latent subset), losing ring16_acquisition (reaches hq = 0.958 at the endpoint but only 2/5 consecutive stable checks), mode_hold (7/8 modes), ring_extension and img_stripes2. For wide continuous vectors (dim >= 170) where only the automatic categorical simplex heuristic is unwanted, pass penalty_options={"input_domain": "continuous"} to GANTrainer (or recipe.make_critic_penalty(opt_d, input_domain="continuous")) as documented in BISPF input domains.

  • Headline numbers below are single runs without error bars, unless a linked report says otherwise.

The 100-Gaussian animations

These three animations use different historical or opt-in recipes rather than the current rhbi_optimized default.

Animation Recipe What it shows Pass/fail metric Result
100gaussians.gif Archived 0.9.0 default (get_recipe("bispf_optimized", optimizer_svd_backend="native", training_precision="float32")). 100-Gaussian grid, public deterministic initialization, protocol seed 0, 20,000 updates. All 100 modes with ≥10 samples within 3σ, and hq (share of samples within 3σ) ≥ 0.95, at each of 5 terminal checks. FAIL: 100/100 modes, but hq 42.1% (receipt)
stripes GIF Archived 0.9.1 default (get_recipe("bispf_optimized"), batched SVD, BF16/channels-last) Fixed 600-update img_stripes2 image task The task's declared Forge gate, including all required modes PASS (readout)
E22 GIF Not the default. Opt-in preset get_recipe("e22", ...) with an identity nn.Linear(2, 2) generator, a 20,000-row table, batch 2,048 and seed 1234 Grid, rotated and staggered 100-Gaussian layouts, 7,000 updates each Native gates: worst live precision over the last 5 checks ≥ 0.97 and worst centre error ≤ 0.20σ PASS on all three layouts (precision .9822–.9851); the animation draws reach hq 98.3–98.6% (E22 results, animation). In the Forge suite, E22 is 0/115: its policy cohort is blocked or incompatible with the current task definitions.

Archived 0.9.0 default on the 100-Gaussian grid: particle outputs, target modes and numerical learning curves (FAIL: hq 42.1% < 95%)

Actual training of the 0.9.1 BISPF default on the stripes task, with numerical quality observations (PASS)

E22 (not the default) on the grid, rotated and staggered 100-Gaussian problems

The E22 run uses a different generator, table size, batch and seed, so it is not a matched comparison with the default's animation.

Releases, Forge and throughput

Running experiments or proposing ideas: start with ParticleGAN Forge — read before running ideas. The research attempt catalog lists source-bound results, reusable lessons, failures and publication links. The experiments by tier page shows goals and training GIFs. The experiment memory explains the hypotheses, comparisons and recommendations behind the recorded results. These views are regenerated as experiments change. Release selection requires completed Forge qualification and review of the winner. The 0.10 Forge requirements make accurate acquisition, settling, endurance and recovery required again.

Changing the default. A promotion changes one line in particlegan/recipes.py: DEFAULT_RECIPE = "rhbi_optimized". All model-family factories inherit that trainer preset. Explicit presets such as get_recipe("empf"), get_recipe("rhbi"), get_recipe("bispf_optimized") and get_recipe("ka2") remain available. This is the owner-selected research default; Forge calibration remains provisional (BLOCKED), Tier 2/3 qualification is incomplete, and untouched holdout confirmation remains open.

0.9.1 throughput. Version 0.9.1 made the faster BISPF execution policy the default, and kept explicit historical settings and saved-recipe restoration (see the changelog for compatibility limits). Batched convolution updates and BF16/channels-last training accelerate supported CUDA image networks. Weights, optimizer arithmetic and sampling stay FP32. CPU and nonconvolutional networks keep their previous execution. The throughput readout preserves 19 passing and 11 failing task verdicts. It measures 2.15× faster 256×256 DCGAN updates and about 2.3× faster small image updates than 0.9.0. Across all six DCGAN workloads, speedups range from 1.02× to 2.15×. These results do not establish natural-image convergence or a universal architecture guarantee.

Repeatable initialization

The recipe never touches your weights: networks train from whatever they are built with. particlegan.init is optional tooling in the spirit of torch.nn.init, and the examples use it:

from particlegan import init

init.deterministic_orthogonal_(G, seed=0)   # G, D and an encoder get different seeds
init.deterministic_orthogonal_(D, seed=1)
prior = init.deterministic_orthogonal_(recipe.make_prior())

It writes orthogonal matrices at PyTorch's default scale, patterned biases and an evenly spread particle table, derived from seed alone: the same seed and architecture give the same weights, and no random state is used. Call it on fresh networks, before loading weights or building optimizers. A custom layer it does not know raises an error until you declare it with init.register. Values depend on each parameter's position in the module you pass, so initialize whole networks: a submodule initialized on its own gets different values. Projects with custom layers can guard this with a one-line test that init.declarations(net) has no None entries (example). See the API reference and the math and architecture guide.

Model families

get_recipe(name) selects a model family or an E22 policy preset.

Name Model
gan (default) GAN with a learnable particle prior
e22 Scalar particle GAN with stationarity control, row evidence, birth/death, learned noise and served averages
e22_routed Conditional dense-bank adaptation with paired row evidence and guarded birth/death
mog GAN with a mixture-of-Gaussians particle prior
ddgan Denoising-diffusion GAN with a UCD (class-conditional) critic
ddgan_mog ddgan with a mixture-of-Gaussians prior
ae_gan Autoencoder GAN: an encoder routes data to particles
vae_gan Variational variant of ae_gan
ae_ddgan Autoencoder denoising-diffusion GAN

Any field can be overridden: get_recipe("mog", total_steps=20_000). For E22, set the task's dimensions and output noise explicitly: get_recipe("e22", num_particles=20_000, z_dim=2, batch_size=2048, output_noise_std=.029). E22Policy exposes the same controls used by GANTrainer for caller-owned backward passes and optimizer steps, with checkpointing and served snapshots. For conditional softmax blends, use get_recipe("e22_routed", ...) with the explicit RoutedRows contract. This adaptation measures the whole conditional forward and validates row moves on separate guard contexts. Frozen BF16 modules can accompany FP32 trainable parameters and tables. Multiple token routing sites can share one bank and controller through the full-model routing contract. Candidate checks rerun the complete model, including downstream sites and the final paired output. RoutedRows(probe_interval=20) schedules expensive row probes separately from per-update gradient evidence and saves its clock in checkpoints. The optional output_error_guard=True bounds clean paired-output MSE on guard contexts; it does not establish repair of the noisy adversarial game. Split rows transport their parent's Adam history at half mass.

Learn more

Citation

@software{particlegan2025,
  author = {Martyn Garcia},
  title = {ParticleGAN: Learnable Priors for Stable GANs},
  year = {2025},
  url = {https://github.com/255BITS/ParticleGAN}
}

License

MIT

Metadata

Release files for particlegan 0.10.0

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

Change of provenance

The repository or configuration that created these release files differ from that of a previous release.

We recommend inspecting the repository and configuration before proceeding. View details.

Source distribution (sdist)

Source distribution for particlegan 0.10.0
File Size Uploaded Provenance Actions
particlegan-0.10.0.tar.gz 410.0 kB With provenance Details for particlegan-0.10.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for particlegan 0.10.0
File Interpreter ABI Platform Actions
particlegan-0.10.0-py3-none-any.whl Python 3 none any Details for particlegan-0.10.0-py3-none-any.whl

Total release size: 857.5 kB

Release files / particlegan-0.10.0.tar.gz

Change of provenance

This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.

We recommend inspecting the repository and configuration before proceeding. View details.

Download URL particlegan-0.10.0.tar.gz
Size 410.0 kB
Tags Source
SHA-256 checksum
How to use checksums
be214a6b130eadea2b22e5bad4eb738d5d78b117555fba015be9f910c37b64a6
BLAKE2b-256 checksum
How to use checksums
0bae3dd8b8e821ea6b59290ebbcb83da8b767995d3ebcfa1e682877496f5a9e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.

Transparency log

Release files / particlegan-0.10.0-py3-none-any.whl

Change of provenance

This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.

We recommend inspecting the repository and configuration before proceeding. View details.

Download URL particlegan-0.10.0-py3-none-any.whl
Size 447.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
135f8507956d5ef70eabf212cf117e2cf94ffb6338d3520adcb813b5b1be2bed
BLAKE2b-256 checksum
How to use checksums
8d262ea4ec3806dd094a6b18f46ad5cd7249ac9156314021bb7997c7febb627b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.

Transparency log

Security for particlegan 0.10.0

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.

Change of provenance

The repository and configuration that created this release differ from a previous release.

While this could reflect a routine change by the project maintainers, it may also indicate that the release files have been compromised.

Select from 2 files

Attestation for particlegan-0.10.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.

Transparency log

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