[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6PQR384G219XQVNFBKMEG3J":3,"skill-same:01M6PQR384G219XQVNFBKMEG3J":117},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":33,"linkOnly":34,"markdownContent":35,"markdownBody":36,"frontMatter":37,"refName":43,"commitSha":44,"skillDirectory":45,"forksCount":14,"repositoryHtmlUrl":46,"repositoryHomepageUrl":6,"ownerHtmlUrl":47,"ownerBlogUrl":48,"ownerDescription":6,"updatedAt":49,"install":50,"resources":63},"01M6PQR384G219XQVNFBKMEG3J","nv-generate-vae-finetune",null,"Used for finetuning the NV-Generate-CTMR MAISI VAE from CT\u002FMRI NIfTI datalists. Not for clinical or production data approval.","headmktlucca-ui\u002Fneuroads-lp","headmktlucca-ui","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F247379838?v=4","01M6PDVAV6M1W96D1SR1PDF8CS","NeuroAds","01M6PDVAZ4P281GNDKD45CYTF5",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fheadmktlucca-ui\u002Fneuroads-lp\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fnv-generate-vae-finetune\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32],"generate","finetune","nv generate vae finetune","finetuning","NVIDIA","data","Production","team","Bash","approval","clinical","MRI","CT","for","2026-11-10 10:12:30",false,"---\nname: nv-generate-vae-finetune\ndescription: Used for finetuning the NV-Generate-CTMR MAISI VAE from CT\u002FMRI NIfTI datalists. Not for clinical or production data approval.\nlicense: Apache-2.0\nallowed-tools: Bash\nmetadata:\n  author: NVIDIA MedTech Team\n  tags:\n    - MedTech\n    - CT\n    - MRI\n    - VAE\n    - finetune\n---\n\n# NV-Generate-VAE-Finetune\n\n## Purpose\n- Used for finetuning the NV-Generate-CTMR MAISI VAE\u002Fautoencoder from user-supplied CT or MRI NIfTI training volumes.\n- Not for clinical interpretation, regulatory use, or approving synthetic data for production training.\n- Upstream currently documents VAE training in `train_vae_tutorial.ipynb` and provides configs\u002Fhelpers, but not a `scripts.train_vae` CLI. This skill does not execute the notebook; it stages the required config\u002Fdatalist glue locally and uses upstream helper APIs.\n- Manifest I\u002FO: inputs are `datalist` and `data_base_dir`; outputs are `autoencoder_checkpoint`, `discriminator_checkpoint`, and `result_json`.\n- The underlying training contract is the upstream config\u002Fenv JSON (`config_maisi_vae_train.json` + `environment_maisi_vae_train.json`, as used in `train_vae_tutorial.ipynb`). The wrapper stages those JSON files for you and exposes the most-tuned fields as CLI flags; the sections below document the fields, their defaults, and how to monitor\u002Ftune a run.\n\n## Instructions\n- Read `skill_manifest.yaml` before changing arguments, side effects, or validation gates.\n- Run `scripts\u002Frun_vae_finetune.py` from the Medical AI Skills repo root.\n- If a host agent exposes `run_script`, use `run_script(\"scripts\u002Frun_vae_finetune.py\", args=[...])`; otherwise run the Bash\u002FPython command below.\n- Use `--preflight` first when checking a new datalist; remove `--preflight` only when the user explicitly wants to launch GPU finetuning.\n- For a staged preflight input bundle directory, use `BUNDLE\u002Fpreflight_datalist.json` as the datalist and `BUNDLE\u002Fpreflight_dataset` as `--data-base-dir` when those files are present.\n\n## Examples\n\nValidate and stage a preflight finetune check from an input bundle (the recommended first step — no GPU, no training). This is the single canonical command; replace `INPUT_BUNDLE` and `OUT_DIR` with your paths:\n\n```bash\nexport NV_GENERATE_ROOT=\"${NV_GENERATE_ROOT:-.workbench_data\u002Fupstreams\u002FNV-Generate-CTMR}\" && \\\npython skills\u002Fnv-generate-vae-finetune\u002Fscripts\u002Frun_vae_finetune.py \\\n  INPUT_BUNDLE\u002Fpreflight_datalist.json \\\n  --data-base-dir INPUT_BUNDLE\u002Fpreflight_dataset \\\n  --output-dir OUT_DIR \\\n  --modality mri \\\n  --preflight\n```\n\nFor real GPU finetuning and other variations, see [Usage](#2-usage-one-line-training) below.\n\n## Available Scripts\n| Script | Purpose | Arguments |\n|---|---|---|\n| `scripts\u002Frun_vae_finetune.py` | Primary entrypoint declared by `skill_manifest.yaml`. | `DATALIST.json --data-base-dir DATA_DIR --output-dir OUT_DIR [--epochs N] [--modality mri] [--patch-size 64,64,64] [--preflight]` |\n\n## Prerequisites\n- `NV_GENERATE_ROOT` may point to a current checkout of `https:\u002F\u002Fgithub.com\u002FNVIDIA-Medtech\u002FNV-Generate-CTMR` containing `configs\u002Fconfig_maisi_vae_train.json`, `scripts\u002Ftransforms.py`, and `scripts\u002Futils.py`.\n- If `NV_GENERATE_ROOT` is unset, the wrapper searches `.workbench_data\u002Fupstreams\u002FNV-Generate-CTMR`.\n- `CUDA_VISIBLE_DEVICES` is optional and can be used to select the GPU for real training.\n- Runtime requirements: NVIDIA CUDA GPU for real training, Python packages from the upstream `requirements.txt`, `lpips`, and downloaded VAE weights unless using `--train-from-scratch`.\n- Side effects: writes staged configs, checkpoints, TensorBoard logs, and run summaries under the caller-provided `--output-dir`; may write model caches under the upstream checkout, `~\u002F.cache\u002Fhuggingface\u002F`, and `~\u002F.cache\u002Ftorch\u002F`; may contact `https:\u002F\u002Fhuggingface.co`, `https:\u002F\u002Fgithub.com`, and `https:\u002F\u002Fdownload.pytorch.org`.\n- The datalist is a MONAI-style JSON object with non-empty `training[]` and `validation[]` or `testing[]`. Each entry has an `image` path relative to `--data-base-dir` and optional `class` or `modality` of `ct` or `mri`.\n\n## 1. Config and environment JSON (adapt to your data)\n\nThe wrapper copies the upstream VAE config\u002Fenv JSON from `$NV_GENERATE_ROOT\u002Fconfigs`, rewrites the fields below, and writes the staged copies under `OUT_DIR\u002Fworkflow\u002Fconfigs\u002F`. You normally only set your datalist and data root; the listed CLI flags override individual fields when you need to.\n\nEnvironment JSON (`environment_maisi_vae_train.json`):\n\n| Field | Set from | Notes |\n|---|---|---|\n| `model_dir` | `--output-dir` | Where `autoencoder.pt`\u002F`discriminator.pt` and best checkpoints are saved. |\n| `tfevent_path` | `--output-dir` | TensorBoard event directory. |\n| `finetune` | `--train-from-scratch` | `true` (default) loads `trained_autoencoder_path`; the flag sets it `false`. |\n| `trained_autoencoder_path` | upstream weights \u002F `--trained-autoencoder-path` | Starting VAE checkpoint when finetuning. |\n\nTraining fields (`config_maisi_vae_train.json`):\n\n| Field | Flag | Type | Default | Notes |\n|---|---|---|---|---|\n| `autoencoder_train.n_epochs` | `--epochs` | int | `1` | |\n| `autoencoder_train.batch_size` | `--batch-size` | int | `1` | Per-GPU (single-GPU runner). |\n| `autoencoder_train.patch_size` | `--patch-size` | int,int,int | `64,64,64` | Training crop. |\n| `autoencoder_train.val_batch_size` | `--val-batch-size` | int | `1` | |\n| `autoencoder_train.val_sliding_window_patch_size` | `--val-sliding-window-patch-size` | int,int,int | `96,96,64` | Sliding-window validation ROI. |\n| `autoencoder_train.lr` | `--lr` | float | `1e-4` | |\n| `autoencoder_train.perceptual_weight` | `--perceptual-weight` | float | `0.3` | LPIPS term. |\n| `autoencoder_train.kl_weight` | `--kl-weight` | float | `1e-7` | KL term. |\n| `autoencoder_train.adv_weight` | `--adv-weight` | float | `0.1` | Adversarial term. |\n| `autoencoder_train.recon_loss` | `--recon-loss` | `l1`\\|`l2` | `l1` | |\n| `autoencoder_train.val_interval` | `--val-interval` | int | `1` | Epochs between validation passes. |\n| `autoencoder_train.cache` | `--cache-rate` | float | `0.0` | MONAI `CacheDataset` fraction. |\n| `autoencoder_train.amp` | `--no-amp` | flag | on | Mixed precision; flag disables it. |\n| `data_option.random_aug` | `--no-random-aug` | flag | on | Random augmentation; flag disables it. |\n| `data_option.spacing_type` | `--spacing-type` | `original`\\|`fixed`\\|`rand_zoom` | `original` | |\n| `data_option.spacing` | `--spacing` | float,float,float | unset | Required when `spacing_type` is `fixed`\u002F`rand_zoom`. |\n| `data_option.select_channel` | `--select-channel` | int | `0` | Channel for multi-channel inputs. |\n\n`--modality` (`ct` or `mri`, default `mri`) fills the per-entry `class` for datalist items missing one. Validation\u002Ftesting entries are required because the training loop runs a validation pass.\n\nFor an end-to-end reference including example data download, see the upstream tutorial `train_vae_tutorial.ipynb`.\n\n## 2. Usage (one-line training)\n\nPreflight only:\n\n```bash\nexport NV_GENERATE_ROOT=\"${NV_GENERATE_ROOT:-.workbench_data\u002Fupstreams\u002FNV-Generate-CTMR}\" && \\\npython skills\u002Fnv-generate-vae-finetune\u002Fscripts\u002Frun_vae_finetune.py \\\n  PATH_TO_DATALIST.json \\\n  --data-base-dir PATH_TO_DATA_ROOT \\\n  --output-dir runs\u002Fnv_generate_vae_finetune_preflight \\\n  --preflight\n```\n\nPreflight bundle input:\n\n```bash\nexport NV_GENERATE_ROOT=\"${NV_GENERATE_ROOT:-.workbench_data\u002Fupstreams\u002FNV-Generate-CTMR}\" && \\\npython skills\u002Fnv-generate-vae-finetune\u002Fscripts\u002Frun_vae_finetune.py \\\n  PATH_TO_INPUT_BUNDLE\u002Fpreflight_datalist.json \\\n  --data-base-dir PATH_TO_INPUT_BUNDLE\u002Fpreflight_dataset \\\n  --output-dir runs\u002Fnv_generate_vae_finetune_preflight \\\n  --preflight\n```\n\nGPU finetuning:\n\n```bash\nexport NV_GENERATE_ROOT=\"${NV_GENERATE_ROOT:-.workbench_data\u002Fupstreams\u002FNV-Generate-CTMR}\" && \\\npython -m pip install -r \"$NV_GENERATE_ROOT\u002Frequirements.txt\" && \\\npython -m pip install lpips tensorboard && \\\npython skills\u002Fnv-generate-vae-finetune\u002Fscripts\u002Frun_vae_finetune.py \\\n  PATH_TO_DATALIST.json \\\n  --data-base-dir PATH_TO_DATA_ROOT \\\n  --output-dir runs\u002Fnv_generate_vae_finetune \\\n  --epochs 1 \\\n  --modality mri \\\n  --patch-size 64,64,64 \\\n  --download-model-data\n```\n\nReplace `PATH_TO_DATALIST.json` and `PATH_TO_DATA_ROOT` with the user's actual paths. Do not use the fixture datalist for real training; it is a preflight-only placeholder.\n\n## 3. Monitor training (TensorBoard)\n\nThe runner writes TensorBoard scalars (per-iteration and per-epoch `recons_loss`, `kl_loss`, `p_loss`, adversarial\u002Freal\u002Ffake losses, and a validation `scale_factor`) under `OUT_DIR\u002Fartifacts\u002Ftfevent\u002Fautoencoder`. Launch TensorBoard against the output directory:\n\n```bash\npython -m pip install tensorboard && \\\ntensorboard --logdir runs\u002Fnv_generate_vae_finetune\u002Fartifacts\u002Ftfevent\n```\n\nThe same per-epoch loss history is also captured in `OUT_DIR\u002Fartifacts\u002Fworkflow_summary.json` and echoed in the JSON the wrapper prints to stdout (`loss_history`, best-checkpoint paths, `exit_code`, `stderr_tail`).\n\n## 4. Hyperparameter tuning and common pitfalls\n\n- **Reconstructions blurry** — raise `--perceptual-weight` (default `0.3`); try `--recon-loss l2` if edges look washed out.\n- **Posterior collapse \u002F over-regularized latents** — `--kl-weight` is intentionally tiny (`1e-7`); increasing it too much degrades reconstruction.\n- **Adversarial training unstable** — lower `--adv-weight` (default `0.1`) or `--lr`; a warmup schedule already ramps the LR over the first 20 epochs.\n- **Out-of-memory** — reduce `--patch-size` (e.g. `48,48,48`) and `--val-sliding-window-patch-size`, keep `--batch-size 1`, and lower `--cache-rate`.\n- **`datalist must include non-empty validation[] or testing[]`** — the validation loop is mandatory; add `validation[]` (or `testing[]`) entries.\n- **Single-GPU only** — the runner asserts exactly one CUDA GPU; set `CUDA_VISIBLE_DEVICES` to pick which one.\n\n## 5. Evaluate the finetuned VAE\n\nValidation reconstruction loss (lowest-`val_weighted_loss` epoch) is tracked automatically and the best autoencoder is saved as `autoencoder_epochN.pt` under `OUT_DIR\u002Fartifacts\u002Fmodels`. To evaluate downstream:\n\n- Compare validation `recons_loss`\u002F`p_loss` curves across runs in TensorBoard, and\n- Plug the finetuned autoencoder into a diffusion finetune\u002Fgeneration run (e.g. [`nv-generate-mr-brain-finetune`](..\u002Fnv-generate-mr-brain-finetune\u002FSKILL.md) via `--trained-autoencoder-path`) to confirm latents still decode to usable volumes.\n\nThis skill gates file accounting and reconstruction bookkeeping only — image quality and downstream utility must be judged by a domain expert.\n\n## Limitations\n- Requires a current upstream `NV-Generate-CTMR` checkout with VAE configs and helper APIs. The skill owns the runner glue and does not depend on the notebook.\n- Full training can be expensive and is not deterministic across hardware, CUDA, and package versions.\n- The wrapper gates file accounting and command provenance, not anatomical realism, reconstruction quality, or downstream model utility.\n- Not for clinical deployment, clinical interpretation, autonomous diagnosis, regulatory submission, or production training-data approval.\n\n## Troubleshooting\n| Error | Cause | Fix |\n|---|---|---|\n| `VAE configs\u002Fhelpers were not found` | `NV_GENERATE_ROOT` does not point at a current NV-Generate-CTMR checkout. | Clone or update `https:\u002F\u002Fgithub.com\u002FNVIDIA-Medtech\u002FNV-Generate-CTMR` and set `NV_GENERATE_ROOT`. |\n| `datalist must include non-empty validation[] or testing[]` | VAE training requires validation data for the configured validation loop. | Add `validation[]` or `testing[]` entries with relative image paths. |\n| CUDA, MONAI, or LPIPS import failure | Runtime environment lacks upstream dependencies. | Install `\"$NV_GENERATE_ROOT\u002Frequirements.txt\"` plus `lpips tensorboard` in the selected environment. |\n","# NV-Generate-VAE-Finetune\n\n## Purpose\n- Used for finetuning the NV-Generate-CTMR MAISI VAE\u002Fautoencoder from user-supplied CT or MRI NIfTI training volumes.\n- Not for clinical interpretation, regulatory use, or approving synthetic data for production training.\n- Upstream currently documents VAE training in `train_vae_tutorial.ipynb` and provides configs\u002Fhelpers, but not a `scripts.train_vae` CLI. This skill does not execute the notebook; it stages the required config\u002Fdatalist glue locally and uses upstream helper APIs.\n- Manifest I\u002FO: inputs are `datalist` and `data_base_dir`; outputs are `autoencoder_checkpoint`, `discriminator_checkpoint`, and `result_json`.\n- The underlying training contract is the upstream config\u002Fenv JSON (`config_maisi_vae_train.json` + `environment_maisi_vae_train.json`, as used in `train_vae_tutorial.ipynb`). The wrapper stages those JSON files for you and exposes the most-tuned fields as CLI flags; the sections below document the fields, their defaults, and how to monitor\u002Ftune a run.\n\n## Instructions\n- Read `skill_manifest.yaml` before changing arguments, side effects, or validation gates.\n- Run `scripts\u002Frun_vae_finetune.py` from the Medical AI Skills repo root.\n- If a host agent exposes `run_script`, use `run_script(\"scripts\u002Frun_vae_finetune.py\", args=[...])`; otherwise run the Bash\u002FPython command below.\n- Use `--preflight` first when checking a new datalist; remove `--preflight` only when the user explicitly wants to launch GPU finetuning.\n- For a staged preflight input bundle directory, use `BUNDLE\u002Fpreflight_datalist.json` as the datalist and `BUNDLE\u002Fpreflight_dataset` as `--data-base-dir` when those files are present.\n\n## Examples\n\nValidate and stage a preflight finetune check from an input bundle (the recommended first step — no GPU, no training). This is the single canonical command; replace `INPUT_BUNDLE` and `OUT_DIR` with your paths:\n\n```bash\nexport NV_GENERATE_ROOT=\"${NV_GENERATE_ROOT:-.workbench_data\u002Fupstreams\u002FNV-Generate-CTMR}\" && \\\npython skills\u002Fnv-generate-vae-finetune\u002Fscripts\u002Frun_vae_finetune.py \\\n  INPUT_BUNDLE\u002Fpreflight_datalist.json \\\n  --data-base-dir INPUT_BUNDLE\u002Fpreflight_dataset \\\n  --output-dir OUT_DIR \\\n  --modality mri \\\n  --preflight\n```\n\nFor real GPU finetuning and other variations, see [Usage](#2-usage-one-line-training) below.\n\n## Available Scripts\n| Script | Purpose | Arguments |\n|---|---|---|\n| `scripts\u002Frun_vae_finetune.py` | Primary entrypoint declared by `skill_manifest.yaml`. | `DATALIST.json --data-base-dir DATA_DIR --output-dir OUT_DIR [--epochs N] [--modality mri] [--patch-size 64,64,64] [--preflight]` |\n\n## Prerequisites\n- `NV_GENERATE_ROOT` may point to a current checkout of `https:\u002F\u002Fgithub.com\u002FNVIDIA-Medtech\u002FNV-Generate-CTMR` containing `configs\u002Fconfig_maisi_vae_train.json`, `scripts\u002Ftransforms.py`, and `scripts\u002Futils.py`.\n- If `NV_GENERATE_ROOT` is unset, the wrapper searches `.workbench_data\u002Fupstreams\u002FNV-Generate-CTMR`.\n- `CUDA_VISIBLE_DEVICES` is optional and can be used to select the GPU for real training.\n- Runtime requirements: NVIDIA CUDA GPU for real training, Python packages from the upstream `requirements.txt`, `lpips`, and downloaded VAE weights unless using `--train-from-scratch`.\n- Side effects: writes staged configs, checkpoints, TensorBoard logs, and run summaries under the caller-provided `--output-dir`; may write model caches under the upstream checkout, `~\u002F.cache\u002Fhuggingface\u002F`, and `~\u002F.cache\u002Ftorch\u002F`; may contact `https:\u002F\u002Fhuggingface.co`, `https:\u002F\u002Fgithub.com`, and `https:\u002F\u002Fdownload.pytorch.org`.\n- The datalist is a MONAI-style JSON object with non-empty `training[]` and `validation[]` or `testing[]`. Each entry has an `image` path relative to `--data-base-dir` and optional `class` or `modality` of `ct` or `mri`.\n\n## 1. Config and environment JSON (adapt to your data)\n\nThe wrapper copies the upstream VAE config\u002Fenv JSON from `$NV_GENERATE_ROOT\u002Fconfigs`, rewrites the fields below, and writes the staged copies under `OUT_DIR\u002Fworkflow\u002Fconfigs\u002F`. You normally only set your datalist and data root; the listed CLI flags override individual fields when you need to.\n\nEnvironment JSON (`environment_maisi_vae_train.json`):\n\n| Field | Set from | Notes |\n|---|---|---|\n| `model_dir` | `--output-dir` | Where `autoencoder.pt`\u002F`discriminator.pt` and best checkpoints are saved. |\n| `tfevent_path` | `--output-dir` | TensorBoard event directory. |\n| `finetune` | `--train-from-scratch` | `true` (default) loads `trained_autoencoder_path`; the flag sets it `false`. |\n| `trained_autoencoder_path` | upstream weights \u002F `--trained-autoencoder-path` | Starting VAE checkpoint when finetuning. |\n\nTraining fields (`config_maisi_vae_train.json`):\n\n| Field | Flag | Type | Default | Notes |\n|---|---|---|---|---|\n| `autoencoder_train.n_epochs` | `--epochs` | int | `1` | |\n| `autoencoder_train.batch_size` | `--batch-size` | int | `1` | Per-GPU (single-GPU runner). |\n| `autoencoder_train.patch_size` | `--patch-size` | int,int,int | `64,64,64` | Training crop. |\n| `autoencoder_train.val_batch_size` | `--val-batch-size` | int | `1` | |\n| `autoencoder_train.val_sliding_window_patch_size` | `--val-sliding-window-patch-size` | int,int,int | `96,96,64` | Sliding-window validation ROI. |\n| `autoencoder_train.lr` | `--lr` | float | `1e-4` | |\n| `autoencoder_train.perceptual_weight` | `--perceptual-weight` | float | `0.3` | LPIPS term. |\n| `autoencoder_train.kl_weight` | `--kl-weight` | float | `1e-7` | KL term. |\n| `autoencoder_train.adv_weight` | `--adv-weight` | float | `0.1` | Adversarial term. |\n| `autoencoder_train.recon_loss` | `--recon-loss` | `l1`\\|`l2` | `l1` | |\n| `autoencoder_train.val_interval` | `--val-interval` | int | `1` | Epochs between validation passes. |\n| `autoencoder_train.cache` | `--cache-rate` | float | `0.0` | MONAI `CacheDataset` fraction. |\n| `autoencoder_train.amp` | `--no-amp` | flag | on | Mixed precision; flag disables it. |\n| `data_option.random_aug` | `--no-random-aug` | flag | on | Random augmentation; flag disables it. |\n| `data_option.spacing_type` | `--spacing-type` | `original`\\|`fixed`\\|`rand_zoom` | `original` | |\n| `data_option.spacing` | `--spacing` | float,float,float | unset | Required when `spacing_type` is `fixed`\u002F`rand_zoom`. |\n| `data_option.select_channel` | `--select-channel` | int | `0` | Channel for multi-channel inputs. |\n\n`--modality` (`ct` or `mri`, default `mri`) fills the per-entry `class` for datalist items missing one. Validation\u002Ftesting entries are required because the training loop runs a validation pass.\n\nFor an end-to-end reference including example data download, see the upstream tutorial `train_vae_tutorial.ipynb`.\n\n## 2. Usage (one-line training)\n\nPreflight only:\n\n```bash\nexport NV_GENERATE_ROOT=\"${NV_GENERATE_ROOT:-.workbench_data\u002Fupstreams\u002FNV-Generate-CTMR}\" && \\\npython skills\u002Fnv-generate-vae-finetune\u002Fscripts\u002Frun_vae_finetune.py \\\n  PATH_TO_DATALIST.json \\\n  --data-base-dir PATH_TO_DATA_ROOT \\\n  --output-dir runs\u002Fnv_generate_vae_finetune_preflight \\\n  --preflight\n```\n\nPreflight bundle input:\n\n```bash\nexport NV_GENERATE_ROOT=\"${NV_GENERATE_ROOT:-.workbench_data\u002Fupstreams\u002FNV-Generate-CTMR}\" && \\\npython skills\u002Fnv-generate-vae-finetune\u002Fscripts\u002Frun_vae_finetune.py \\\n  PATH_TO_INPUT_BUNDLE\u002Fpreflight_datalist.json \\\n  --data-base-dir PATH_TO_INPUT_BUNDLE\u002Fpreflight_dataset \\\n  --output-dir runs\u002Fnv_generate_vae_finetune_preflight \\\n  --preflight\n```\n\nGPU finetuning:\n\n```bash\nexport NV_GENERATE_ROOT=\"${NV_GENERATE_ROOT:-.workbench_data\u002Fupstreams\u002FNV-Generate-CTMR}\" && \\\npython -m pip install -r \"$NV_GENERATE_ROOT\u002Frequirements.txt\" && \\\npython -m pip install lpips tensorboard && \\\npython skills\u002Fnv-generate-vae-finetune\u002Fscripts\u002Frun_vae_finetune.py \\\n  PATH_TO_DATALIST.json \\\n  --data-base-dir PATH_TO_DATA_ROOT \\\n  --output-dir runs\u002Fnv_generate_vae_finetune \\\n  --epochs 1 \\\n  --modality mri \\\n  --patch-size 64,64,64 \\\n  --download-model-data\n```\n\nReplace `PATH_TO_DATALIST.json` and `PATH_TO_DATA_ROOT` with the user's actual paths. Do not use the fixture datalist for real training; it is a preflight-only placeholder.\n\n## 3. Monitor training (TensorBoard)\n\nThe runner writes TensorBoard scalars (per-iteration and per-epoch `recons_loss`, `kl_loss`, `p_loss`, adversarial\u002Freal\u002Ffake losses, and a validation `scale_factor`) under `OUT_DIR\u002Fartifacts\u002Ftfevent\u002Fautoencoder`. Launch TensorBoard against the output directory:\n\n```bash\npython -m pip install tensorboard && \\\ntensorboard --logdir runs\u002Fnv_generate_vae_finetune\u002Fartifacts\u002Ftfevent\n```\n\nThe same per-epoch loss history is also captured in `OUT_DIR\u002Fartifacts\u002Fworkflow_summary.json` and echoed in the JSON the wrapper prints to stdout (`loss_history`, best-checkpoint paths, `exit_code`, `stderr_tail`).\n\n## 4. Hyperparameter tuning and common pitfalls\n\n- **Reconstructions blurry** — raise `--perceptual-weight` (default `0.3`); try `--recon-loss l2` if edges look washed out.\n- **Posterior collapse \u002F over-regularized latents** — `--kl-weight` is intentionally tiny (`1e-7`); increasing it too much degrades reconstruction.\n- **Adversarial training unstable** — lower `--adv-weight` (default `0.1`) or `--lr`; a warmup schedule already ramps the LR over the first 20 epochs.\n- **Out-of-memory** — reduce `--patch-size` (e.g. `48,48,48`) and `--val-sliding-window-patch-size`, keep `--batch-size 1`, and lower `--cache-rate`.\n- **`datalist must include non-empty validation[] or testing[]`** — the validation loop is mandatory; add `validation[]` (or `testing[]`) entries.\n- **Single-GPU only** — the runner asserts exactly one CUDA GPU; set `CUDA_VISIBLE_DEVICES` to pick which one.\n\n## 5. Evaluate the finetuned VAE\n\nValidation reconstruction loss (lowest-`val_weighted_loss` epoch) is tracked automatically and the best autoencoder is saved as `autoencoder_epochN.pt` under `OUT_DIR\u002Fartifacts\u002Fmodels`. To evaluate downstream:\n\n- Compare validation `recons_loss`\u002F`p_loss` curves across runs in TensorBoard, and\n- Plug the finetuned autoencoder into a diffusion finetune\u002Fgeneration run (e.g. [`nv-generate-mr-brain-finetune`](..\u002Fnv-generate-mr-brain-finetune\u002FSKILL.md) via `--trained-autoencoder-path`) to confirm latents still decode to usable volumes.\n\nThis skill gates file accounting and reconstruction bookkeeping only — image quality and downstream utility must be judged by a domain expert.\n\n## Limitations\n- Requires a current upstream `NV-Generate-CTMR` checkout with VAE configs and helper APIs. The skill owns the runner glue and does not depend on the notebook.\n- Full training can be expensive and is not deterministic across hardware, CUDA, and package versions.\n- The wrapper gates file accounting and command provenance, not anatomical realism, reconstruction quality, or downstream model utility.\n- Not for clinical deployment, clinical interpretation, autonomous diagnosis, regulatory submission, or production training-data approval.\n\n## Troubleshooting\n| Error | Cause | Fix |\n|---|---|---|\n| `VAE configs\u002Fhelpers were not found` | `NV_GENERATE_ROOT` does not point at a current NV-Generate-CTMR checkout. | Clone or update `https:\u002F\u002Fgithub.com\u002FNVIDIA-Medtech\u002FNV-Generate-CTMR` and set `NV_GENERATE_ROOT`. |\n| `datalist must include non-empty validation[] or testing[]` | VAE training requires validation data for the configured validation loop. | Add `validation[]` or `testing[]` entries with relative image paths. |\n| CUDA, MONAI, or LPIPS import failure | Runtime environment lacks upstream dependencies. | Install `\"$NV_GENERATE_ROOT\u002Frequirements.txt\"` plus `lpips tensorboard` in the selected environment. |\n",{"name":5,"license":15,"metadata":38,"description":7,"allowed-tools":27},{"tags":39,"author":42},[40,31,30,41,20],"MedTech","VAE","NVIDIA MedTech Team","main","7a940b8e5af16c95e5c190a524421d32fc7445a9",".claude\u002Fskills\u002Fnv-generate-vae-finetune","https:\u002F\u002Fgithub.com\u002Fheadmktlucca-ui\u002Fneuroads-lp","https:\u002F\u002Fgithub.com\u002Fheadmktlucca-ui","https:\u002F\u002Fneuroads.com.br","2026-08-12 00:42:44",{"source":8,"skillName":5,"commands":51,"prompt":61,"zipAvailable":62},[52,55,58],{"tool":53,"command":54},"npx","npx skills add headmktlucca-ui\u002Fneuroads-lp --skill nv-generate-vae-finetune",{"tool":56,"command":57},"bunx","bunx skills add headmktlucca-ui\u002Fneuroads-lp --skill nv-generate-vae-finetune",{"tool":59,"command":60},"pnpm","pnpm dlx skills add headmktlucca-ui\u002Fneuroads-lp --skill nv-generate-vae-finetune","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fheadmktlucca-ui\u002Fneuroads-lp\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fnv-generate-vae-finetune\u002FSKILL.md",true,[64,70,74,78,82,85,89,95,99,103,109,113],{"path":65,"resourceType":66,"resourceTypeDesc":67,"sizeBytes":68,"sourceHtmlUrl":69},"BENCHMARK.md","REFERENCE","参考文档",4349,"https:\u002F\u002Fgithub.com\u002Fheadmktlucca-ui\u002Fneuroads-lp\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fnv-generate-vae-finetune\u002FBENCHMARK.md",{"path":71,"resourceType":66,"resourceTypeDesc":67,"sizeBytes":72,"sourceHtmlUrl":73},"evals\u002Fevals.json",1182,"https:\u002F\u002Fgithub.com\u002Fheadmktlucca-ui\u002Fneuroads-lp\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fnv-generate-vae-finetune\u002Fevals\u002Fevals.json",{"path":75,"resourceType":66,"resourceTypeDesc":67,"sizeBytes":76,"sourceHtmlUrl":77},"fixtures\u002Fpreflight_datalist.json",221,"https:\u002F\u002Fgithub.com\u002Fheadmktlucca-ui\u002Fneuroads-lp\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fnv-generate-vae-finetune\u002Ffixtures\u002Fpreflight_datalist.json",{"path":79,"resourceType":66,"resourceTypeDesc":67,"sizeBytes":80,"sourceHtmlUrl":81},"fixtures\u002Fpreflight_dataset\u002FimagesTr\u002Fplaceholder_mri_train.txt",37,"https:\u002F\u002Fgithub.com\u002Fheadmktlucca-ui\u002Fneuroads-lp\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fnv-generate-vae-finetune\u002Ffixtures\u002Fpreflight_dataset\u002FimagesTr\u002Fplaceholder_mri_train.txt",{"path":83,"resourceType":66,"resourceTypeDesc":67,"sizeBytes":80,"sourceHtmlUrl":84},"fixtures\u002Fpreflight_dataset\u002FimagesVal\u002Fplaceholder_mri_val.txt","https:\u002F\u002Fgithub.com\u002Fheadmktlucca-ui\u002Fneuroads-lp\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fnv-generate-vae-finetune\u002Ffixtures\u002Fpreflight_dataset\u002FimagesVal\u002Fplaceholder_mri_val.txt",{"path":86,"resourceType":66,"resourceTypeDesc":67,"sizeBytes":87,"sourceHtmlUrl":88},"fixtures\u002FREADME.md",232,"https:\u002F\u002Fgithub.com\u002Fheadmktlucca-ui\u002Fneuroads-lp\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fnv-generate-vae-finetune\u002Ffixtures\u002FREADME.md",{"path":90,"resourceType":91,"resourceTypeDesc":92,"sizeBytes":93,"sourceHtmlUrl":94},"scripts\u002Frun_vae_finetune.py","SCRIPT","脚本",32915,"https:\u002F\u002Fgithub.com\u002Fheadmktlucca-ui\u002Fneuroads-lp\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fnv-generate-vae-finetune\u002Fscripts\u002Frun_vae_finetune.py",{"path":96,"resourceType":66,"resourceTypeDesc":67,"sizeBytes":97,"sourceHtmlUrl":98},"skill_manifest.yaml",6196,"https:\u002F\u002Fgithub.com\u002Fheadmktlucca-ui\u002Fneuroads-lp\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fnv-generate-vae-finetune\u002Fskill_manifest.yaml",{"path":100,"resourceType":66,"resourceTypeDesc":67,"sizeBytes":101,"sourceHtmlUrl":102},"skill-card.md",3682,"https:\u002F\u002Fgithub.com\u002Fheadmktlucca-ui\u002Fneuroads-lp\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fnv-generate-vae-finetune\u002Fskill-card.md",{"path":104,"resourceType":105,"resourceTypeDesc":106,"sizeBytes":107,"sourceHtmlUrl":108},"skill.oms.sig","OTHER","其他",6601,"https:\u002F\u002Fgithub.com\u002Fheadmktlucca-ui\u002Fneuroads-lp\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fnv-generate-vae-finetune\u002Fskill.oms.sig",{"path":110,"resourceType":91,"resourceTypeDesc":92,"sizeBytes":111,"sourceHtmlUrl":112},"tests\u002Ftest_run_vae_finetune.py",5742,"https:\u002F\u002Fgithub.com\u002Fheadmktlucca-ui\u002Fneuroads-lp\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fnv-generate-vae-finetune\u002Ftests\u002Ftest_run_vae_finetune.py",{"path":114,"resourceType":66,"resourceTypeDesc":67,"sizeBytes":115,"sourceHtmlUrl":116},"validators\u002Foutput_schema.json",4061,"https:\u002F\u002Fgithub.com\u002Fheadmktlucca-ui\u002Fneuroads-lp\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fnv-generate-vae-finetune\u002Fvalidators\u002Foutput_schema.json",[118,145,169,195,213,248],{"skillNo":119,"name":120,"nameZh":6,"description":121,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":122,"licenseFileUrl":6,"sourceHtmlUrl":123,"categories":124,"keywords":133,"publishedAt":33},"01M6PTDCZTXTGSTX4RFK901YSZ","xunit-skill","Generates xUnit.net tests in C#. Covers Fact\u002FTheory, constructor injection, IClassFixture, and FluentAssertions. Use when user mentions \"xUnit\", \"[Fact]\", \"[Theory]\", \"Assert.Equal\", \"C# xUnit\". Triggers on: \"xUnit\", \"[Fact]\", \"[Theory]\", \"Assert.Equal C#\", \"xUnit.net\".","MIT","https:\u002F\u002Fgithub.com\u002Fheadmktlucca-ui\u002Fneuroads-lp\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fxunit-skill\u002FSKILL.md",[125,130],{"categoryNo":126,"categoryName":127,"taxonomyType":128,"taxonomyTypeDesc":129},"01JBSEEDCAT000000000000008","测试与质量","SCENARIO","使用场景",{"categoryNo":131,"categoryName":132,"taxonomyType":128,"taxonomyTypeDesc":129},"01JBSEEDCAT000000000000023","Skill与智能体开发",[134,135,136,137,138,139,140,141,142,143,144],"xunit","xunit skill","testing","injection","user","use","tests","triggers","unit","unit-testing","C#",{"skillNo":146,"name":147,"nameZh":6,"description":148,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":122,"licenseFileUrl":6,"sourceHtmlUrl":149,"categories":150,"keywords":153,"publishedAt":33},"01M6PTCB59ZTG5FTMWGPYEMMBP","xcuitest-skill","Generates XCUITest UI tests for iOS\u002FiPadOS apps in Swift. Apple's native testing framework for reliable, fast UI automation. Supports local simulators and TestMu AI cloud real devices. Use when user mentions \"XCUITest\", \"XCTest\", \"iOS UI test\", \"Swift test\", \"XCUIApplication\". Triggers on: \"XCUITest\", \"XCTest UI\", \"iOS UI test\", \"Swift UI test\", \"XCUIApplication\", \"TestMu\".","https:\u002F\u002Fgithub.com\u002Fheadmktlucca-ui\u002Fneuroads-lp\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fxcuitest-skill\u002FSKILL.md",[151,152],{"categoryNo":126,"categoryName":127,"taxonomyType":128,"taxonomyTypeDesc":129},{"categoryNo":131,"categoryName":132,"taxonomyType":128,"taxonomyTypeDesc":129},[154,155,136,156,157,158,159,160,139,161,162,163,164,165,140,141,166,167,32,168],"xcuitest","xcuitest skill","automation","test","testing framework","ios","devices","mobile","mobile-testing","ui test","local","apple","apps","native","objective",{"skillNo":170,"name":171,"nameZh":6,"description":172,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":122,"licenseFileUrl":6,"sourceHtmlUrl":173,"categories":174,"keywords":179,"publishedAt":33},"01M6PTATMNTY9NF4J7KSR76YK6","world-builder","Create and manage generative game zones for Dorothy's Pokemon-style world. Use this skill when creating, updating, or designing game worlds via MCP tools.","https:\u002F\u002Fgithub.com\u002Fheadmktlucca-ui\u002Fneuroads-lp\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fworld-builder\u002FSKILL.md",[175,178],{"categoryNo":176,"categoryName":177,"taxonomyType":128,"taxonomyTypeDesc":129},"01JBSEEDCAT000000000000015","视觉设计",{"categoryNo":131,"categoryName":132,"taxonomyType":128,"taxonomyTypeDesc":129},[180,181,182,183,184,185,186,187,139,188,189,190,191,192,193,32,194],"builder","world","world builder","MCP","create","mcp tools","Tools","game","pokemon","manage","style","via","theme","zone","generative",{"skillNo":196,"name":197,"nameZh":6,"description":198,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":122,"licenseFileUrl":6,"sourceHtmlUrl":199,"categories":200,"keywords":203,"publishedAt":33},"01M6PT9Z92JTSQEHE1QR0NNW5F","webdriverio-skill","Generates WebdriverIO (WDIO) automation tests in JavaScript or TypeScript. Supports local and TestMu AI cloud. Use when user mentions \"WebdriverIO\", \"WDIO\", \"wdio.conf\", \"browser.url\", \"$\", \"$$\". Triggers on: \"WebdriverIO\", \"WDIO\", \"wdio\", \"browser.$\".","https:\u002F\u002Fgithub.com\u002Fheadmktlucca-ui\u002Fneuroads-lp\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fwebdriverio-skill\u002FSKILL.md",[201,202],{"categoryNo":126,"categoryName":127,"taxonomyType":128,"taxonomyTypeDesc":129},{"categoryNo":131,"categoryName":132,"taxonomyType":128,"taxonomyTypeDesc":129},[204,136,205,156,206,207,208,209,138,139,210,164,140,141,211,212],"webdriverio skill","typescript","javascript","browser","cloud","e2e","e2e-testing","URL","conf",{"skillNo":214,"name":215,"nameZh":6,"description":216,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":122,"licenseFileUrl":6,"sourceHtmlUrl":217,"categories":218,"keywords":228,"publishedAt":33},"01M6PT9NVK36ZWCQ69YXK3FR4K","web-design-guidelines","Web platform design and accessibility guidelines. Use when building web interfaces, auditing accessibility, implementing responsive layouts, or reviewing web UI code. Triggers on tasks involving HTML, CSS, web components, WCAG compliance, responsive design, or web performance.","https:\u002F\u002Fgithub.com\u002Fheadmktlucca-ui\u002Fneuroads-lp\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fweb\u002FSKILL.md",[219,222,223],{"categoryNo":220,"categoryName":221,"taxonomyType":128,"taxonomyTypeDesc":129},"01JBSEEDCAT000000000000009","前端开发",{"categoryNo":176,"categoryName":177,"taxonomyType":128,"taxonomyTypeDesc":129},{"categoryNo":224,"categoryName":225,"taxonomyType":226,"taxonomyTypeDesc":227},"01JBSEEDCAT000000000000032","设计师","PROFESSION","适用职业",[229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,141,247],"design","web","guidelines","web design guidelines","web design","css","performance","components","web components","tasks","code","web performance","ui","platform design","html","responsive design","responsive","platform","implementing",{"skillNo":249,"name":250,"nameZh":6,"description":251,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":122,"licenseFileUrl":6,"sourceHtmlUrl":252,"categories":253,"keywords":256,"publishedAt":33},"01M6PT9A3JKRE3X34276F2FW5R","watchos-design-guidelines","Apple Human Interface Guidelines for Apple Watch. Use when building watchOS apps, complications, or workout features. Triggers on tasks involving Watch UI, Digital Crown, glanceable interfaces, or wrist-based interactions.","https:\u002F\u002Fgithub.com\u002Fheadmktlucca-ui\u002Fneuroads-lp\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fwatchos\u002FSKILL.md",[254,255],{"categoryNo":176,"categoryName":177,"taxonomyType":128,"taxonomyTypeDesc":129},{"categoryNo":224,"categoryName":225,"taxonomyType":226,"taxonomyTypeDesc":227},[229,231,257,238,241,139,258,259,165,246,260,141,166,261,32,262,263],"watchos design guidelines","workout","human","watch","interface","platform-design","features"]