Conversation
|
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. |
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueComment |
This was referenced Sep 23, 2026
Fridah-nv
added this pull request to stack #2538
September 23, 2026 21:57
Adds the `algo_cfg` config surface and the compiler that lowers it, but nothing
that runs a plan yet -- that arrives in the next change. Reviewed on its own,
this is a pure function from (config, model structure) to an ordered list of
stages, plus the rules that reject a plan that cannot be right.
`AlgoCfgEntry` has the same `{<selector>, "cfg": ...}` shape as a
`QuantizerCfgEntry`: `quant_cfg` entries carry quantizer *attributes*,
`algo_cfg` entries carry the ordered list of calibration *algorithms* for the
matched targets. Exactly one selector per entry -- `module_name` for
module-level algorithms where the role is implied, `quantizer_name` when the
role must be chosen explicitly -- enforced at config-construction time.
`compile_algo_cfg(config, model)` reads the quantized model's structure to
resolve globs and validate, but mutates nothing and runs no forward. So a bad
plan fails before any expensive calibration, it is testable without running a
model, and the plan is a pure function of (config, structure) -- hence identical
on every rank, which is what will keep predicate scoping from desynchronizing
collectives.
Eight rules, one named function each, all reported in a single pass: an empty
scope, an unscopable algorithm given a scope, a whole-module algorithm whose
scope is not closed over its modules, an algorithm aimed at a role it does not
improve, fusible siblings split across pipelines, an algorithm whose own output
violates its precondition, and a stage whose every write is overwritten before
anyone reads it. Overlap is judged per state token *and* per quantizer role, so
two stages sharing a module do not conflict if they write different roles.
`derive_handoff` reports when an earlier stage already produced what a later one
needs, using coverage rather than overlap: a narrow producer must not let a wider
consumer skip its own initialization.
`algorithm` lowers through the same path as its all-`"*"` case, so there is no
second engine, and an `algo_cfg` that does not cover the whole model leaves the
rest to `algorithm` via an explicit exclusion rather than an implicit fallthrough.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Signed-off-by: Fridah-nv <201670829+Fridah-nv@users.noreply.github.com>
Fridah-nv
force-pushed
the
fridah/algo-cfg-3-compile
branch
from
September 23, 2026 22:02
1ca7f58 to
9e617c8
Compare
Contributor
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## fridah/algo-cfg-2-write-mask #2536 +/- ##
================================================================
+ Coverage 68.97% 69.08% +0.11%
================================================================
Files 606 606
Lines 67315 67623 +308
================================================================
+ Hits 46429 46717 +288
- Misses 20886 20906 +20
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Brief
What changes: Configs can express per-scope algorithm pipelines; invalid ones are rejected with a reason. Nothing runs them until 4/4 (#2537).
How:
AlgoCfgEntrymirrors the shape of aquant_cfgentry — one selector plus acfg— andcompile_algo_cfglowers entries plusalgorithminto an ordered list of stages. Compilation is a pure function of the config and the model's structure: no mutation, no forward pass. Eight validation rules, one function each, all reported in a single pass.What does this PR do?
Type of change: new feature
Stack 3 of 4, splitting #2292. Base: #2535. This is the design review — the other three are mechanical by comparison.
algo_cfgThe config surface
An
algo_cfgentry has the same{<selector>, "cfg": ...}shape as aquant_cfgentry:quant_cfgentries carry quantizer attributes,algo_cfgentries carry the ordered algorithms for the matched targets. Exactly one selector per entry —module_namefor module-level algorithms where the role is implied,quantizer_namewhen the role must be chosen explicitly — enforced at config-construction time by a pydantic before-validator, so a malformed entry fails before the model is ever consulted.This expresses two things the current surface cannot: different algorithms for different parts of the model, and an ordered pipeline on the same targets where each stage consumes the previous one's mutated weights and scales.
Compile is a pure function
compile_algo_cfg(config, model)reads the quantized model's structure to resolve globs and validate, but mutates nothing, runs no forward and touches no data. So a bad config fails before any expensive calibration, it is testable without running a model, and the plan is a pure function of(config, structure)— hence identical on every rank, which is what will keep predicate scoping from desynchronizing collectives.Nothing executes a plan in this PR. That is PR 4. Reviewed on its own, this is a function and the rules that reject a plan that cannot be right.
The rules
Eight, one named function each, all reported in a single pass rather than failing at the first:
algo_cfgshared across numerics may name a role one of them turns offawq_litetwice folds a scale into an already-smoothed weight)Overlap is judged per state token and per quantizer role, so two stages sharing a module do not conflict if they write different roles.
derive_handoffreports when an earlier stage already produced what a later one needs, using coverage rather than overlap: a narrow producer must not let a wider consumer skip its own initialization.algorithmlowers through the same path as its all-"*"case, so there is no second engine, and analgo_cfgthat does not cover the whole model leaves the rest toalgorithmvia an explicit exclusion rather than an implicit fallthrough.What validation was worth
Exhaustive compile sweeps over the finished stack — every 2- and 3-algorithm chain across three quantizer layouts (8,712 compiles) plus the scoping surface (4,422) — found four defects, all in what state a rule is evaluated against rather than in the rule logic. Three are in PR 4 with the grid contract they belong to; the fourth (disabled quantizers counting as targets) is here.
Testing
tests/unit/torch/quantization/test_algo_cfg.py— 43 tests: lowering, every rule, derived handoff, coverage, and three fixture shapes (single-level quantizer, SequentialQuantizer, weight-only/no-forward).pytest tests/unit/torch/quantization/→ 1178 passed, 8 skipped, plus the same two pre-existingtest_huggingface.pyfailures and one pre-existing collection error described in #2534.Before your PR is "Ready for review"
algo_cfgis opt-in; without it nothing changes.CONTRIBUTING.md: N/AAdditional Information
The config surface and how much of the capability contract belongs in a first cut are what I would most like feedback on.
🤖 Generated with Claude Code