Skip to content

Require PTQ recipe guidance before selecting quantization candidates - #2478

Open
Zhehao-Hu wants to merge 1 commit into
mainfrom
zhehaoh/feature/quant-recipe-search-ptq-guide
Open

Zhehao-Hu wants to merge 1 commit into
mainfrom
zhehaoh/feature/quant-recipe-search-ptq-guide

Conversation

@Zhehao-Hu

@Zhehao-Hu Zhehao-Hu commented Sep 18, 2026

Copy link
Copy Markdown

What does this PR do?

Type of change: documentation

Updates quant-recipe-search to require reading modelopt_recipes/ptq.md before selecting initial or subsequent quantization candidates.

The skill uses the guide to inform quantization scope, KV-cache scheme, and calibration method. It requires inspecting candidate YAMLs and supporting configs, citing relevant guide sections, and explaining deviations. Existing coverage, runtime compatibility, and evaluation checks remain required.

Usage

Invoke quant-recipe-search as usual. The skill reads the guide from the ModelOpt source checkout.

Testing

  • Passed a local Codex skill smoke test recommending an initial NVFP4 candidate for Qwen/Qwen3-8B targeting high-concurrency inference on Blackwell.
  • The test prompt named the skill without explicitly requesting that the agent read ptq.md.
  • Verified successful reads of the updated skill, ptq.md, the selected recipe YAML, and supporting configs before the final recommendation.
  • The agent selected general/ptq/nvfp4_mlp_only-kv_fp8_cast and cited relevant guide sections. It explicitly left coverage, accuracy, and throughput pending validation.

Before your PR is "Ready for review"

Make sure you read and follow Contributor guidelines and your commits are signed (git commit -s -S).

Make sure you read and follow the Security Best Practices (e.g. avoiding hardcoded trust_remote_code=True, torch.load(..., weights_only=False), pickle, etc.).

  • Is this change backward compatible?: ✅
  • If you copied code from any other sources or added a new PIP dependency, did you follow guidance in CONTRIBUTING.md: N/A
  • Did you write any new necessary tests?: N/A
  • Did you update Changelog?: N/A
  • Did you get Claude approval on this PR?: ✅ / ❌ / N/A

Additional Information

This change places the reading requirement in the shared recipe-search skill so consumers receive it directly. Consumers that pin the ModelOpt plugin to a commit must update their pin to adopt it.

Summary by CodeRabbit

  • Documentation
    • Updated the quantization recipe search guidance to require consulting the latest PTQ documentation before selecting candidates.
    • Added guidance for resolving referenced materials, reporting unavailable documentation, and documenting deviations.
    • Clarified that PTQ guidance should inform quantization scope, KV-cache configuration, and calibration method selection.

@copy-pr-bot

copy-pr-bot Bot commented Sep 18, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@coderabbitai

coderabbitai Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: NVIDIA/Model-Optimizer/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 21964e16-2209-4247-91af-5325bc341f3a

📥 Commits

Reviewing files that changed from the base of the PR and between 76c04df and 2e3c80b.

📒 Files selected for processing (1)
  • plugins/modelopt/skills/quant-recipe-search/SKILL.md

Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review.


📝 Walkthrough

Walkthrough

The quantization recipe search skill now requires ModelOpt PTQ recipe guidance before candidate selection. It applies the guidance to quantization scope, KV-cache scheme, and calibration method, and requires citations or explanations for deviations.

Changes

Quantization recipe guidance

Layer / File(s) Summary
Recipe guidance workflow
plugins/modelopt/skills/quant-recipe-search/SKILL.md
The workflow reads the PTQ source guide and imported configurations, reports unreadable guidance, applies the guidance during candidate selection and PTQ, and cites the relevant guidance or explains deviations. References now link the guidance to scope, KV-cache, and calibration decisions.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Other

Suggested reviewers: chadvoegele

Merge Risk: ⚪ Minimal · up to 2e3c8

No actionable merge-blocking issue remains in the reviewed documentation workflow.

🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Security Anti-Patterns ✅ Passed The reviewed range changes only plugins/modelopt/skills/quant-recipe-search/SKILL.md (+22 lines). It adds documentation only. It does not change Python or example code, dependency files, model loadi…
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: requiring PTQ recipe guidance before selecting quantization candidates.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Comment @coderabbitai help to get the list of available commands.

@Zhehao-Hu

Copy link
Copy Markdown
Author

/claude review

Comment on lines +60 to +62
## Recipe Guidance

Before selecting an initial or subsequent ModelOpt candidate, read

This comment was marked as outdated.

claude[bot]

This comment was marked as outdated.

@codecov

codecov Bot commented Sep 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.74%. Comparing base (d23030f) to head (2e3c80b).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2478   +/-   ##
=======================================
  Coverage   70.74%   70.74%           
=======================================
  Files         601      601           
  Lines       66300    66300           
=======================================
  Hits        46906    46906           
  Misses      19394    19394           
Flag Coverage Δ
unit 58.10% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: Zhehao Hu <zhehaoh@nvidia.com>
@Zhehao-Hu
Zhehao-Hu force-pushed the zhehaoh/feature/quant-recipe-search-ptq-guide branch from c3dada5 to 2e3c80b Compare September 18, 2026 22:11
@Zhehao-Hu

Copy link
Copy Markdown
Author

/claude review

Comment on lines +62 to +66
Before choosing a recipe, read `modelopt_recipes/ptq.md` in the source checkout
used for PTQ. Resolve all `modelopt_recipes/...` paths against that checkout.
If it is missing, follow
[Env-1. Get ModelOpt source](../common/environment-setup.md#env-1-get-modelopt-source).
Report if the guide cannot be read.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[SUGGESTION] The "source checkout" requirement is the right call — I confirmed pyproject.toml ships only modelopt_recipes = ["**/*.yml", "**/*.yaml"] as package data, so ptq.md genuinely does not exist in a wheel and a pip-installed user must follow Env-1. But that same asymmetry creates a silent skew this paragraph doesn't close.

What happens: for a pip-installed user, ptq.md comes from a freshly cloned checkout while the YAMLs also exist in the installed wheel. modelopt/recipe/loader.py:_resolve_recipe_path resolves a relative --recipe modelopt_recipes/... filesystem-first (cwd-relative), then falls back to BUILTIN_RECIPES_LIB. So if the PTQ run's cwd is not that checkout, the guide and YAML you reviewed come from the clone while the YAML that actually calibrates comes from the installed library — potentially a different revision.

Why it matters: the fallback is silent for this case. The FutureWarning at modelopt/recipe/loader.py:89 only fires for deprecated tier prefixes, not for a checkout-vs-built-in divergence, so nothing surfaces the mismatch. The cited rationale would describe a recipe that never ran.

Line 70's "ensure the quantization run uses the recipe and imported configs reviewed" states the requirement but names no mechanism. Naming one makes it executable:

Suggested change
Before choosing a recipe, read `modelopt_recipes/ptq.md` in the source checkout
used for PTQ. Resolve all `modelopt_recipes/...` paths against that checkout.
If it is missing, follow
[Env-1. Get ModelOpt source](../common/environment-setup.md#env-1-get-modelopt-source).
Report if the guide cannot be read.
used for PTQ. Resolve all `modelopt_recipes/...` paths against that checkout, and
pass candidates to `ptq` as absolute paths under it (or run PTQ with that
checkout as the working directory) so a relative path cannot fall back to the
installed recipe library at a different revision.

Comment on lines +68 to +72
Use the guide to choose quantization scope, KV-cache scheme, and calibration
method. Inspect the recipe YAML and its imported configs. When handing the
recipe to `ptq`, ensure the quantization run uses the recipe and imported configs
reviewed. Then perform the existing coverage, compatibility, and evaluation
checks.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[SUGGESTION] "Inspect the recipe YAML and its imported configs" + "ensure the quantization run uses the recipe and imported configs reviewed" is not achievable as literally written for the general-recipe path, because the skill you delegate to steers away from YAMLs there.

plugins/modelopt/skills/ptq/SKILL.md:71 says: "General PTQ recipes in modelopt_recipes/general/ptq/ correspond to the same formats — --qformat is the simpler way to use them." A --qformat nvfp4 run loads no recipe YAML at all, so whenever this guidance leads to a general scheme (the common case for a first candidate — ptq.md §Choosing a general recipe), the delegated run can legitimately never touch the file whose sections you just cited. The instruction then either blocks the documented ptq path or gets quietly ignored.

Model-specific recipes are unaffected — ptq/SKILL.md:56 already prefers --recipe <path> and already requires inspecting include/exclude patterns, which composes cleanly with this section.

Worth splitting the two cases explicitly, e.g.:

Use the guide to choose quantization scope, KV-cache scheme, and calibration
method. Inspect the recipe YAML and its imported configs. When handing a recipe
to `ptq`, keep the reviewed artifacts authoritative: pass `--recipe` so the run
loads exactly what you inspected. `--qformat` is acceptable only for a general
scheme whose `modelopt_recipes/general/ptq/` YAML was the basis of the review —
note that substitution in the portfolio table. Then perform the existing
coverage, compatibility, and evaluation checks.

@NVIDIA NVIDIA deleted a comment from claude Bot Sep 18, 2026
@NVIDIA NVIDIA deleted a comment from claude Bot Sep 18, 2026
@claude

claude Bot commented Sep 18, 2026

Copy link
Copy Markdown

Claude review — quant-recipe-search PTQ guidance requirement

Scope: full review. 1 file changed (+22/−0), documentation-only: plugins/modelopt/skills/quant-recipe-search/SKILL.md. For verification I also read modelopt_recipes/ptq.md headings, plugins/modelopt/skills/common/environment-setup.md, plugins/modelopt/skills/ptq/SKILL.md Step 3, modelopt/recipe/loader.py::_resolve_recipe_path, and the modelopt_recipes packaging rules in pyproject.toml. No modelopt/ runtime change, so mode/state composition, export, and checkpoint-compat categories are not in play.

Findings — CRITICAL: 0, IMPORTANT: 0, SUGGESTION: 2

Prior review findings are resolved. My earlier pass on c3dada5a raised one IMPORTANT and two SUGGESTIONs; all three are addressed in 2e3c80bc:

  • IMPORTANT (MODELOPT_RECIPE_ROOT honored in only one paragraph) — resolved by dropping the env var entirely in favor of "the source checkout used for PTQ," which needs no new convention and cannot disagree with _resolve_recipe_path.
  • SUGGESTION (undefined "catalog revision has not changed" reuse condition) — resolved with concrete triggers: pulling changes, switching branches or checkouts, or editing the guide.
  • SUGGESTION (not wired into sequential execution) — resolved; the requirement now appears in Design Workflow step 3 and in the References list, not just its own section.

Verified as correct:

  • Every section the text promises exists in modelopt_recipes/ptq.md: Model-body schemes / Scoped schemes (scope), KV-cache schemes, Calibration variants, Choosing a general recipe, Model-specific recipes.
  • The "source checkout" framing is not over-cautious — it is required. pyproject.toml declares modelopt_recipes = ["**/*.yml", "**/*.yaml"] as package data, so ptq.md ships in no wheel and a pip-installed user really must go through Env-1. Routing the missing case to Env-1 is exactly right.
  • The relative link and anchor both resolve: ../common/environment-setup.md from quant-recipe-search/ lands on the real file, and the Env-1. Get ModelOpt source heading yields the anchor the link uses.
  • Edited in the canonical plugin tree (plugins/modelopt/skills/) per CLAUDE.md, so the .agents/skills and .claude/skills symlinks pick it up with no extra change.

The two SUGGESTIONs — both fall out of the same asymmetry the PR creates, and neither blocks:

  1. Checkout-vs-wheel revision skew. Since ptq.md exists only in a clone but the YAMLs also exist in the wheel, and _resolve_recipe_path resolves a relative --recipe cwd-first then falls back to BUILTIN_RECIPES_LIB, a run whose cwd is not the checkout can calibrate a different revision than the one reviewed. The fallback is silent here — the FutureWarning at modelopt/recipe/loader.py:89 fires only for deprecated tier prefixes. Line 70 states the requirement but names no mechanism; absolute paths under the resolved checkout (or cwd set to it) would make it executable.
  2. --qformat bypasses the reviewed YAML. ptq/SKILL.md:71 presents --qformat as "the simpler way" to use general recipes, and it loads no YAML — so for a general scheme the delegated run may never touch the file whose sections were cited, making "ensure the quantization run uses the recipe and imported configs reviewed" unachievable as written. Model-specific recipes are fine; ptq/SKILL.md:56 already prefers --recipe and already requires inspecting include/exclude patterns.

Risk: low. Documentation-only, additive, no runtime/checkpoint/public-API surface, backward compatible as the PR body states. The pin caveat for consumers tracking the plugin at a commit is correctly called out in Additional Information. Approving — the two SUGGESTIONs sharpen the cross-skill hand-off and do not block.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude review passed — no blocking issues found. LGTM

@cjluo-nv cjluo-nv left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bot review (claude-opus-5) — DM the bot to share feedback.

Approving: a 22-line, docs-only addition to quant-recipe-search/SKILL.md that is internally consistent — modelopt_recipes/ptq.md exists and does cover scope, KV-cache, and calibration, and the ../common/environment-setup.md#env-1-get-modelopt-source link and anchor both resolve.

No action needed.

@Zhehao-Hu
Zhehao-Hu marked this pull request as ready for review September 18, 2026 22:40
@Zhehao-Hu
Zhehao-Hu requested a review from a team as a code owner September 18, 2026 22:40
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.

2 participants