Skip to content

Adding multiweight support to Quantized GoogLeNet #4848

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

Merged

Conversation

datumbox
Copy link
Contributor

@datumbox datumbox commented Nov 3, 2021

Fixes partially #4674

Verified with:

python -u train_quantization.py --test-only --weights ImageNet1K_FBGEMM_TFV1 --model googlenet --device cpu

cc @bjuncek

@facebook-github-bot
Copy link

facebook-github-bot commented Nov 3, 2021

💊 CI failures summary and remediations

As of commit 1a150d9 (more details on the Dr. CI page):


  • 1/1 failures introduced in this PR

1 failure not recognized by patterns:

Job Step Action
CircleCI binary_linux_conda_py3.6_cu111 packaging/build_conda.sh 🔁 rerun

1 job timed out:

  • binary_linux_conda_py3.6_cu111

This comment was automatically generated by Dr. CI (expand for details).

Please report bugs/suggestions to the (internal) Dr. CI Users group.

Click here to manually regenerate this comment.

Copy link
Contributor Author

@datumbox datumbox left a comment

Choose a reason for hiding this comment

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

Few comments to assist review:

@@ -84,6 +84,7 @@ def test_old_vs_new_factory(model_fn, module_name, dev):
},
"quantization": {
"input_shape": (1, 3, 224, 224),
"quantize": True,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Needed to actually run the tests on the quantized weights.

progress: bool = True,
quantize: bool = False,
**kwargs: Any,
) -> "QuantizableGoogLeNet":
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just moving this builder below to the class definition to use proper typing.

progress: bool = True,
quantize: bool = False,
**kwargs: Any,
) -> QuantizableGoogLeNet:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

copy-pasted, no need for review.

@@ -14,14 +14,13 @@


class GoogLeNetWeights(Weights):
ImageNet1K_Community = WeightEntry(
ImageNet1K_TFV1 = WeightEntry(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was previously incorrectly tagged as community contribution while in reality the weights were ported from TF. Proof: #678 (comment)

else:
weights = GoogLeNetWeights.verify(weights)

original_aux_logits = kwargs.get("aux_logits", False)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We simplify similarly to the unquantized builder.

kwargs["num_classes"] = len(weights.meta["categories"])
if "backend" in weights.meta:
kwargs["backend"] = weights.meta["backend"]
backend = kwargs.pop("backend", "fbgemm")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The rest is similar to the quantized implementation for resnet.

"backend": "fbgemm",
"quantization": "ptq",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding some additional meta-data such as interpolation, type of quantization and a reference to the unquantized enum of the the weights to all previous models.

Copy link
Contributor

@jdsgomes jdsgomes left a comment

Choose a reason for hiding this comment

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

LGTM!

@datumbox datumbox merged commit b43353e into pytorch:main Nov 3, 2021
@datumbox datumbox deleted the prototype/quantizedgooglenet_multiweight branch November 3, 2021 16:09
@datumbox datumbox linked an issue Nov 3, 2021 that may be closed by this pull request
6 tasks
facebook-github-bot pushed a commit that referenced this pull request Nov 8, 2021
Summary:
* Reordering the builders to use proper typing.

* Adding additional meta-data on existing quantized models.

* Fixing meta on unquantized model.

* Adding quantized googlenet builder.

* undo inception move.

* Adding recipe information.

Reviewed By: kazhang

Differential Revision: D32216660

fbshipit-source-id: 2fbda7b7d39e97f156264b86fcf42076598d564b
cyyever pushed a commit to cyyever/vision that referenced this pull request Nov 16, 2021
* Reordering the builders to use proper typing.

* Adding additional meta-data on existing quantized models.

* Fixing meta on unquantized model.

* Adding quantized googlenet builder.

* undo inception move.

* Adding recipe information.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multi-pretrained weights: Add model builders for Quantization
3 participants