Skip to content

Commit 7164e32

Browse files
kaikaiyaochensuyue
authored andcommitted
Mod readme of Neural Coder (#1405)
* Update README.md * Update README.md * Update README.md * Update README.md * Create PythonAPI.md * Update PythonAPI.md * Update README.md * Update PythonAPI.md * Create SupportMatrix.md * Create SupportMatrix.md * Update SupportMatrix.md * Update SupportMatrix.md * Update README.md * Update README.md * Update SupportMatrix.md * Update SupportMatrix.md * Update SupportMatrix.md * Update SupportMatrix.md * Update SupportMatrix.md (cherry picked from commit 1690c5c)
1 parent f023b83 commit 7164e32

File tree

4 files changed

+84
-71
lines changed

4 files changed

+84
-71
lines changed

README.md

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ dataset = quantizer.dataset('dummy', shape=(1, 224, 224, 3))
6464
quantizer.calib_dataloader = common.DataLoader(dataset)
6565
quantizer.fit()
6666
```
67-
### Quantization with [JupyterLab Extension](./neural_coder/extensions/neural_compressor_ext_lab/README.md) (Experimental)
67+
### Quantization with [JupyterLab Extension](./neural_coder/extensions/neural_compressor_ext_lab/README.md)
6868
Search for ```jupyter-lab-neural-compressor``` in the Extension Manager in JupyterLab and install with one click:
6969

7070
<a target="_blank" href="./neural_coder/extensions/screenshots/extmanager.png">
@@ -84,20 +84,6 @@ inc_bench
8484
<img src="./docs/imgs/INC_GUI.gif" alt="Architecture">
8585
</a>
8686

87-
### Quantization with [Neural Coder](./neural_coder/docs/Quantization.md) (Experimental)
88-
89-
```python
90-
from neural_coder import auto_quant
91-
auto_quant(
92-
code="https://github.com/huggingface/transformers/blob/v4.21-release/examples/pytorch/text-classification/run_glue.py",
93-
args="--model_name_or_path albert-base-v2 \
94-
--task_name sst2 \
95-
--do_eval \
96-
--output_dir result \
97-
--overwrite_output_dir",
98-
)
99-
```
100-
10187
## System Requirements
10288

10389
### Validated Hardware Environment
@@ -252,7 +238,7 @@ Intel® Neural Compressor validated 420+ [examples](./examples) for quantization
252238
</tr>
253239
<tr>
254240
<td colspan="4" align="center"><a href="docs/distillation_quantization.md">Distillation for Quantization</a></td>
255-
<td colspan="5" align="center"><a href="neural_coder">Neural Coder (No-Code Solution)</a></td>
241+
<td colspan="5" align="center"><a href="neural_coder">Neural Coder</a></td>
256242
</tr>
257243

258244
</tbody>

neural_coder/README.md

Lines changed: 6 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -35,62 +35,13 @@ simultaneously on below PyTorch evaluation code, we generate the optimized code
3535

3636
## Getting Started!
3737

38-
### Neural Coder for Quantization
39-
We provide a feature that helps automatically enable quantization on Deep Learning models and automatically evaluates for the best performance on the model. It is a code-free solution that can help users enable quantization algorithms on a model with no manual coding needed. Supported features include Post-Training Static Quantization, Post-Training Dynamic Quantization, and Mixed Precision. For more details please refer to this [guide](docs/AutoQuant.md).
38+
There are currently 2 ways to use Neural Coder for automatic quantization enabling and benchmark.
4039

41-
### General Guide
42-
We currently provide 3 main user-facing APIs for Neural Coder: enable, bench and superbench.
43-
#### Enable
44-
Users can use ```enable()``` to enable specific features into DL scripts:
45-
```
46-
from neural_coder import enable
47-
enable(
48-
code="neural_coder/examples/vision/resnet50.py",
49-
features=[
50-
"pytorch_jit_script",
51-
"pytorch_channels_last",
52-
],
53-
)
54-
```
55-
To run benchmark directly on the optimization together with the enabling:
56-
```
57-
from neural_coder import enable
58-
enable(
59-
code="neural_coder/examples/vision/resnet50.py",
60-
features=[
61-
"pytorch_jit_script",
62-
"pytorch_channels_last"
63-
],
64-
run_bench=True,
65-
)
66-
```
67-
#### Bench
68-
To run benchmark on your code with an existing patch:
69-
```
70-
from neural_coder import bench
71-
bench(
72-
code="neural_coder/examples/vision/resnet50.py",
73-
patch_path="${your_patch_path}",
74-
)
75-
```
76-
#### SuperBench
77-
To sweep on optimization sets with a fixed benchmark configuration:
78-
```
79-
from neural_coder import superbench
80-
superbench(code="neural_coder/examples/vision/resnet50.py")
81-
```
82-
To sweep on benchmark configurations for a fixed optimization set:
83-
```
84-
from neural_coder import superbench
85-
superbench(
86-
code="neural_coder/examples/vision/resnet50.py",
87-
sweep_objective="bench_config",
88-
bench_feature=[
89-
"pytorch_jit_script",
90-
"pytorch_channels_last",
91-
],
92-
)
93-
```
40+
### Jupyter Lab Extension
41+
We offer Neural Coder as an extension plugin in Jupyter Lab. This enables users to utilize Neural Coder while writing their Deep Learning models in Jupyter Lab coding platform. Users can simply search for ```jupyter-lab-neural-compressor``` in the Extension Manager in JupyterLab and install Neural Coder with one click. For more details, please refer to this [guide](extensions/neural_compressor_ext_lab/README.md)
42+
43+
### Python API
44+
There are 3 user-facing APIs for Neural Coder: enable, bench and superbench. For more details, please refer to this [guide](docs/PythonAPI.md). We have provided a [list](docs/SupportMatrix.md) of supported Deep Learning optimization features. Specifically for quantization, we provide an auto-quantization API that helps automatically enable quantization on Deep Learning models and automatically evaluates for the best performance on the model with no manual coding needed. Supported features include Post-Training Static Quantization, Post-Training Dynamic Quantization, and Mixed Precision. For more details, please refer to this [guide](docs/Quantization.md).
9445

9546
## Contact
9647
Please contact us at [inc.maintainers@intel.com](mailto:inc.maintainers@intel.com) for any Neural Coder related question.

neural_coder/docs/PythonAPI.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
Neural Coder as Python API
2+
===========================
3+
4+
We currently provide 3 main user-facing APIs for Neural Coder: enable, bench and superbench.
5+
6+
#### Enable
7+
Users can use ```enable()``` to enable specific features into DL scripts:
8+
```
9+
from neural_coder import enable
10+
enable(
11+
code="neural_coder/examples/vision/resnet50.py",
12+
features=[
13+
"pytorch_jit_script",
14+
"pytorch_channels_last",
15+
],
16+
)
17+
```
18+
To run benchmark directly on the optimization together with the enabling:
19+
```
20+
from neural_coder import enable
21+
enable(
22+
code="neural_coder/examples/vision/resnet50.py",
23+
features=[
24+
"pytorch_jit_script",
25+
"pytorch_channels_last"
26+
],
27+
run_bench=True,
28+
)
29+
```
30+
31+
#### Bench
32+
To run benchmark on your code with an existing patch:
33+
```
34+
from neural_coder import bench
35+
bench(
36+
code="neural_coder/examples/vision/resnet50.py",
37+
patch_path="${your_patch_path}",
38+
)
39+
```
40+
41+
#### SuperBench
42+
To sweep on optimization sets with a fixed benchmark configuration:
43+
```
44+
from neural_coder import superbench
45+
superbench(code="neural_coder/examples/vision/resnet50.py")
46+
```
47+
To sweep on benchmark configurations for a fixed optimization set:
48+
```
49+
from neural_coder import superbench
50+
superbench(
51+
code="neural_coder/examples/vision/resnet50.py",
52+
sweep_objective="bench_config",
53+
bench_feature=[
54+
"pytorch_jit_script",
55+
"pytorch_channels_last",
56+
],
57+
)
58+
```

neural_coder/docs/SupportMatrix.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Supported Optimization Features
2+
===========================
3+
4+
| Framework | Optimization | API Alias |
5+
| ------------- | ------------- | ------------- |
6+
| PyTorch | [Mixed Precision](https://pytorch.org/docs/stable/amp.html) | `pytorch_amp` |
7+
| PyTorch | [Channels Last](https://pytorch.org/tutorials/intermediate/memory_format_tutorial.html) | `pytorch_channels_last` |
8+
| PyTorch | [JIT (Just-In-Time) Script/Trace](https://pytorch.org/docs/stable/jit.html) & [optimize_for_inference](https://pytorch.org/docs/stable/generated/torch.jit.optimize_for_inference.html) | `pytorch_jit_script`, `pytorch_jit_trace`, `pytorch_jit_script_ofi`, `pytorch_jit_trace_ofi` |
9+
| PyTorch | JIT with [TorchDynamo](https://github.com/pytorch/torchdynamo) | `pytorch_torchdynamo_jit_script`, `pytorch_torchdynamo_jit_trace`, `pytorch_torchdynamo_jit_script_ofi`, `pytorch_torchdynamo_jit_trace_ofi` |
10+
| PyTorch | [Intel Neural Compressor Mixed Precision](https://github.com/intel/neural-compressor/blob/master/docs/mixed_precision.md) | `pytorch_inc_bf16` |
11+
| PyTorch | [Intel Neural Compressor INT8 Static Quantization (FX/IPEX)](https://github.com/intel/neural-compressor/blob/master/docs/PTQ.md) | `pytorch_inc_static_quant_fx`, `pytorch_inc_static_quant_ipex` |
12+
| PyTorch | [Intel Neural Compressor INT8 Dynamic Quantization](https://github.com/intel/neural-compressor/blob/master/docs/dynamic_quantization.md) | `pytorch_inc_dynamic_quant` |
13+
| PyTorch | [Intel Extension for PyTorch (FP32, BF16, INT8 Static/Dynamic Quantization)](https://github.com/intel/intel-extension-for-pytorch) | `pytorch_ipex_fp32`, `pytorch_ipex_bf16`, `pytorch_ipex_int8_static_quant`, `pytorch_ipex_int8_dynamic_quant` |
14+
| PyTorch | [Alibaba Blade-DISC](https://github.com/alibaba/BladeDISC) | `pytorch_aliblade` |
15+
| PyTorch Lightning | [Mixed Precision](https://pytorch-lightning.readthedocs.io/en/latest/guides/speed.html) | `pytorch_lightning_bf16_cpu` |
16+
| TensorFlow | [Mixed Precision](https://www.intel.com/content/www/us/en/developer/articles/guide/getting-started-with-automixedprecisionmkl.html) | `tensorflow_amp` |
17+
| Keras | [Mixed Precision](https://www.tensorflow.org/guide/mixed_precision) | `keras_amp` |
18+
| ONNX Runtime | [INC Static Quantization (QLinear)](https://github.com/intel/neural-compressor/blob/master/examples/onnxrt/README.md#operator-oriented-with-qlinearops) | `onnx_inc_static_quant_qlinear` |

0 commit comments

Comments
 (0)