Justin Chu
c0d8a4af0a
[BE] Enable ruff's UP rules and autoformat ao/ ( #105430 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/105430
Approved by: https://github.com/albanD , https://github.com/malfet
2023-07-19 13:44:37 +00:00
Vasiliy Kuznetsov
f15ab8a7f2
AO migration: replace torch internal callsites ( #94170 )
...
Summary:
Do the following renames:
`torch.quantization` -> `torch.ao.quantization`
`torch.nn.quantized` -> `torch.ao.nn.quantized`
`torch.nn.quantizable` -> `torch.ao.nn.quantizable`
`torch.nn.qat` -> `torch.ao.nn.qat`
`torch.nn.intrinsic` -> `torch.ao.nn.intrinsic`
And then, do
`torch.ao.nn.quantized._reference` -> `torch.ao.nn.quantized.reference` to clean up the aftermath of https://github.com/pytorch/pytorch/pull/84974
Then, manually update `test/test_module_init.py` to fix hanging whitespace due to the replace.
Run this script to do the replacements: https://gist.github.com/vkuzo/7f7afebf8c31b9ba48306223e68a1c82
This is for https://github.com/pytorch/pytorch/issues/81667
Test plan: CI
Pull Request resolved: https://github.com/pytorch/pytorch/pull/94170
Approved by: https://github.com/jerryzh168
2023-02-07 02:32:23 +00:00
HDCharles
6a866c3ed1
[ao] fixing public v private for torch.ao.nn.X ( #87883 )
...
Summary: this mostly consisted of adding __all__ to files without them.
A few functions in X.utils were made private too
Test Plan: python test/test_public_bindings.py
Reviewers:
Subscribers:
Tasks:
Tags:
Differential Revision: [D40814548](https://our.internmc.facebook.com/intern/diff/D40814548 )
Pull Request resolved: https://github.com/pytorch/pytorch/pull/87883
Approved by: https://github.com/jcaip , https://github.com/anjali411
2022-12-15 03:03:07 +00:00
zaf
c92e5ac95b
[quant][ao_migration] torch.nn.quantized.modules → torch.ao.nn.quantized.modules ( #78713 )
...
Context: In order to avoid the cluttering of the `torch.nn` namespace
the quantized modules namespace is moved to `torch.ao.nn`.
The list of the `nn.quantized` files that are being migrated:
- [ ] `torch.nn.quantized` → `torch.ao.nn.quantized`
- [X] `torch.nn.quantized.functional` → `torch.ao.nn.quantized.functional`
- [X] [Current PR] `torch.nn.quantized.modules` → `torch.ao.nn.quantized.modules`
- [ ] `torch.nn.quantized.dynamic` → `torch.ao.nn.quantized.dynamic`
- [ ] `torch.nn.quantized._reference` → `torch.ao.nn.quantized._reference`
- [ ] `torch.nn.quantizable` → `torch.ao.nn.quantizable`
- [ ] `torch.nn.qat` → `torch.ao.nn.qat`
- [ ] `torch.nn.qat.modules` → `torch.ao.nn.qat.modules`
- [ ] `torch.nn.qat.dynamic` → `torch.ao.nn.qat.dynamic`
- [ ] `torch.nn.intrinsic` → `torch.ao.nn.intrinsic`
- [ ] `torch.nn.intrinsic.modules` → `torch.ao.nn.intrinsic.modules`
- [ ] `torch.nn.intrinsic.qat` → `torch.ao.nn.intrinsic.qat`
- [ ] `torch.nn.intrinsic.quantized` → `torch.ao.nn.intrinsic.quantized`
- [ ] `torch.nn.intrinsic.quantized.modules` → `torch.ao.nn.intrinsic.quantized.modules`
- [ ] `torch.nn.intrinsic.quantized.dynamic` → `torch.ao.nn.intrinsic.quantized.dynamic`
Majority of the files are just moved to the new location.
However, specific files need to be double checked:
- Documentation @vkuzo
- docs/source/conf.py
- docs/source/quantization.rst
- [quantize_fx](torch/ao/quantization/quantize_fx.py) @jerryzh168
- [common test routine](test/quantization/ao_migration/common.py) @HDCharles
- JIT stuff @jamesr66a
- torch/csrc/jit/passes/hoist_conv_packed_params.cpp
- torch/csrc/jit/passes/quantization/helper.h
- torch/csrc/jit/serialization/import_source.cpp
Differential Revision: [D38926012](https://our.internmc.facebook.com/intern/diff/D38926012/ )
Differential Revision: [D38926012](https://our.internmc.facebook.com/intern/diff/D38926012 )
Pull Request resolved: https://github.com/pytorch/pytorch/pull/78713
Approved by: https://github.com/jerryzh168
2022-08-25 16:50:33 +00:00
PyTorch MergeBot
6a9c02339d
Revert "[quant][ao_migration] torch.nn.quantized.modules → torch.ao.nn.quantized.modules ( #78713 )"
...
This reverts commit 432f037498 .
Reverted https://github.com/pytorch/pytorch/pull/78713 on behalf of https://github.com/janeyx99 due to Reverting for breaking (trunk-only) ios build
2022-08-22 07:32:37 +00:00
zaf
432f037498
[quant][ao_migration] torch.nn.quantized.modules → torch.ao.nn.quantized.modules ( #78713 )
...
Context: In order to avoid the cluttering of the `torch.nn` namespace
the quantized modules namespace is moved to `torch.ao.nn`.
The list of the `nn.quantized` files that are being migrated:
- [ ] `torch.nn.quantized` → `torch.ao.nn.quantized`
- [X] `torch.nn.quantized.functional` → `torch.ao.nn.quantized.functional`
- [X] [Current PR] `torch.nn.quantized.modules` → `torch.ao.nn.quantized.modules`
- [ ] `torch.nn.quantized.dynamic` → `torch.ao.nn.quantized.dynamic`
- [ ] `torch.nn.quantized._reference` → `torch.ao.nn.quantized._reference`
- [ ] `torch.nn.quantizable` → `torch.ao.nn.quantizable`
- [ ] `torch.nn.qat` → `torch.ao.nn.qat`
- [ ] `torch.nn.qat.modules` → `torch.ao.nn.qat.modules`
- [ ] `torch.nn.qat.dynamic` → `torch.ao.nn.qat.dynamic`
- [ ] `torch.nn.intrinsic` → `torch.ao.nn.intrinsic`
- [ ] `torch.nn.intrinsic.modules` → `torch.ao.nn.intrinsic.modules`
- [ ] `torch.nn.intrinsic.qat` → `torch.ao.nn.intrinsic.qat`
- [ ] `torch.nn.intrinsic.quantized` → `torch.ao.nn.intrinsic.quantized`
- [ ] `torch.nn.intrinsic.quantized.modules` → `torch.ao.nn.intrinsic.quantized.modules`
- [ ] `torch.nn.intrinsic.quantized.dynamic` → `torch.ao.nn.intrinsic.quantized.dynamic`
Majority of the files are just moved to the new location.
However, specific files need to be double checked:
- Documentation @vkuzo
- docs/source/conf.py
- docs/source/quantization.rst
- [quantize_fx](torch/ao/quantization/quantize_fx.py) @jerryzh168
- [common test routine](test/quantization/ao_migration/common.py) @HDCharles
- JIT stuff @jamesr66a
- torch/csrc/jit/passes/hoist_conv_packed_params.cpp
- torch/csrc/jit/passes/quantization/helper.h
- torch/csrc/jit/serialization/import_source.cpp
Differential Revision: [D36860145](https://our.internmc.facebook.com/intern/diff/D36860145/ )
Pull Request resolved: https://github.com/pytorch/pytorch/pull/78713
Approved by: https://github.com/jerryzh168
2022-08-22 01:38:55 +00:00
Salil Desai
5c12cd224f
[PyTorch Edge] Add qnnpack bcsr matrix unpacking and use unpacking in Linear module ( #80475 )
...
Having unpacking removes the need to store the original dense weights in the python Linear module
Differential Revision: [D34699287](https://our.internmc.facebook.com/intern/diff/D34699287/ )
**NOTE FOR REVIEWERS**: This PR has internal Facebook specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D34699287/ )!
Pull Request resolved: https://github.com/pytorch/pytorch/pull/80475
Approved by: https://github.com/qihqi
2022-07-07 15:32:21 +00:00
Salil Desai
eaf817df3a
[PyTorch Edge] Add serialization/deserialization of Sparse Quantize Linear Packed Params ( #80474 )
...
Packed Params are serialized/deserialized in sparse form
Differential Revision: [D34392761](https://our.internmc.facebook.com/intern/diff/D34392761/ )
**NOTE FOR REVIEWERS**: This PR has internal Facebook specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D34392761/ )!
Pull Request resolved: https://github.com/pytorch/pytorch/pull/80474
Approved by: https://github.com/qihqi
2022-07-07 15:30:02 +00:00
Salil Desai
523b081a64
[PyTorch Edge] Remove Original Weight Tensor from QNNPack Sparse Quantized Linear Packed Params ( #80473 )
...
We plan to add serialization/deserialization wihout the original weight tensor, so we no longer need to store it
Differential Revision: [D34617321](https://our.internmc.facebook.com/intern/diff/D34617321/ )
Pull Request resolved: https://github.com/pytorch/pytorch/pull/80473
Approved by: https://github.com/qihqi
2022-07-07 15:11:44 +00:00
anjali411
f68f77610a
Add __all__ to torch.nn.quantized, fx.passes, ao.nn and amp submodules ( #80376 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/80376
Approved by: https://github.com/albanD
2022-06-27 21:36:27 +00:00
Michael Suo
fb0f285638
[lint] upgrade mypy to latest version
...
Fixes https://github.com/pytorch/pytorch/issues/75927 .
Had to fix some bugs and add some ignores.
To check if clean:
```
lintrunner --paths-cmd='git grep -Il .' --take MYPY,MYPYSTRICT
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/76753
Approved by: https://github.com/malfet
2022-05-03 20:51:34 +00:00
PyTorch MergeBot
3d7428d9ac
Revert "[lint] upgrade mypy to latest version"
...
This reverts commit 9bf18aab94 .
Reverted https://github.com/pytorch/pytorch/pull/76753 on behalf of https://github.com/suo
2022-05-03 20:01:18 +00:00
Michael Suo
9bf18aab94
[lint] upgrade mypy to latest version
...
Fixes https://github.com/pytorch/pytorch/issues/75927 .
Had to fix some bugs and add some ignores.
To check if clean:
```
lintrunner --paths-cmd='git grep -Il .' --take MYPY,MYPYSTRICT
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/76753
Approved by: https://github.com/malfet
2022-05-03 19:43:28 +00:00
Charles David Hernandez
98c0fb8b42
[sparsity] More descriptive error message for missing parameters ( #69895 )
...
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/69895
sparse.Linear has an error message that doesn't tell the user how to resolve the issue. This adds more info.
ghstack-source-id: 145603212
Test Plan: Not needed -- string change only
Reviewed By: jerryzh168
Differential Revision: D33039278
fbshipit-source-id: b5f7f5d257142eb3e7ad73f7c005755253a329d7
2021-12-15 16:58:31 -08:00
Zafar
07932e2735
[sparsity] Convert function for sparse kernels without a context manager ( #66778 )
...
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/66778
This removes the hack of the context manager that would communicate the zeros block shape to the quantization convert.
The conversion will assume that the converted modules have `sparse_params` (which is added by the sparsifier).
Test Plan: Imported from OSS
Reviewed By: mrshenli
Differential Revision: D31835721
Pulled By: z-a-f
fbshipit-source-id: c5fd2da3b09a728a2296765c00ca69275dbca3b1
2021-12-09 02:58:57 -08:00
Zafar
0d020effab
[quant] Fix the parts that were missing after initial migration ( #66058 )
...
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/66058
After the initial migration from `torch.quantization` to `torch.ao.quantization`, some of the files did not change.
This happened because the migration was done in parallel, and some of the files were landed while the others were still in the original location.
This is the last fix in the AO migration phase 1, which completely enables the ao.quantization namespace.
Test Plan: `python test/test_quantization.py`
Reviewed By: vkuzo
Differential Revision: D31366066
Pulled By: z-a-f
fbshipit-source-id: bf4a74885be89d098df2d87e685795a2a64026c5
2021-10-05 11:45:37 -07:00
Zafar
7ab2729481
[sparsity][refactor] Import factoring out ( #58707 )
...
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/58707
Minor refactor that changes the format of the import.
This is done to avoid accidental circular dependencies.
Test Plan:
```
python test/test_ao_sparsity.py
```
Imported from OSS
Differential Revision:
D28970961
D28970961
Reviewed By: raghuramank100
Pulled By: z-a-f
fbshipit-source-id: c312742f5e218c435a1a643532f5842116bfcfff
2021-07-02 16:32:39 -07:00
Zafar
5d34b7955b
[sparsity][refactor] Changing linear row/col control ( #60850 )
...
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/60850
Test Plan:
```
python test/test_ao_sparsity.py
```
```
python test/test_ao_sparsity.py
```
Differential Revision:
D29465900
D29465900
Reviewed By: raghuramank100
Pulled By: z-a-f
fbshipit-source-id: 412f50da857f377898fea79d378ae54a049b81fe
2021-07-02 11:12:30 -07:00
Zafar
b0fd3ca542
[sparse] Add the AO namespace to torch ( #58703 )
...
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/58703
Test Plan: Imported from OSS
Reviewed By: jbschlosser
Differential Revision: D28970962
Pulled By: z-a-f
fbshipit-source-id: 0d0f62111a0883af4143a933292dfaaf8fae220d
2021-06-09 19:47:21 -07:00
Zafar Takhirov
375687839e
[sparsity] Moving the sparsity python files to OSS ( #56617 )
...
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/56617
This migrates the sparsity to the open source
Test Plan: `buck test mode/opt //caffe2/test:ao`
Reviewed By: raghuramank100
Differential Revision: D27812207
fbshipit-source-id: cc87d9d2b486269901a4ad9b483615741a1cd712
2021-04-22 14:07:31 -07:00