Skip to content

Paper watch: pairing regularization (arXiv:2604.20130) — toy test, partial transfer - #560

Open
mikkel wants to merge 1 commit into
masterfrom
paper-watch/pairing-regularization
Open

mikkel wants to merge 1 commit into
masterfrom
paper-watch/pairing-regularization

Conversation

@mikkel

@mikkel mikkel commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Paper watch — cycle 1: pairing regularization on ParticleGAN

Paper: "Pairing Regularization for Mitigating Many-to-One Collapse in GANs" — Lin, Huang, Liu (2026). https://arxiv.org/abs/2604.20130

Mechanism (as published): a pairing network P(x, z) is trained with a contrastive (InfoNCE-style) loss to identify, within a minibatch, which latent produced each generated sample. The loss is added to the generator objective only (weight λ_pair); the discriminator and adversarial loss are untouched. On the paper's 2D toys, pairing rescues a collapsing plain GAN (ring: Naeem coverage 0.372 → 0.851; mixture: pairing+R1 recall 0.957 / coverage 0.861).

This PR asks the transfer question — does the term help a system that already has a learned particle prior? — as one CPU pytest: tests/test_paperwatch_pairing_regularization.py. No formulation code changes; the pairing term is delivered entirely through the repo's existing PriorManipulator penalty hook (GANTrainer adds it to the generator loss as prior_manipulation, and the pairing network's parameters ride the generator optimizer as prior router parameters). Candidate codes are detached inside the penalty, as in the paper the latent is exogenous; batch entries that repeat the same particle row are masked out of the denominator, since a repeated row is genuinely unidentifiable.

Toy design

  • Targets: 8 Gaussians on a ring (radius 2.0, σ = 0.15) for the shipped test; a uniform ring (radius 2.0) run in the gauntlet for cross-checking (the paper's headline toy).
  • Arms, identical budget (2,400 steps, batch 128, lr 2e-3, ka2 recipe, seeds 0/1/2):
    • (a) ParticleGAN control — learned 256-particle prior, z_dim 2.
    • (b) Plain GAN control — same recipe with the repo's matched non-particle control: frozen prior, prior_code_law="fresh_gaussian".
    • (c) ParticleGAN + pairing — (a) + pairing loss, λ_pair = 0.03, pairing net hidden 128.
  • Metrics: Naeem coverage (fraction of real samples whose 5-NN ball within the real set contains a generated sample) and within-mode dispersion ratio (mean pairwise distance of fakes assigned to each mode ÷ the target's σ√π; 1.0 = perfect, < 1 = intramode concentration — the many-to-one collapse the paper names). Ring runs report coverage + angular-histogram uniformity instead of dispersion.

Gauntlet log (standing 10-iteration loop; stopped at 6 — verdict stable)

Controls, mixture @ 800 steps: ParticleGAN cov 0.211 ± 0.018 / disp 0.76 · plain cov 0.616 ± 0.014 / disp 1.54.
Controls, mixture @ 2,400 steps: ParticleGAN cov 0.201 ± 0.014 / disp 0.78 · plain cov 0.638 ± 0.039 / disp 1.07.

Round Change (one per round) Pairing cov Pairing disp Read
1 λ_pair = 1.0, 800 steps 0.075 3.91 Pairing term ≈ 3× the adversarial loss (measured prior_manipulation 2.75 vs loss_gan 0.87 at step 30); generator collapses to a central, per-particle-identifiable blob. Far below both controls.
2 λ_pair = 0.1 0.163 2.43 Monotone improvement as λ falls; still below the ParticleGAN control.
3 λ_pair = 0.03 0.232 1.53 First pass of the ParticleGAN control on coverage (0.211); dispersion overshoots to the plain arm's level.
4 Budget 800 → 2,400 steps (all arms re-run) 0.245 1.46 Pairing beats the ParticleGAN control in every seed (+0.044 mean). Plain control also matures (dispersion → 1.07) and stays far ahead on coverage (0.638).
5 Pairing net hidden 128 → 32 0.208 1.54 Worse on both metrics — the "pairing net memorizes particle identities" hypothesis is not supported. Reverted to hidden 128.
6 Ring target @ round-4 config (all arms) 0.237 (ring cov) uniformity 0.993 Same ordering on the paper's own toy: ParticleGAN control 0.215 / 0.978, plain 0.779 / 0.998. Verdict is not a mixture artifact.

Final margins (mixture, 2,400 steps, λ_pair = 0.03, mean ± sd over seeds 0/1/2)

Arm Naeem coverage Dispersion ratio
ParticleGAN (control 1) 0.201 ± 0.014 0.78 ± 0.04
Plain GAN (control 2) 0.638 ± 0.039 1.07 ± 0.06
ParticleGAN + pairing 0.245 ± 0.010 1.46 ± 0.01

Ring (coverage / angular uniformity): ParticleGAN 0.215 / 0.978 · plain 0.779 / 0.998 · pairing 0.237 / 0.993.

Verdict: PARTIAL

Pairing does what the paper says to the ParticleGAN control: it relieves intramode concentration (dispersion 0.78 → 1.46, overshooting 1.0) and lifts its coverage in every seed on both targets. But the paper's headline claim — pairing rescues the GAN — does not transfer past the plain baseline here: at an adequate budget the plain fresh-Gaussian GAN was never collapsing (dispersion ≈ 1.07, coverage 0.64), and pairing on ParticleGAN does not catch it. The test's assertions encode exactly these measured margins, including the negative half (test_pairing_does_not_beat_plain_control), so a future change that moves either boundary fails loudly here first.

Failure modes are understood: at λ ≥ 0.1 the identification gradient dominates and the generator trades the data manifold for per-particle identifiability (central blob, dispersion ≈ 2.4–3.9, coverage ≈ 0.08–0.16); at λ = 0.03 the term is a genuine regularizer but its within-mode repulsion overshoots the target spread.

Seam check (standing rule)

The gauntlet exercised recipe.make_prior(manipulators=...), the ManipulatedPrior.regularize → prior_manipulation path, manipulator-parameter routing in make_optimizers, and GANTrainer.sample served/live weight semantics. All behaved exactly as documented — no seam in our own code was found, so there is nothing to fix in this PR. (One cost note, not a bug: the pairing arm runs ~5× slower than the controls because the B×B pairing scores backpropagate through the generator; the smaller pairing net in round 5 cut that to ~2× but cost accuracy.)

Run it

python -m pytest tests/test_paperwatch_pairing_regularization.py

CPU-only; the nine trainings take ~10 minutes on a workstation (5 tests: 2 mechanism unit checks + 3 gauntlet assertions over a shared module-scoped fixture). Verified end-to-end on a clean checkout (pop-os, torch 2.15): 5 passed.

…tial transfer

Three-arm CPU toy (ParticleGAN / plain fresh-Gaussian GAN / ParticleGAN +
pairing) on an 8-Gaussian ring mixture, ka2 recipe, 2,400 steps, seeds 0-2.
Pairing is delivered through the PriorManipulator penalty hook; assertions
encode the gauntlet's measured margins: pairing beats the ParticleGAN
control on coverage and relieves its intramode concentration, but does not
beat the plain control. Verdict: partial. Nothing merged.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant