-
Notifications
You must be signed in to change notification settings - Fork 169
Minor pruning update #397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minor pruning update #397
Conversation
Signed-off-by: Keval Morabia <[email protected]>
WalkthroughUpdates adjust example code signatures, introduce a registry parameter to NAS conversion for mode application, and switch pruning to convert models before search. Public API changes: convert(model, mode, registry=NASModeRegistry). Other flows and error handling remain unchanged. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Client
participant Conversion as convert(model, mode, registry)
participant Registry as registry.apply_mode
Client->>Conversion: call convert(model, mode, registry?)
Note over Conversion: Default registry = NASModeRegistry
Conversion->>Registry: apply_mode(model, mode)
Registry-->>Conversion: returns converted model
Conversion-->>Client: converted model
sequenceDiagram
autonumber
actor User
participant Prune as prune(model, ...)
participant MTN as mtn.convert
participant Search as mtn.search
User->>Prune: invoke prune(model, ...)
Prune->>MTN: convert(model, mode)
MTN-->>Prune: DynamicModule model
Prune->>Search: search(DynamicModule, ...)
Search-->>Prune: search results
Prune-->>User: results
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
examples/pruning/README.md (1)
58-59
: Verify the undefined variables in the example code.The example shows
evaluate_and_print_results(prefix, forward_step, train_iterator, model, ...)
but the variablesprefix
,forward_step
, andtrain_iterator
are not defined in the example snippet. Consider adding brief comments or placeholder definitions to make the example more complete and avoid confusion for users following the example.Example addition:
+# Define the evaluation parameters +prefix = "train" +forward_step = ... # Your forward step function +train_iterator = ... # Your training data iterator + def forward_loop(_): evaluate_and_print_results(prefix, forward_step, train_iterator, model, ...)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
examples/pruning/README.md
(3 hunks)modelopt/torch/nas/conversion.py
(2 hunks)modelopt/torch/prune/pruning.py
(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
modelopt/torch/nas/conversion.py (2)
modelopt/torch/opt/mode.py (1)
_ModeRegistryCls
(267-344)modelopt/torch/opt/conversion.py (1)
apply_mode
(342-429)
modelopt/torch/prune/pruning.py (1)
modelopt/torch/nas/conversion.py (1)
convert
(29-89)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: linux
- GitHub Check: wait-checks / wait
- GitHub Check: wait-checks / wait
- GitHub Check: code-quality
- GitHub Check: build-docs
🔇 Additional comments (4)
modelopt/torch/prune/pruning.py (1)
201-202
: LGTM! Clean refactoring to use the NAS conversion API.The change from
apply_mode
tomtn.convert
withPruneModeRegistry
is consistent with the updatedconvert
API that now accepts a registry parameter. This provides better separation of concerns by delegating mode application and DynamicModule conversion to the NAS layer.examples/pruning/README.md (2)
69-69
: Good clarification for handling model lists.The comment helpfully clarifies that if the model is a list, users should pass
model[0]
to the prune API.
84-84
: LGTM! More specific tutorial reference.The updated link points to a specific NeMo tutorial for pruning and distillation, which is more helpful than a generic reference.
modelopt/torch/nas/conversion.py (1)
89-89
: LGTM! Correct forwarding of registry parameter.The registry parameter is properly forwarded to
apply_mode
, enabling callers to specify custom mode registries.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #397 +/- ##
==========================================
- Coverage 73.79% 73.78% -0.01%
==========================================
Files 171 171
Lines 17583 17582 -1
==========================================
- Hits 12975 12973 -2
- Misses 4608 4609 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: Keval Morabia <[email protected]>
Minor cleanup
Summary by CodeRabbit
New Features
Documentation
Chores