From bc3bd812ddabdec5b31d694497e5295c87e1d482 Mon Sep 17 00:00:00 2001 From: Michael Cahill Date: Sat, 7 Mar 2026 16:25:26 -0800 Subject: [PATCH] M01: add sgm denoiser_scaling, discretizer, DiffusionEngine, GeneralConditioner stubs; M01_run3 and M01_summary Made-with: Cursor --- docs/milestones/M01/M01_run3.md | 84 ++++++++++++++++++++++++++++++ docs/milestones/M01/M01_summary.md | 75 ++++++++++++++++++++++++++ scripts/dev/create_stub_repos.py | 31 ++++++++++- 3 files changed, 188 insertions(+), 2 deletions(-) create mode 100644 docs/milestones/M01/M01_run3.md create mode 100644 docs/milestones/M01/M01_summary.md diff --git a/docs/milestones/M01/M01_run3.md b/docs/milestones/M01/M01_run3.md new file mode 100644 index 000000000..213e55697 --- /dev/null +++ b/docs/milestones/M01/M01_run3.md @@ -0,0 +1,84 @@ +# M01 CI Run 3 — Stub Repositories (Iterative) + +**Date:** 2026-03-08 +**Branch:** m01-ci-truthfulness +**Trigger:** Stub repository approach (ac965561 → 1d3c4dcb) + +--- + +## 1. Workflow Identity + +| Workflow | Run ID | Status | +|----------|--------|--------| +| Linter | 22810292142 | ✓ success | +| Tests | 22810292144 | ✗ failure | + +--- + +## 2. Approach + +**Stub repositories** instead of cache/submodules: + +- `scripts/dev/create_stub_repos.py` creates minimal `repositories/` layout +- Satisfies `paths.py` assertion and import chain +- Deterministic, no network, no cloning + +--- + +## 3. Stub Progression (by run) + +| Run | Blocker | Fix | +|-----|---------|-----| +| 22810169638 | `paths.py` assert (ddpm.py) | Add ddpm.py stub | +| 22810208301 | `LatentDiffusion` import | Add LatentDiffusion, LatentDepth2ImageDiffusion to ddpm | +| 22810246639 | `ldm.util` | Add ldm.util.default | +| 22810246639 | `ldm.modules.midas` | Add ldm.modules.midas | +| 22810292144 | `sgm.models` | Add sgm.models.diffusion | +| 22810326719 | `sgm.modules.diffusionmodules.denoiser_scaling` | Add denoiser_scaling, discretizer, DiffusionEngine, GeneralConditioner | + +--- + +## 4. Current Stub Layout + +``` +repositories/ + stable-diffusion-stability-ai/ + ldm/ + models/diffusion/ddpm.py (LatentDiffusion, LatentDepth2ImageDiffusion) + util.py (default) + modules/ + encoders/modules.py (FrozenCLIPEmbedder, FrozenOpenCLIPEmbedder, CLIPTextModel) + attention/ (CrossAttention) + diffusionmodules/model.py (AttnBlock) + midas/ + generative-models/ + sgm/ + models/diffusion/ (DiffusionEngine) + modules/ + encoders/modules.py + attention/ (CrossAttention, SDP_IS_AVAILABLE, XFORMERS_IS_AVAILABLE) + diffusionmodules/ (model, denoiser_scaling, discretizer, openaimodel) + conditioner.py (GeneralConditioner) + k-diffusion/ + BLIP/ + stable-diffusion-webui-assets/ +``` + +--- + +## 5. Remaining Blocker (Run 22810326719) + +``` +ModuleNotFoundError: No module named 'sgm.modules.diffusionmodules.denoiser_scaling' +``` + +Fix applied in next commit: add denoiser_scaling, discretizer, DiffusionEngine, GeneralConditioner, openaimodel stubs. + +--- + +## 6. Next Steps + +- Push stub additions +- Run CI +- If more import errors: add stubs iteratively +- When server starts: verify pytest and coverage pass diff --git a/docs/milestones/M01/M01_summary.md b/docs/milestones/M01/M01_summary.md new file mode 100644 index 000000000..e56d07450 --- /dev/null +++ b/docs/milestones/M01/M01_summary.md @@ -0,0 +1,75 @@ +# M01 Summary — CI Truthfulness & Guardrails + +**Milestone:** M01 +**Branch:** m01-ci-truthfulness +**Status:** In Progress (stub iteration) + +--- + +## Accomplished + +| Item | Status | +|------|--------| +| Same-repo PR CI | ✓ Removed skip condition | +| CLIP/pkg_resources fix | ✓ `--no-build-isolation` in launch_utils | +| `--skip-prepare-environment` | ✓ CI uses deterministic bootstrap | +| `--exit` handling | ✓ Early exit when skip-prepare + --exit | +| Install runtime deps | ✓ torch, clip, open_clip, requirements_versions | +| pip-audit | ✓ Non-blocking | +| SHA-pinned actions | ✓ | +| .gitattributes | ✓ | +| Smoke step | ✓ | +| Coverage threshold | ✓ --cov-fail-under=60 | +| Stub repositories | ✓ scripts/dev/create_stub_repos.py | + +--- + +## Remaining Blocker + +**Server startup fails** due to deep import chain from `ldm` and `sgm` packages. + +With `--skip-prepare-environment`, no repos are cloned. The app expects `repositories/` to exist and imports from them at runtime. + +**Solution:** Stub repositories (deterministic, no network). + +**Progress:** Iterative stub addition. Each CI run reveals one more missing import. Stubs added so far: + +- paths.py assertion (ddpm.py) +- LatentDiffusion, LatentDepth2ImageDiffusion +- ldm.util.default +- ldm.modules.attention, diffusionmodules.model, midas +- sgm.modules.encoders, attention, diffusionmodules +- sgm.models.diffusion (DiffusionEngine) +- sgm.modules.diffusionmodules.denoiser_scaling, discretizer +- sgm.modules.GeneralConditioner, openaimodel + +--- + +## CI Flow (Current) + +``` +install deps → pip-audit → create stub repositories → setup env → smoke → start server → pytest → coverage +``` + +--- + +## Definition of Done (Status) + +- [x] CI runs on push and pull_request +- [x] Linter: PASS +- [ ] Tests: PASS (blocked: server startup) +- [ ] Coverage threshold enforced +- [x] pip-audit runs +- [x] All actions pinned to SHAs +- [x] .gitattributes present +- [ ] docs/serena.md updated (when M01 closes) + +--- + +## When M01 Closes + +1. Stub iteration completes (server starts, pytest passes) +2. Update docs/serena.md ledger +3. Generate M01_audit.md +4. Merge m01-ci-truthfulness +5. Tag milestone diff --git a/scripts/dev/create_stub_repos.py b/scripts/dev/create_stub_repos.py index 0012157c0..d9722399f 100644 --- a/scripts/dev/create_stub_repos.py +++ b/scripts/dev/create_stub_repos.py @@ -65,7 +65,8 @@ def main() -> None: # sgm.modules.attention, diffusionmodules.model (sd_hijack_optimizations) touch( os.path.join(REPOS, gm, "sgm", "modules", "attention", "__init__.py"), - "class CrossAttention:\n def forward(self, *a, **k): pass\n", + "class CrossAttention:\n def forward(self, *a, **k): pass\n" + "\nSDP_IS_AVAILABLE = True\nXFORMERS_IS_AVAILABLE = False\n", ) touch(os.path.join(REPOS, gm, "sgm", "modules", "diffusionmodules", "__init__.py")) touch( @@ -74,7 +75,33 @@ def main() -> None: ) # sgm.models.diffusion (sd_models_xl) touch(os.path.join(REPOS, gm, "sgm", "models", "__init__.py")) - touch(os.path.join(REPOS, gm, "sgm", "models", "diffusion", "__init__.py")) + touch( + os.path.join(REPOS, gm, "sgm", "models", "diffusion", "__init__.py"), + "class DiffusionEngine:\n pass\n", + ) + # sgm.modules.diffusionmodules.denoiser_scaling, discretizer (sd_models_xl) + touch( + os.path.join(REPOS, gm, "sgm", "modules", "diffusionmodules", "denoiser_scaling.py"), + "class VScaling:\n pass\n", + ) + touch( + os.path.join(REPOS, gm, "sgm", "modules", "diffusionmodules", "discretizer.py"), + "class LegacyDDPMDiscretization:\n alphas_cumprod = [1.0]\n", + ) + # sgm.modules.GeneralConditioner (sd_models_xl) + touch(os.path.join(REPOS, gm, "sgm", "modules", "__init__.py")) + touch( + os.path.join(REPOS, gm, "sgm", "modules", "conditioner.py"), + "class GeneralConditioner:\n pass\n", + ) + touch( + os.path.join(REPOS, gm, "sgm", "modules", "__init__.py"), + "from .conditioner import GeneralConditioner\n", + ) + touch( + os.path.join(REPOS, gm, "sgm", "modules", "diffusionmodules", "openaimodel.py"), + "# stub\n", + ) # k-diffusion: k_diffusion.sampling kd = "k-diffusion"