Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

A temp solution to enable GluonCV INT8 flow #14331

Open
xinyu-intel opened this issue Mar 5, 2019 · 1 comment
Open

A temp solution to enable GluonCV INT8 flow #14331

xinyu-intel opened this issue Mar 5, 2019 · 1 comment
Labels
Quantization Issues/Feature Requests related to Quantization

Comments

@xinyu-intel
Copy link
Contributor

Description

A simple method to launch int8 inference with gluon is that loading back a quantized JSON file and parameter as a SymbolBlock. However, SymbolBlock function is based on CachedOP which needs both forward and backward computing graph. So, some inference_only operators like quantized operators and subgraph operators cannot be loaded back. Below are the error logs:

Export to JSON...
Load back from JSON with SymbolBlock
[10:01:41] src/operator/subgraph/mkldnn/mkldnn_conv_property.cc:148: Start to execute MKLDNN Convolution optimization pass.
Traceback (most recent call last):
  File "demo_ssd.py", line 58, in <module>
    ids, scores, bboxes = [xx[0].asnumpy() for xx in net(x)]
  File "/home/chenxiny/mxnet-official/python/mxnet/gluon/block.py", line 540, in __call__
    out = self.forward(*args)
  File "/home/chenxiny/mxnet-official/python/mxnet/gluon/block.py", line 1078, in forward
    return self._call_cached_op(x, *args)
  File "/home/chenxiny/mxnet-official/python/mxnet/gluon/block.py", line 797, in _call_cached_op
    self._build_cache(*args)
  File "/home/chenxiny/mxnet-official/python/mxnet/gluon/block.py", line 785, in _build_cache
    self._cached_op = ndarray.CachedOp(out, flags)
  File "/home/chenxiny/mxnet-official/python/mxnet/_ctypes/ndarray.py", line 116, in __init__
    ctypes.byref(self.handle)))
  File "/home/chenxiny/mxnet-official/python/mxnet/base.py", line 252, in check_call
    raise MXNetError(py_str(_LIB.MXGetLastError()))
mxnet.base.MXNetError: [10:01:42] src/pass/gradient.cc:192: Operator _sg_mkldnn_conv is non-differentiable because it didn't register FGradient attribute.

A temporary solution implemented in #14275 is that registering fake grad to subgraph and quantized operators. This will be reverted after the improvement of CachedOP is done.

Environment info (Required)

----------Python Info----------
Version      : 3.6.3
Compiler     : GCC 7.2.0
Build        : ('default', 'Oct 13 2017 12:02:49')
Arch         : ('64bit', '')
------------Pip Info-----------
Version      : 9.0.1
Directory    : /home/chenxiny/anaconda3/lib/python3.6/site-packages/pip
----------MXNet Info-----------
Version      : 1.5.0
Directory    : /home/chenxiny/mxnet-xinyu/python/mxnet
Hashtag not found. Not installed from pre-built package.
----------System Info----------
Platform     : Linux-3.10.0-957.el7.x86_64-x86_64-with-centos-7.6.1810-Core
system       : Linux
node         : 
release      : 3.10.0-957.el7.x86_64
version      : #1 SMP Thu Nov 8 23:39:32 UTC 2018
----------Hardware Info----------
machine      : x86_64
processor    : x86_64
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                80
On-line CPU(s) list:   0-79
Thread(s) per core:    2
Core(s) per socket:    20
Socket(s):             2
NUMA node(s):          2
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 85
Model name:            Intel(R) Xeon(R) Gold 6148 CPU @ 2.40GHz
Stepping:              4
CPU MHz:               1000.048
CPU max MHz:           3700.0000
CPU min MHz:           1000.0000
BogoMIPS:              4800.00
Virtualization:        VT-x
L1d cache:             32K
L1i cache:             32K
L2 cache:              1024K
L3 cache:              28160K
NUMA node0 CPU(s):     0-19,40-59
NUMA node1 CPU(s):     20-39,60-79
Flags:                 fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch epb cat_l3 cdp_l3 intel_ppin intel_pt ssbd mba ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts hwp hwp_act_window hwp_epp hwp_pkg_req pku ospke spec_ctrl intel_stibp flush_l1d
----------Network Test----------
Setting timeout: 10
Timing for MXNet: https://github.com/apache/incubator-mxnet, DNS: 0.0055 sec, LOAD: 2.5571 sec.
Timing for Gluon Tutorial(en): http://gluon.mxnet.io, DNS: 0.0081 sec, LOAD: 2.4796 sec.
Timing for Gluon Tutorial(cn): https://zh.gluon.ai, DNS: 0.0087 sec, LOAD: 2.1053 sec.
Timing for FashionMNIST: https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/gluon/dataset/fashion-mnist/train-labels-idx1-ubyte.gz, DNS: 0.0121 sec, LOAD: 2.1985 sec.
Timing for PYPI: https://pypi.python.org/pypi/pip, DNS: 0.0079 sec, LOAD: 6.4577 sec.
Timing for Conda: https://repo.continuum.io/pkgs/free/, DNS: 0.0082 sec, LOAD: 1.5200 sec.

@piyushghai
Copy link
Contributor

@mxnet-label-bot Add [Quantization]

@marcoabreu marcoabreu added the Quantization Issues/Feature Requests related to Quantization label Mar 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Quantization Issues/Feature Requests related to Quantization
Projects
None yet
Development

No branches or pull requests

3 participants