Skip to content

Phase 0: safety net — vendored VAE, test suite, CI gating#10

Open
AshishKumar4 wants to merge 3 commits into
mainfrom
revamp/phase-0-safety-net
Open

Phase 0: safety net — vendored VAE, test suite, CI gating#10
AshishKumar4 wants to merge 3 commits into
mainfrom
revamp/phase-0-safety-net

Conversation

@AshishKumar4

Copy link
Copy Markdown
Owner

First PR of the revamp series (phases 0/1/2 are stacked; review in order).

Why

The July 2026 audit found the repo has zero tests, auto-publishes to PyPI on every push, and depends on diffusers' Flax support — which upstream deleted on 2026-07-21 (huggingface/diffusers#14169) while diffusers wasn't even declared in pyproject.toml. This PR builds the safety net everything else lands on.

What

  • Vendored the SD VAE flax modules (flaxdiff/models/autoencoder/vae.py, Apache-2.0 attribution) with a direct HF hub msgpack loader replacing FlaxAutoencoderKL.from_pretrained. Verified against real weights: correct 8x downscale / 4 latent channels, 26.6dB roundtrip PSNR on a real image. Declared the other load-bearing-but-undeclared deps (transformers, wandb, huggingface_hub) and pinned diffusers>=0.29,<0.35 (only needed for the diffusers_unet_simple arch now).
  • Test suite (~680 lines): forward-shape tests for every architecture incl. all hybrid SSM variants; scheduler invariants (alpha^2+sigma^2=1, invertibility, EDM lognormal sigma distribution); exact predictor round-trips; samplers tested end-to-end against an analytic gaussian oracle denoiser they must converge to; config round-trip through parse_config; trainer save/restore smoke tests.
  • 17 known bugs are encoded as xfail(strict=True) — the suite is green today, and Phase 1's fixes must flip each one (strict means a fixed bug that still carries the marker fails the build). The xfail list is effectively the Phase 1 worklist: sampler step-domain bug, UViT double-hilbert, DDPM batch crash, DDIM eta, RK4, video shapes, opt_state lost on resume, training without wandb crashing, silent config drops, and more.
  • CI: pytest now actually runs (-m "not network"); PyPI publish moved from push-to-main to releases only.

Verification

pytest -m "not network": 39 passed, 17 xfailed. Network-marked VAE tests pass locally (weights download + reconstruction PSNR).

🤖 Generated with Claude Code

AshishKumar4 and others added 3 commits July 22, 2026 23:25
diffusers removed all Flax/JAX support upstream (huggingface/diffusers#14169),
which would break our latent diffusion path on any fresh install. The VAE
modules are now vendored (Apache-2.0, attribution in vae.py) with a direct
HF hub msgpack loader, verified against the real weights (26.6dB roundtrip
PSNR on a real image). transformers/wandb/huggingface_hub were also
load-bearing but undeclared. Also fixes the README install instructions
which pointed at a requirements.txt that does not exist.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…plers, config and trainer

Every architecture gets a forward-shape test, schedulers get invariant
tests (variance preservation, invertibility, EDM lognormal), predictors
get exact round-trip tests, and samplers are tested end to end against an
analytic gaussian oracle denoiser which they must converge to. Known bugs
are encoded as strict xfails so the suite is green now and the fixes must
flip them.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Pushes to main were auto-publishing untested code to PyPI with the pytest
step commented out.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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