-
Notifications
You must be signed in to change notification settings - Fork 249
1686 Logic matching refactor #1687
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
Open
ved1beta
wants to merge
13
commits into
vllm-project:main
Choose a base branch
from
ved1beta:refactor_1686
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
63cb6e6
get_layer_by_name refactor
ved1beta 06a1e71
get_layers_params refactor
ved1beta 932daf5
set_layer -> Module.set_submodule
ved1beta ba045bc
removed get_param get_params
ved1beta d495843
removed get_layer, get_layers -> match_named_modules
ved1beta 6303210
removed get_default_params and match_layers_params
ved1beta 3394c8c
removed get_quantizable,prunable,terminal_layers
ved1beta f012ae6
get_matching_layer -> match_modules_set, match_modules, get_linear_la…
ved1beta a709fa6
Merge branch 'main' into refactor_1686
ved1beta 94d2b94
Update src/llmcompressor/modifiers/awq/base.py
ved1beta e740de3
required changes
ved1beta 0a7a79f
format
ved1beta f5740fe
Merge branch 'refactor_1686' of github.com:ved1beta/llm-compressor in…
ved1beta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -14,6 +14,7 @@ | |||||
from loguru import logger | ||||||
from pydantic import ConfigDict, PrivateAttr, model_validator | ||||||
from torch.nn import Module | ||||||
from operator import attrgetter | ||||||
from tqdm import tqdm | ||||||
|
||||||
from llmcompressor.core import Event, EventType, State | ||||||
|
@@ -29,7 +30,7 @@ | |||||
from llmcompressor.pipelines.cache import IntermediatesCache | ||||||
from llmcompressor.utils.fsdp.helpers import get_fsdp_parent | ||||||
from llmcompressor.utils.helpers import calibration_forward_context | ||||||
from llmcompressor.utils.pytorch.module import get_layer_by_name, get_layers | ||||||
from llmcompressor.utils.pytorch.module import get_layers | ||||||
|
||||||
__all__ = ["AWQModifier"] | ||||||
|
||||||
|
@@ -323,7 +324,7 @@ def _set_resolved_mappings(self, model: Module) -> None: | |||||
smooth_layer = smooth_layers[smooth_name] | ||||||
|
||||||
smooth_parent_name = ".".join(smooth_name.split(".")[:-1]) | ||||||
smooth_parent = get_layer_by_name(smooth_parent_name, model) | ||||||
smooth_parent = attrgetter(smooth_parent_name)(model) | ||||||
|
||||||
balance_layers, balance_names = [], [] | ||||||
for balance_regex in mapping.balance_layers: | ||||||
|
@@ -765,7 +766,7 @@ def get_lowest_common_parent(names: List[str], module: Module) -> Tuple[str, Mod | |||||
while True: | ||||||
if parent_name == "": | ||||||
return "", module | ||||||
parent = get_layer_by_name(parent_name, module) | ||||||
parent = attrgetter(parent_name)(module) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
if not isinstance(parent, torch.nn.ModuleList): | ||||||
return parent_name, parent | ||||||
parent_name = ".".join(parent_name.split(".")[:-1]) |
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.
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.
This line could raise an
AttributeError
ifsmooth_parent_name
is an empty string. This can happen ifsmooth_name
refers to a top-level module inmodel
(i.e., its name does not contain any dots). In that case,smooth_name.split('.')[:-1]
results in an empty list, andsmooth_parent_name
becomes""
, which is not a valid input forattrgetter
.To prevent a crash, you should handle this case by assigning
model
as the parent whensmooth_parent_name
is empty, as this indicatessmooth_name
is a direct attribute ofmodel
.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.
: )
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.
Yeah I'm a bit concerned this has the potential to error out as well. what if there's no parent?