Added --save-latent flag to train-vae for latent mu/sigma and loss hi… - #67
Open
kbcoulter wants to merge 3 commits into
Open
Added --save-latent flag to train-vae for latent mu/sigma and loss hi…#67kbcoulter wants to merge 3 commits into
kbcoulter wants to merge 3 commits into
Conversation
…story, used in betascan.
- model.py
- train_vae: new --save-latent flag (independent of --save-stats)
- Writes per-epoch loss/recon/kl history to {out}.losses_stats.tsv
- Runs vae.eval() then a no-grad pass over the training data to export mu/sigma to {out}.latent_mu.tsv and {out}.latent_std.tsv
- x_tensor uses device/dtype (not .float()) so it matches the model under --bfloat16
-cli.md
- Added save-latent to docs
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new --save-latent flag to the embkit model train-vae CLI command to persist per-epoch training losses and latent distribution statistics (mu/std) for downstream analysis workflows (e.g., betascan/embedding rotation).
Changes:
- Introduces
--save-latentto export{out}.losses_stats.tsv,{out}.latent_mu.tsv, and{out}.latent_std.tsvafter training. - Runs an eval/no-grad pass over the training dataset to compute and save latent
muandsigma. - Updates CLI documentation to include the new flag.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/embkit/commands/model.py | Adds the --save-latent flag and implements loss + latent mu/std export. |
| docs/cli.md | Documents the new --save-latent option for train-vae. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
To 32 before building. Everything here is functionally identical. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
kbcoulter
marked this pull request as draft
August 3, 2026 18:35
Covers losses, mu, std, sample index, save-stats (with save-latent)
kbcoulter
marked this pull request as ready for review
August 3, 2026 20:56
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.
Add
--save-latentflag totrain-vaefor latent stat and loss savingtrain_vaeconveniently had--save-statsadded, which saves mean/std, but not latent mu/sigma or per-epoch loss. Latent mu is needed for the betascan test in embedding-rotation.Changes
New
--save-latentflag fortrain-vae(independent of--save-stats):{out}.losses_stats.tsvvae.eval()with no-grad on the training data to export mu/sigma to{out}.latent_mu.tsvand{out}.latent_std.tsvdevice/dtypeinstead of forcingfloat32, to work with--bfloat16Opening this for review. I am happy to add tests for
train-vaeif the approach looks good or look at adding--save-latentinto other models (train-netvae) if thatd be useful.