Skip to content
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

[PT2] Introduce PT2OpLayerAttribute #3178

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

AlexanderDokuchaev
Copy link
Collaborator

@AlexanderDokuchaev AlexanderDokuchaev commented Jan 7, 2025

Changes

  • Introduced PT2OpLayerAttribute, to collect called function, attributes and constant ports
  • FunctionMeta stored function instead of function name

Reason for changes

Needs to implement subgraph extractor for FBC

Related tickets

110974

Tests

tests/torch2/function_hook/nncf_graph/test_layer_attributes.py

@github-actions github-actions bot added NNCF PT Pull requests that updates NNCF PyTorch experimental labels Jan 7, 2025
@AlexanderDokuchaev AlexanderDokuchaev marked this pull request as ready for review January 7, 2025 14:26
@AlexanderDokuchaev AlexanderDokuchaev requested a review from a team as a code owner January 7, 2025 14:26
@daniil-lyakhov daniil-lyakhov self-requested a review January 9, 2025 12:33
Copy link
Collaborator

@daniil-lyakhov daniil-lyakhov left a comment

Choose a reason for hiding this comment

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

LGTM, only have a couple of questions:

"""
if isinstance(meta, FunctionMeta):
constant_port_ids = get_constant_port_ids(nx_graph, node)
return PT2OpLayerAttributes(meta.func, meta.args, meta.kwargs, constant_port_ids)
Copy link
Collaborator

@daniil-lyakhov daniil-lyakhov Jan 9, 2025

Choose a reason for hiding this comment

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

Why do we need both constant_port_ids in PT2OpLayerAttributes and weights_port_id in the metatypes? https://github.com/openvinotoolkit/nncf/blob/develop/nncf/torch/graph/operator_metatypes.py#L207

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

constant_port_ids collects all constanat ports like weights and bias.
weights_port_id needs to find only weight.

Copy link
Collaborator

@daniil-lyakhov daniil-lyakhov Jan 9, 2025

Choose a reason for hiding this comment

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

Ok, there are models with constant subgraphs which contain linear layers (swin_v2), does you approach cover such cases? In torch FX such nodes have 3 constant inputs

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

All 3 inputs marks as constants

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
experimental NNCF PT Pull requests that updates NNCF PyTorch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants