-
Notifications
You must be signed in to change notification settings - Fork 249
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
Enable FunctionHookMode tracing by default #3338
base: develop
Are you sure you want to change the base?
Changes from 11 commits
c0b0d20
3519c6d
e6f9faf
d5f8a6d
d7ecabb
3d9c0d4
9266901
c8ab91c
9a7c5a9
1e454f5
99adef9
340db48
7c88cfa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,10 +15,13 @@ | |
from torch import nn | ||
|
||
import nncf | ||
from nncf.common.logging import nncf_logger | ||
from nncf.experimental.torch2.function_hook.wrapper import get_hook_storage | ||
from nncf.experimental.torch2.function_hook.wrapper import wrap_model | ||
from nncf.torch.layer_utils import COMPRESSION_MODULES | ||
from nncf.torch.layer_utils import StatefulModuleInterface | ||
from nncf.torch.utils import get_model_device | ||
from nncf.torch.utils import is_multidevice | ||
|
||
COMPRESSION_STATE_ATTR = "compression_state" | ||
TModel = TypeVar("TModel", bound=nn.Module) | ||
|
@@ -101,11 +104,19 @@ def load_from_config(model: TModel, config: Dict[str, Any]) -> TModel: | |
:return: The compressed model. | ||
""" | ||
wrapped_model = wrap_model(model) | ||
|
||
device = None | ||
if not is_multidevice(wrapped_model): | ||
device = get_model_device(wrapped_model) | ||
else: | ||
nncf_logger.warning("Model is on multiple devices. Cannot determine device for loaded modules.") | ||
|
||
hook_storage = get_hook_storage(wrapped_model) | ||
transformation_commands = cast(List[S_COMMAND], config[COMPRESSION_STATE_ATTR]) | ||
for command in transformation_commands: | ||
module_cls = COMPRESSION_MODULES.get(command["module_cls_name"]) | ||
module = module_cls.from_config(command["module_config"]) | ||
module.to(device) | ||
Comment on lines
+108
to
+119
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. I encountered the same problem with the model on various devices: Is there a reliable method to match the compression module from the insertion command to the target layer and its parameters? With this matching, it would be possible to determine the device. 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. Currently we have limited support for multidevice models. 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. Multidevice case is very popular for LLMs. @AlexanderDokuchaev, do you have any idea how torch2 will support it? 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. I did not look at it. Currently multidevice support for new tracing works similar like for current. |
||
for target_name in command["hook_names_in_model"]: | ||
hook_type, hook_key, hook_id = target_name.split(".") | ||
storage_dict = getattr(hook_storage, hook_type) | ||
|
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.
Please update the main Readme:
OpenVINO documentation should be also update regarding the changes.
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.
done
we have already have deprecation message in create_compressed sine previous release, what a reason to duplicate it in readme now?