Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.

Conversation

@rahul-tuli
Copy link
Member

@rahul-tuli rahul-tuli commented Feb 3, 2022

import torch
from sparseml.pytorch.models import resnet50
from sparseml.pytorch.optim import QuantizationModifier


# Pretrained Model
model = resnet50(pretrained=True)

# Modifier init
modifier = QuantizationModifier(start_epoch=0, activation_bits=4)

# Modifier Application
modifier.apply(
    module=model,
)

# Book-Keeping, the model should have non infinity weights
print(model(torch.rand(1, 3, 224, 224)))

for param in model.parameters():
    print(param.data.min(), param.data.max())

@rahul-tuli rahul-tuli requested a review from bfineran February 4, 2022 19:26
@rahul-tuli rahul-tuli self-assigned this Feb 4, 2022
@rahul-tuli rahul-tuli marked this pull request as draft February 4, 2022 19:34
@rahul-tuli rahul-tuli requested a review from mgoin February 4, 2022 19:34
Copy link
Contributor

@bfineran bfineran left a comment

Choose a reason for hiding this comment

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

as discussed we need to have modifier properties to control both the weight and activation qconfig kwargs

@bfineran
Copy link
Contributor

@rahul-tuli pushed the discussed fix for propagating observer quant range

@rahul-tuli
Copy link
Member Author

@rahul-tuli pushed the discussed fix for propagating observer quant range

Thanks, incorporated the requested changes!

Fix: tests, test helper names, style
Fix - Merge Conflicts
Renamed - `enable_in4_activations` to `int4_activations`
Use: A copy of `activation_qconfig_kwargs` for overriding quant_max, quant_min values
Copy link
Contributor

@bfineran bfineran left a comment

Choose a reason for hiding this comment

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

looks close! left a few comments then good from my end

@bfineran bfineran marked this pull request as ready for review February 18, 2022 14:58
@bfineran bfineran changed the title [WIP] int4-quant int4 quantized activations support + QuantizationModifier qconfig kwargs support Feb 18, 2022
Copy link
Contributor

@bfineran bfineran left a comment

Choose a reason for hiding this comment

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

one more comment then good to go

@rahul-tuli rahul-tuli requested a review from bfineran February 18, 2022 15:34
bfineran
bfineran previously approved these changes Feb 18, 2022
@rahul-tuli rahul-tuli changed the title int4 quantized activations support + QuantizationModifier qconfig kwargs support Activation Bits Support + qconfig kwargs for QuantizationModifier Feb 18, 2022
KSGulin
KSGulin previously approved these changes Feb 18, 2022
Copy link
Contributor

@KSGulin KSGulin left a comment

Choose a reason for hiding this comment

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

Good stuff

@KSGulin KSGulin dismissed stale reviews from bfineran and themself via 82e94d3 February 18, 2022 16:27
KSGulin
KSGulin previously approved these changes Feb 18, 2022
bfineran
bfineran previously approved these changes Feb 18, 2022
natuan
natuan previously requested changes Feb 18, 2022
@rahul-tuli rahul-tuli requested a review from natuan February 23, 2022 08:23
@rahul-tuli rahul-tuli dismissed natuan’s stale review February 23, 2022 08:27

synced offline

@rahul-tuli rahul-tuli merged commit a78f340 into main Feb 23, 2022
@rahul-tuli rahul-tuli deleted the feature-int4-quant branch February 23, 2022 15:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants