Skip to content

Restructure skills/ to be operator-focused#32

Merged
Can-Zhao merged 4 commits into
NVIDIA-Medtech:mainfrom
Can-Zhao:skills-restructure
May 28, 2026
Merged

Restructure skills/ to be operator-focused#32
Can-Zhao merged 4 commits into
NVIDIA-Medtech:mainfrom
Can-Zhao:skills-restructure

Conversation

@Can-Zhao

@Can-Zhao Can-Zhao commented May 27, 2026

Copy link
Copy Markdown
Contributor

Skills now follow a uniform template oriented at someone running inference: Command to run → How to configure a run → Output → Related scripts → Related skills. Algorithm step-by-step walkthroughs and internal function-args tables removed; workflow figures kept.

Changes per skill:

  • skills/infer_mask-generation.md → renamed to infer_mask-only.md to parallel infer_image-only. Body rewritten around the two mask-acquisition paths (Path A diffusion-from-scratch vs Path B training-mask DB lookup) and the anatomy_size 10-d slot table.

  • infer_image-only.md: restructured around ## How to configure a run (6 numbered steps: modality, AE knobs, dim/spacing from FOV, cfg_guidance_scale_modality, cfg_guidance_scale_tumor N/A, num_inference_steps). New end-to-end worked example: T1-axial rflow-mr-brain with concrete dim and spacing values. CFG section spells out "classifier-free guidance" at first use and links to the per-plane FOV table in docs/inference.md.

  • infer_image-from-mask.md: rewritten as a CLI-operator guide — command to run, input mask format and how to produce one (nv-segment-ct + add_body_envelope, or other segmenter + remap), config knob explanation including cfg_guidance_scale_tumor and the CT-only scope, output file layout. Cross-links to infer_mask-image-paired for the GPU-memory presets.

  • infer_mask-image-paired.md: keeps the LDMSampler dispatch flowchart; drops the algorithmic "Two paths in detail" prose, internal LDMSampler.init state table, and Quality-check loop details. Gains a 6-step ## How to configure a run mirroring infer_image-only, with a GPU-memory presets table (output_size + AE sliding-window knobs by GPU) drawn from the shipped config_infer_<XXg>_<dim>.json files. End-to-end Path B chest CT example.

  • download-models.md: section name standardization (Code referenceRelated scripts) and cross-reference style brought in line with the other skills ([name](name.md)).

Skills now follow a uniform template oriented at someone running
inference: Command to run → How to configure a run → Output → Related
scripts → Related skills. Algorithm step-by-step walkthroughs and
internal function-args tables removed; workflow figures kept.

Changes per skill:

- `skills/infer_mask-generation.md` → renamed to `infer_mask-only.md`
  to parallel `infer_image-only`. Body rewritten around the two
  mask-acquisition paths (Path A diffusion-from-scratch vs Path B
  training-mask DB lookup) and the `anatomy_size` 10-d slot table.

- `infer_image-only.md`: restructured around `## How to configure a
  run` (6 numbered steps: modality, AE knobs, dim/spacing from FOV,
  cfg_guidance_scale_modality, cfg_guidance_scale_tumor N/A,
  num_inference_steps). New end-to-end worked example: T1-axial
  rflow-mr-brain with concrete `dim` and `spacing` values. CFG
  section spells out "classifier-free guidance" at first use and
  links to the per-plane FOV table in docs/inference.md.

- `infer_image-from-mask.md`: rewritten as a CLI-operator guide —
  command to run, input mask format and how to produce one
  (nv-segment-ct + add_body_envelope, or other segmenter + remap),
  config knob explanation including cfg_guidance_scale_tumor and the
  CT-only scope, output file layout. Cross-links to
  infer_mask-image-paired for the GPU-memory presets.

- `infer_mask-image-paired.md`: keeps the LDMSampler dispatch
  flowchart; drops the algorithmic "Two paths in detail" prose,
  internal LDMSampler.__init__ state table, and Quality-check loop
  details. Gains a 6-step `## How to configure a run` mirroring
  `infer_image-only`, with a GPU-memory presets table
  (output_size + AE sliding-window knobs by GPU) drawn from the
  shipped `config_infer_<XXg>_<dim>.json` files. End-to-end Path B
  chest CT example.

- `download-models.md`: section name standardization
  (`Code reference` → `Related scripts`) and cross-reference style
  brought in line with the other skills (`[name](name.md)`).
@Can-Zhao Can-Zhao marked this pull request as ready for review May 27, 2026 19:18
@greptile-apps

greptile-apps Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR restructures the skills/ documentation from algorithm-walkthrough style to a uniform operator-focused template (command → configuration steps → output → related scripts → related skills). infer_mask-generation.md is renamed to infer_mask-only.md to parallel infer_image-only.md, and all four inference skills receive new 6-step "How to configure a run" sections that mirror each other for easy cross-comparison.

  • docs/inference.md corrects the config-key names to cfg_guidance_scale (fixing the misleading cfg_guidance_scale_modality / cfg_guidance_scale_tumor names flagged in previous review threads), and all four inference skills now use the correct key throughout.
  • infer_mask-image-paired.md gains an accurate GPU-memory presets table (verified against the shipped config_infer_<XXg>_<dim>.json files) and a concrete Path-B chest-CT end-to-end example.
  • download-models.md standardises section naming and converts plain-text skill cross-links to relative Markdown links.

Confidence Score: 5/5

Documentation-only restructuring; no executable code changed. All factual claims verified against source files.

Every claim introduced by this PR was cross-checked against the codebase: the GPU-memory presets table matches all nine config_infer files exactly, the corrected cfg_guidance_scale key name is confirmed by diff_model_infer.py line 297, the AE hardcoded values (roi_size=[80,80,80], overlap=0.4) are confirmed in diff_model_infer.py, and the find_masks / find_closest_masks attributions match their respective source files.

No files require special attention. The GPU-memory presets table in skills/infer_mask-image-paired.md is the highest-stakes new content, and it verified cleanly against the shipped config files.

Important Files Changed

Filename Overview
docs/inference.md Corrects two config-key names in the reference table: cfg_guidance_scale_modality → cfg_guidance_scale (in config_maisi_diff_model_*.json) and cfg_guidance_scale_tumor → cfg_guidance_scale (in config_infer.json), with a disambiguation note that the same key name has different semantics depending on which script reads it.
skills/download-models.md Section rename Code reference → Related scripts, table reformatted from symbol-oriented to script-oriented rows, and infer_mask-generation cross-link updated to infer_mask-only. Minimal change, no issues.
skills/infer_image-from-mask.md Rewritten as a CLI operator guide. Internal function-args table and algorithm step-by-step prose replaced with command block, mask format table, Options A/B preprocessing steps, a worked example, and related-scripts table. Content accuracy verified.
skills/infer_image-only.md Restructured around a 6-step How to configure a run section. Adds T1-axial whole-brain worked example, replaces cfg_guidance_scale_modality with the correct cfg_guidance_scale, and accurately notes AE knobs are hardcoded in diff_model_infer.py.
skills/infer_mask-generation.md File deleted — content migrated to the new infer_mask-only.md in operator-focused form. All cross-links in other skills have been updated accordingly.
skills/infer_mask-image-paired.md Gains a 6-step How to configure a run section, a GPU-memory presets table (all 9 rows verified against configs/config_infer__.json), and a Path-B chest-CT end-to-end example. cfg_guidance_scale_tumor corrected to cfg_guidance_scale.
skills/infer_mask-only.md New file replacing infer_mask-generation.md. Covers Path A/B dispatch, the 10-slot anatomy_size vector, output format, and related scripts. find_masks correctly attributed to scripts/find_masks.py; find_closest_masks correctly attributed to LDMSampler in scripts/sample.py.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[User: pick pipeline] --> B{Need to generate mask?}
    B -- "No (have mask already)" --> C[infer_image-from-mask\nscripts/infer_image_from_mask.py\nCT-only]
    B -- "No (unconditional image)" --> D[infer_image-only\nscripts/diff_model_infer.py\nCT or MR]
    B -- "Yes (paired output)" --> E[infer_mask-image-paired\nscripts/inference.py\nCT-only]
    E --> F{controllable_anatomy_size\nnon-empty?}
    F -- "Path A: Yes" --> G[Mask DM DDPM\nscripts/sample_mask.py]
    F -- "Path B: No" --> H[DB lookup\nfind_masks\nscripts/find_masks.py]
    G --> I[MAISI 132-class mask]
    H --> I
    I --> J[Image LDM + ControlNet\nscripts/infer_image_from_mask.py]
    C --> J
    J --> K[Quality check CT\nLDMSampler.quality_check_ct]
    K -- Pass --> L[sample_image.nii.gz + sample_label.nii.gz]
    K -- Fail --> J
    D --> M[unet_3d_seed_modality.nii.gz]
Loading

Reviews (5): Last reviewed commit: "Trim tumor-CFG bullet to satisfy markdow..." | Re-trigger Greptile

Comment thread skills/infer_image-only.md Outdated
Comment thread skills/infer_mask-image-paired.md Outdated
Comment thread skills/infer_mask-only.md
Can-Zhao and others added 3 commits May 27, 2026 12:26
Reviewer flagged that `find_masks` and `find_closest_masks` were
attributed to scripts/sample_mask.py — that's wrong.

- `find_masks` lives in `scripts/find_masks.py:55` (top-level
  function).
- `find_closest_masks` is `LDMSampler.find_closest_masks` —
  a method in `scripts/sample.py:575`, not a standalone function.
- `ldm_conditional_sample_one_mask` IS in `scripts/sample_mask.py`
  (kept).

Fixes in both `infer_mask-only.md` and `infer_mask-image-paired.md`:
split the single "sample_mask = Path A + Path B helpers" row into the
correct three entries (sample_mask.py for Path A, find_masks.py for
Path B exact match, sample.py for the LDMSampler.find_closest_masks
closest-match fallback).
…ills

The skill docs on this branch had been updated to reference the renamed
keys (`cfg_guidance_scale_tumor`, `cfg_guidance_scale_modality`) from
the issue-29-cfg-guidance-mr-docs branch, but the code and configs on
this branch (and on main) still use the original `cfg_guidance_scale`
key. Realign the docs to the actual key name.

The modality-vs-tumor CFG distinction is preserved in prose — anchored
to which script + config file reads the value (modality-CFG in
`config_maisi_diff_model_*.json` via `scripts.diff_model_infer`;
tumor-CFG in `config_infer.json` via `scripts.inference` /
`scripts.infer_image_from_mask`), rather than to a key suffix.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The tumor-CFG bullet in infer_image-from-mask.md was 794 chars (limit
is 700). Drop the trailing recap sentence — the preceding sentence
already explains that the same key gates the modality branch in the
image-only path.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Can-Zhao Can-Zhao merged commit a9a441a into NVIDIA-Medtech:main May 28, 2026
1 check passed
Can-Zhao added a commit to Can-Zhao/NV-Generate-CTMR_MRBrain that referenced this pull request May 28, 2026
…VIDIA-Medtech#31)

Brings the post-restructure skills layout and reorganized
docs/inference.md onto this branch so the cfg key renames can be
re-applied against the now-canonical doc structure.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Can-Zhao added a commit to Can-Zhao/NV-Generate-CTMR_MRBrain that referenced this pull request May 28, 2026
After merging upstream/main (PR NVIDIA-Medtech#32 restructured skills, PR NVIDIA-Medtech#31 reorg'd
docs/inference.md), re-apply the cfg key renames to the new structure:

- `infer_image-only.md` — image-only path uses `cfg_guidance_scale_modality`
  (modality CFG: required `> 0` for MR).
- `infer_image-from-mask.md`, `infer_mask-image-paired.md` — mask-conditioned
  path uses `cfg_guidance_scale_tumor` (CT tumor CFG).
- `docs/inference.md` — both keys differentiated in the knobs table and the
  MR-contrast tuning bullet.

Each skill notes that the legacy un-suffixed `cfg_guidance_scale` key is
still accepted for one release with a `DeprecationWarning`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Can-Zhao added a commit to Can-Zhao/NV-Generate-CTMR_MRBrain that referenced this pull request May 28, 2026
The five operator-focused inference skills under skills/ (added in NVIDIA-Medtech#32)
work as drop-in inputs for AI coding agents (Claude Code, Cursor,
Codex, etc.) — feed one to the agent and it walks the user through the
matching workflow end-to-end. This was previously buried in a one-line
mention under the §2 Quick Start callout; surface it so it's actually
discoverable.

- News: dedicated entry naming all five skills and the AI-agent use case.
- §2 Quick Start callout: rewritten to lead with the AI-agent angle,
  with a note that the same files work as standalone reference.
- §2.2 through §2.6: each subsection gains a "**Skill:** ..." pointer
  to the matching skill file. §2.1 (Installation) and §2.7 (community
  external link) intentionally have no skill pointer.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Can-Zhao added a commit to Can-Zhao/NV-Generate-CTMR_MRBrain that referenced this pull request May 28, 2026
The five operator-focused inference skills under skills/ (added in NVIDIA-Medtech#32)
work as drop-in inputs for AI coding agents (Claude Code, Cursor,
Codex, etc.) — feed one to the agent and it walks the user through the
matching workflow end-to-end. This was previously buried in a one-line
mention under the §2 Quick Start callout; surface it so it's actually
discoverable.

- News: dedicated entry naming all five skills and the AI-agent use case.
- §2 Quick Start callout: rewritten to lead with the AI-agent angle,
  with a note that the same files work as standalone reference.
- §2.2 through §2.6: each subsection gains a "**Skill:** ..." pointer
  to the matching skill file. §2.1 (Installation) and §2.7 (community
  external link) intentionally have no skill pointer.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Can-Zhao added a commit to Can-Zhao/NV-Generate-CTMR_MRBrain that referenced this pull request May 28, 2026
The five operator-focused inference skills under skills/ (added in NVIDIA-Medtech#32)
work as drop-in inputs for AI coding agents (Claude Code, Cursor,
Codex, etc.) — feed one to the agent and it walks the user through the
matching workflow end-to-end. This was previously buried in a one-line
mention under the §2 Quick Start callout; surface it so it's actually
discoverable.

- News: dedicated entry naming all five skills and the AI-agent use case.
- §2 Quick Start callout: rewritten to lead with the AI-agent angle,
  with a note that the same files work as standalone reference.
- §2.2 through §2.6: each subsection gains a "**Skill:** ..." pointer
  to the matching skill file. §2.1 (Installation) and §2.7 (community
  external link) intentionally have no skill pointer.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Can-Zhao added a commit to Can-Zhao/NV-Generate-CTMR_MRBrain that referenced this pull request May 28, 2026
The five operator-focused inference skills under skills/ (added in NVIDIA-Medtech#32)
work as drop-in inputs for AI coding agents (Claude Code, Cursor,
Codex, etc.) — feed one to the agent and it walks the user through the
matching workflow end-to-end. This was previously buried in a one-line
mention under the §2 Quick Start callout; surface it so it's actually
discoverable.

- News: dedicated entry naming all five skills and the AI-agent use case.
- §2 Quick Start callout: rewritten to lead with the AI-agent angle,
  with a note that the same files work as standalone reference.
- §2.2 through §2.6: each subsection gains a "**Skill:** ..." pointer
  to the matching skill file. §2.1 (Installation) and §2.7 (community
  external link) intentionally have no skill pointer.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Can-Zhao added a commit that referenced this pull request May 28, 2026
* Highlight inference skills in README News + Quickstart

The five operator-focused inference skills under skills/ (added in #32)
work as drop-in inputs for AI coding agents (Claude Code, Cursor,
Codex, etc.) — feed one to the agent and it walks the user through the
matching workflow end-to-end. This was previously buried in a one-line
mention under the §2 Quick Start callout; surface it so it's actually
discoverable.

- News: dedicated entry naming all five skills and the AI-agent use case.
- §2 Quick Start callout: rewritten to lead with the AI-agent angle,
  with a note that the same files work as standalone reference.
- §2.2 through §2.6: each subsection gains a "**Skill:** ..." pointer
  to the matching skill file. §2.1 (Installation) and §2.7 (community
  external link) intentionally have no skill pointer.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* Add example AI-agent prompt under Quickstart callout

Drop a concrete one-liner ("Read this README and use the matching
skill to generate a T1 whole-brain MR image.") so readers see exactly
what the agent flow looks like. Pending end-to-end verification with
Claude Code; revert this commit if testing reveals the prompt doesn't
elicit the right behavior.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* Reorder Quick Start preamble: AI-agent skills first, FOV warning second

The previous order led with the FOV/dim/spacing warning, which is only
relevant if the user is hand-tuning configs. Now that skills exist for
every workflow, lead with the AI-agent path (the simpler default) and
demote the hyperparameter warning to a "tuning manually?" callout for
the smaller audience that still needs it.

Also drop the "same files also work as standalone reference" sentence
from the AI callout — the manual-tuning callout below now covers that
audience explicitly.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant