[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M78841HEY9VT1XKJFFMJWD3S":3,"skill-same:01M78841HEY9VT1XKJFFMJWD3S":83},{"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":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":33,"commitSha":34,"skillDirectory":35,"forksCount":14,"repositoryHtmlUrl":36,"repositoryHomepageUrl":6,"ownerHtmlUrl":37,"ownerBlogUrl":38,"ownerDescription":39,"updatedAt":40,"install":41,"resources":54},"01M78841HEY9VT1XKJFFMJWD3S","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.","Solizardking\u002Ftrain2earn","Solizardking","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F108096810?v=4","01M786KDB10AYV042N0F9BD5B5","Clawd","01M786KDC5C3NPE4W44C5641EZ",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Ftrain2earn\u002Fblob\u002Fmain\u002Fskillhub\u002Fpublic\u002Fapi\u002Fskills\u002Fnvidia\u002Fnv-generate-vae-finetune\u002FSKILL.md",[],[],"2026-11-15 14:19:17",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:-$HOME\u002F.cache\u002Fnvidia-skills\u002Fupstreams\u002FNV-Generate-CTMR-61c4ec7}\" && \\\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- An explicit `NV_GENERATE_ROOT` may point to the caller's local checkout and\n  must contain `configs\u002Fconfig_maisi_vae_train.json`, `scripts\u002Ftransforms.py`,\n  and `scripts\u002Futils.py`. The result records its current commit.\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\nWhen no local checkout is supplied, create the recommended pinned default\ncheckout once:\n\n```bash\nif [ -z \"${NV_GENERATE_ROOT:-}\" ]; then\n  export NV_GENERATE_COMMIT=61c4ec709b84cad468852243c48e250bec732074\n  export NV_GENERATE_ROOT=\"$HOME\u002F.cache\u002Fnvidia-skills\u002Fupstreams\u002FNV-Generate-CTMR-61c4ec7\"\n  if [ ! -d \"$NV_GENERATE_ROOT\u002F.git\" ]; then\n    git clone https:\u002F\u002Fgithub.com\u002FNVIDIA-Medtech\u002FNV-Generate-CTMR.git \"$NV_GENERATE_ROOT\"\n    git -C \"$NV_GENERATE_ROOT\" checkout --detach \"$NV_GENERATE_COMMIT\"\n  fi\nfi\n```\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:-$HOME\u002F.cache\u002Fnvidia-skills\u002Fupstreams\u002FNV-Generate-CTMR-61c4ec7}\" && \\\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:-$HOME\u002F.cache\u002Fnvidia-skills\u002Fupstreams\u002FNV-Generate-CTMR-61c4ec7}\" && \\\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:-$HOME\u002F.cache\u002Fnvidia-skills\u002Fupstreams\u002FNV-Generate-CTMR-61c4ec7}\" && \\\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:-$HOME\u002F.cache\u002Fnvidia-skills\u002Fupstreams\u002FNV-Generate-CTMR-61c4ec7}\" && \\\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- An explicit `NV_GENERATE_ROOT` may point to the caller's local checkout and\n  must contain `configs\u002Fconfig_maisi_vae_train.json`, `scripts\u002Ftransforms.py`,\n  and `scripts\u002Futils.py`. The result records its current commit.\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\nWhen no local checkout is supplied, create the recommended pinned default\ncheckout once:\n\n```bash\nif [ -z \"${NV_GENERATE_ROOT:-}\" ]; then\n  export NV_GENERATE_COMMIT=61c4ec709b84cad468852243c48e250bec732074\n  export NV_GENERATE_ROOT=\"$HOME\u002F.cache\u002Fnvidia-skills\u002Fupstreams\u002FNV-Generate-CTMR-61c4ec7\"\n  if [ ! -d \"$NV_GENERATE_ROOT\u002F.git\" ]; then\n    git clone https:\u002F\u002Fgithub.com\u002FNVIDIA-Medtech\u002FNV-Generate-CTMR.git \"$NV_GENERATE_ROOT\"\n    git -C \"$NV_GENERATE_ROOT\" checkout --detach \"$NV_GENERATE_COMMIT\"\n  fi\nfi\n```\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:-$HOME\u002F.cache\u002Fnvidia-skills\u002Fupstreams\u002FNV-Generate-CTMR-61c4ec7}\" && \\\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:-$HOME\u002F.cache\u002Fnvidia-skills\u002Fupstreams\u002FNV-Generate-CTMR-61c4ec7}\" && \\\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:-$HOME\u002F.cache\u002Fnvidia-skills\u002Fupstreams\u002FNV-Generate-CTMR-61c4ec7}\" && \\\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":24,"description":7,"allowed-tools":32},{"tags":25,"author":31},[26,27,28,29,30],"MedTech","CT","MRI","VAE","finetune","NVIDIA MedTech Team","Bash","main","86cc27ffd16af6cb85948f1155578e6f3f61cc4c","skillhub\u002Fpublic\u002Fapi\u002Fskills\u002Fnvidia\u002Fnv-generate-vae-finetune","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Ftrain2earn","https:\u002F\u002Fgithub.com\u002FSolizardking","https:\u002F\u002Fmusebook.trade","Got a mile high and never came down","2026-10-08 11:52:53",{"source":8,"skillName":5,"commands":42,"prompt":52,"zipAvailable":53},[43,46,49],{"tool":44,"command":45},"npx","npx skills add Solizardking\u002Ftrain2earn --skill nv-generate-vae-finetune",{"tool":47,"command":48},"bunx","bunx skills add Solizardking\u002Ftrain2earn --skill nv-generate-vae-finetune",{"tool":50,"command":51},"pnpm","pnpm dlx skills add Solizardking\u002Ftrain2earn --skill nv-generate-vae-finetune","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FSolizardking\u002Ftrain2earn\u002Fblob\u002Fmain\u002Fskillhub\u002Fpublic\u002Fapi\u002Fskills\u002Fnvidia\u002Fnv-generate-vae-finetune\u002FSKILL.md",true,[55,61,65,71,75,79],{"path":56,"resourceType":57,"resourceTypeDesc":58,"sizeBytes":59,"sourceHtmlUrl":60},"BENCHMARK.md","REFERENCE","参考文档",4047,"https:\u002F\u002Fgithub.com\u002FSolizardking\u002Ftrain2earn\u002Fblob\u002Fmain\u002Fskillhub\u002Fpublic\u002Fapi\u002Fskills\u002Fnvidia\u002Fnv-generate-vae-finetune\u002FBENCHMARK.md",{"path":62,"resourceType":57,"resourceTypeDesc":58,"sizeBytes":63,"sourceHtmlUrl":64},"metadata.json",347,"https:\u002F\u002Fgithub.com\u002FSolizardking\u002Ftrain2earn\u002Fblob\u002Fmain\u002Fskillhub\u002Fpublic\u002Fapi\u002Fskills\u002Fnvidia\u002Fnv-generate-vae-finetune\u002Fmetadata.json",{"path":66,"resourceType":67,"resourceTypeDesc":68,"sizeBytes":69,"sourceHtmlUrl":70},"scripts\u002Frun_vae_finetune.py","SCRIPT","脚本",32915,"https:\u002F\u002Fgithub.com\u002FSolizardking\u002Ftrain2earn\u002Fblob\u002Fmain\u002Fskillhub\u002Fpublic\u002Fapi\u002Fskills\u002Fnvidia\u002Fnv-generate-vae-finetune\u002Fscripts\u002Frun_vae_finetune.py",{"path":72,"resourceType":57,"resourceTypeDesc":58,"sizeBytes":73,"sourceHtmlUrl":74},"skill_manifest.yaml",6385,"https:\u002F\u002Fgithub.com\u002FSolizardking\u002Ftrain2earn\u002Fblob\u002Fmain\u002Fskillhub\u002Fpublic\u002Fapi\u002Fskills\u002Fnvidia\u002Fnv-generate-vae-finetune\u002Fskill_manifest.yaml",{"path":76,"resourceType":57,"resourceTypeDesc":58,"sizeBytes":77,"sourceHtmlUrl":78},"skill-card.md",4121,"https:\u002F\u002Fgithub.com\u002FSolizardking\u002Ftrain2earn\u002Fblob\u002Fmain\u002Fskillhub\u002Fpublic\u002Fapi\u002Fskills\u002Fnvidia\u002Fnv-generate-vae-finetune\u002Fskill-card.md",{"path":80,"resourceType":57,"resourceTypeDesc":58,"sizeBytes":81,"sourceHtmlUrl":82},"verification.json",1671,"https:\u002F\u002Fgithub.com\u002FSolizardking\u002Ftrain2earn\u002Fblob\u002Fmain\u002Fskillhub\u002Fpublic\u002Fapi\u002Fskills\u002Fnvidia\u002Fnv-generate-vae-finetune\u002Fverification.json",[84,92,100,108,115,123],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":88,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":19},"01M78B94RSCAKMH1QS79VE6DG9","testing","For testing with Light Protocol programs and clients on localnet, devnet, and mainnet validation.","MIT","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Ftrain2earn\u002Fblob\u002Fmain\u002Fskillhub\u002Fskills\u002Ftesting\u002FSKILL.md",[],[],{"skillNo":93,"name":94,"nameZh":6,"description":95,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":88,"licenseFileUrl":96,"sourceHtmlUrl":97,"categories":98,"keywords":99,"publishedAt":19},"01M78B81BKY8RX12HETPG8YKWK","qedgen","Formally verify programs by writing Lean 4 proofs. Trigger this skill whenever the user wants to formally verify code, generate Lean 4 proofs, prove properties about algorithms or smart contracts, verify invariants, convert program logic into formal specifications, or anything involving Lean 4 and formal verification. Also trigger when the user mentions \"qedgen\", \"lean proof\", \"formal proof\", \"verify my code\", \"prove correctness\", \"formal verification\", or wants mathematical guarantees about their implementation.","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Ftrain2earn\u002Fblob\u002Fmain\u002Fskillhub\u002Fskills\u002Fsolana-formal-verification\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Ftrain2earn\u002Fblob\u002Fmain\u002Fskillhub\u002Fskills\u002Fsolana-formal-verification\u002FSKILL.md",[],[],{"skillNo":101,"name":102,"nameZh":6,"description":103,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":88,"licenseFileUrl":104,"sourceHtmlUrl":105,"categories":106,"keywords":107,"publishedAt":19},"01M78B7Q7C5K54E01DN83A60KG","solana-dev","Use when user asks to \"build a Solana dapp\", \"write an Anchor program\", \"create a token\", \"debug Solana errors\", \"set up wallet connection\", \"test my Solana program\", \"deploy to devnet\", or \"explain Solana concepts\" (rent, accounts, PDAs, CPIs, etc.). Also use for quick on-chain lookups via public RPC + curl — \"what's the balance of \u003Cwallet>\", \"look up transaction \u003Csig>\", \"token balance for \u003Caccount>\", \"check this address on mainnet\u002Fdevnet\". End-to-end Solana development playbook covering wallet connection, Anchor\u002FPinocchio programs, Codama client generation, LiteSVM\u002FMollusk\u002FSurfpool testing, security checklists, and JSON-RPC curl lookups against public clusters. Integrates with the Solana MCP server for live documentation search. Prefers framework-kit (@solana\u002Fclient + @solana\u002Freact-hooks) for UI, wallet-standard-first connection (incl. ConnectorKit), @solana\u002Fkit for client\u002FRPC code, and @solana\u002Fweb3-compat for legacy boundaries.","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Ftrain2earn\u002Fblob\u002Fmain\u002Fskillhub\u002Fskills\u002Fsolana-dev\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Ftrain2earn\u002Fblob\u002Fmain\u002Fskillhub\u002Fskills\u002Fsolana-dev\u002FSKILL.md",[],[],{"skillNo":109,"name":110,"nameZh":6,"description":111,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":88,"licenseFileUrl":6,"sourceHtmlUrl":112,"categories":113,"keywords":114,"publishedAt":19},"01M78B7HXD6N6GWKSVRQ8F6Q31","solana-common-errors","Diagnose and fix common Solana development errors — GLIBC mismatches, Anchor version conflicts, cargo build-sbf \u002F platform-tools failures, LiteSVM issues, edition2024 crate pins, RPC airdrops, and Anchor 0.29→0.32 migrations. Use when builds fail, Anchor CLI won't install, or CI breaks on Debian\u002FUbuntu.","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Ftrain2earn\u002Fblob\u002Fmain\u002Fskillhub\u002Fskills\u002Fsolana-common-errors\u002FSKILL.md",[],[],{"skillNo":116,"name":117,"nameZh":6,"description":118,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":119,"sourceHtmlUrl":120,"categories":121,"keywords":122,"publishedAt":19},"01M78B6T7YSYWQ0N4DP40QDXEZ","skill-creator","Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Ftrain2earn\u002Fblob\u002Fmain\u002Fskillhub\u002Fskills\u002Fskill-creator\u002Flicense.txt","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Ftrain2earn\u002Fblob\u002Fmain\u002Fskillhub\u002Fskills\u002Fskill-creator\u002FSKILL.md",[],[],{"skillNo":124,"name":125,"nameZh":6,"description":126,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":88,"licenseFileUrl":6,"sourceHtmlUrl":127,"categories":128,"keywords":129,"publishedAt":19},"01M78B1VFT9X5AND7AE1HZPZGF","phantom-wallet-mcp","Execute wallet operations through the Phantom MCP server. Use when the user wants to interact with their Phantom wallet directly — get addresses, transfer SOL or SPL tokens, buy\u002Fswap tokens, sign transactions, and sign messages across Solana, Ethereum, Bitcoin, and Sui. Requires the @phantom\u002Fmcp-server to be configured as an MCP server.","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Ftrain2earn\u002Fblob\u002Fmain\u002Fskillhub\u002Fskills\u002Fphantom-wallet-mcp\u002FSKILL.md",[],[]]