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

Fix support const as input to linear layers in pytorch #1080

Merged
merged 2 commits into from
May 22, 2024

Conversation

lapid92
Copy link
Collaborator

@lapid92 lapid92 commented May 21, 2024

Pull Request Description:

The issue is that positional weights are only inserted as inputs to the node if the positional weights of the node are being quantized, and in any case where the node weights are not being quantized.
The PR addresses the scenario where the node weights are being quantized and the positional weights are not quantized.

Checklist before requesting a review:

  • I set the appropriate labels on the pull request.
  • I have added/updated the release note draft (if necessary).
  • I have updated the documentation to reflect my changes (if necessary).
  • All function and files are well documented.
  • All function and classes have type hints.
  • There is a licenses in all file.
  • The function and variable names are informative.
  • I have checked for code duplications.
  • I have added new unittest (if necessary).

@@ -56,7 +56,7 @@ def __init__(self, unit_test, func, const, input_reverse_order=False):
def get_tpc(self):
tp = generate_test_tp_model({'weights_n_bits': 32,
'activation_n_bits': 32,
'enable_weights_quantization': False,
'enable_weights_quantization': True,
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe test with AND without weights quantization?

@ofirgo
Copy link
Collaborator

ofirgo commented May 21, 2024

@lapid92
Please add description to the PR explaining the problem and the solution (and consider including it in the commit message when merging).

@@ -239,7 +239,9 @@ def insert_positional_weights_to_input_list(self, input_tensors: List) -> List:
for pos, weight in sorted((pos, weight) for pos, weight in self.weights.items()
if isinstance(pos, int)):
assert pos <= len(input_tensors), 'Positional weight index mismatch'
input_tensors.insert(pos, weight)
# Insert only positional weights that are not subject to quantization.
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe explain why?

@@ -239,7 +239,9 @@ def insert_positional_weights_to_input_list(self, input_tensors: List) -> List:
for pos, weight in sorted((pos, weight) for pos, weight in self.weights.items()
if isinstance(pos, int)):
assert pos <= len(input_tensors), 'Positional weight index mismatch'
Copy link
Collaborator

Choose a reason for hiding this comment

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

change this to if with a "critical" logger message

@lapid92 lapid92 requested review from ofirgo and elad-c May 22, 2024 06:15
@lapid92 lapid92 merged commit 3181d42 into sony:main May 22, 2024
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants