Diffusion pipeline latent preview - #236
Merged
Merged
Conversation
stikves
force-pushed
the
sukru/latent-preview
branch
5 times, most recently
from
September 9, 2026 21:12
184015d to
f2672a0
Compare
Surface intermediate denoising latents so a UI can render a cheap live preview without a full VAE decode per step: - PipelineProgress.currentLatent, plumbed through an optional progress handler (zero cost when unset) across the SD, SD3, and FLUX.2 pipelines. - NDArray.asRGB(coefficients:) — a single cblas_sgemm latent-to-RGB projection. Coefficients are supplied by the caller; the mapping is specific to each model's VAE. - LatentPreviewTuner and diffusion-runner --tune-preview / --tune-fit to collect latent/image pairs, fit a coefficient set, and export per-step draft previews.
stikves
force-pushed
the
sukru/latent-preview
branch
from
September 9, 2026 21:16
f2672a0 to
e65cee3
Compare
stikves
requested review from
DawerG,
gokulkrishna98,
kevchengcodes and
tjia1818
September 9, 2026 21:53
stikves
marked this pull request as ready for review
September 9, 2026 21:54
tjia1818
reviewed
Sep 10, 2026
- Flux2Pipeline: fix preview comment typo (16 -> 32 channels after unpatchify) - LatentPreview: correct vDSP -> cblas_sgemm/BLAS docs; add rgbChannels constant - LatentPreviewTuner: extract shared solveLeastSquares helper used by both fitCoefficients and fitFromDirectory, removing duplicated normal-equations math - LatentPreviewTuner: report full shape on fit-shape guard; drop thin savePNG wrapper; log skipped latents in exportStepPreviewsFromDirectory
kevchengcodes
approved these changes
Sep 10, 2026
kevchengcodes
left a comment
Contributor
There was a problem hiding this comment.
looks good, left one more comment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Diffusion pipeline latent preview
Surfaces intermediate denoising latents so a UI can render a lightweight live preview without a full VAE decode at every step.
PipelineProgress.currentLatent— the current latent is exposed through an optional progress handler; when no handler is set, no preview work is performed.NDArray.asRGB(coefficients:)— projects a latent to an RGB image via a singlecblas_sgemm. The projection is a small linear map specific to a model's VAE, supplied by the caller.LatentPreviewTuneranddiffusion-runner --tune-preview/--tune-fit— collect latent/image pairs for a model, fit a coefficient set, and export per-step preview images.Coefficients are fit per model rather than bundled, since the latent-to-RGB mapping depends on the model's VAE. See the
LatentRGBCoefficientsdocumentation for the tuning workflow.Closes: #231
Follow-up (out of scope)
Preview resolution equals the latent resolution. A higher-fidelity option is a small distilled decoder that reconstructs full-resolution output at a fraction of the full VAE cost; tracked separately.
Test plan
--tune-previewcollects pairs;--tune-fitfits coefficients and exports previews