You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2020/04/01 10:17:06 UTC

[GitHub] [incubator-mxnet] shuo-ouyang opened a new pull request #17952: 1bit gradient compression

shuo-ouyang opened a new pull request #17952: 1bit gradient compression
URL: https://github.com/apache/incubator-mxnet/pull/17952
 
 
   ## Description ##
   Added 1bit gradient compression implementation which has similar speedup with 2bit compression. It works with a threshold, values in gradient above the threshold will be quantized to +1, while values below the threshold will be quantizaed to -1. Different with 2bit compression, this implementation of 1bit supports zero threshold. In addition, 1bit compression seems perform better than the current implentation of 2bit compression when batch size increase.
   
   ### Important files to review ###
   gradient_compression-inl.h
   gradient_compression.cc
   
   ### Training result of ResNet110 on cifar10 with 1 server and 8 worker ###
   each worker is equipped with 4 Tesla K80 GPUs
   mode: dist_sync_device
   batchsize: 1024
   note: th = threshold
   due to the software limitation (our cluster only support CUDA8.0), we run these tests with mxnet1.4.0
   ||  No Quantization | 2bit Quantization (th=0.2)  | 2bit Quantization (th=0.5)  | 2bit Quantization (th=1)  | 1bit Quantization (th=0) |
   | :----: | :----: | :----:  | :----:  |  :----:  | :----:  |
   |validation accuracy| 0.903320 | 0.478516 | 0.574219 | 0.553711 | 0.892578 |
   
   ### Training result of ResNet20 on cifar10 with 1 server and 8 worker ###
   ||  No Quantization | 2bit Quantization (th=0.2)  | 2bit Quantization (th=0.5)  | 2bit Quantization (th=1)  | 1bit Quantization (th=0) |
   | :----: | :----: | :----:  | :----:  |  :----:  | :----:  |
   |validation accuracy| 0.913086 | 0.326172 | 0.501953 | 0.570312 | 0.822266 |
   
   ### Related issue or pr ###
   signum with grad compression #9558
   2bit gradient compression #8662
   
   ### Reference ###
   [Seide F, Fu H, Droppo J, et al. 1-bit stochastic gradient descent and its application to data-parallel distributed training of speech dnns](https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/IS140694.pdf)
   
   ## Checklist ##
   ### Essentials ###
   Please feel free to remove inapplicable items for your PR.
   - [ ] The PR title starts with [MXNET-$JIRA_ID], where $JIRA_ID refers to the relevant [JIRA issue](https://issues.apache.org/jira/projects/MXNET/issues) created (except PRs with tiny changes)
   - [x] Changes are complete (i.e. I finished coding on this PR)
   - [ ] All changes have test coverage:
   - Unit tests are added for small changes to verify correctness (e.g. adding a new operator)
   - Nightly tests are added for complicated/long-running ones (e.g. changing distributed kvstore)
   - Build tests will be added for build configuration changes (e.g. adding a new build option with NCCL)
   - [x] Code is well-documented: 
   - For user-facing API changes, API doc string has been updated. 
   - For new C++ functions in header files, their functionalities and arguments are documented. 
   - For new examples, README.md is added to explain the what the example does, the source of the dataset, expected performance on test set and reference to the original paper if applicable
   - Check the API doc at https://mxnet-ci-doc.s3-accelerate.dualstack.amazonaws.com/PR-$PR_ID/$BUILD_ID/index.html
   - [ ] To the best of my knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change
   
   ### Changes ###
   - [ ] Feature1, tests, (and when applicable, API doc)
   - [ ] Feature2, tests, (and when applicable, API doc)
   
   ## Comments ##
   - If this change is a backward incompatible change, why must this change be made.
   - Interesting edge cases to note here

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] shuo-ouyang commented on issue #17952: 1bit gradient compression

Posted by GitBox <gi...@apache.org>.
shuo-ouyang commented on issue #17952: 1bit gradient compression
URL: https://github.com/apache/incubator-mxnet/pull/17952#issuecomment-608977558
 
 
   @mxnet-bot run ci [unix-gpu, centos-gpu]

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] shuo-ouyang commented on issue #17952: 1bit gradient compression

Posted by GitBox <gi...@apache.org>.
shuo-ouyang commented on issue #17952: 1bit gradient compression
URL: https://github.com/apache/incubator-mxnet/pull/17952#issuecomment-609109020
 
 
   @wkcn Thanks for your help and support. To be honest, I am not familiar with jenkins workflow, and I dont know why some checks are failed when only one whitespace was deleted in code comments.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] mxnet-bot commented on issue #17952: 1bit gradient compression

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on issue #17952: 1bit gradient compression
URL: https://github.com/apache/incubator-mxnet/pull/17952#issuecomment-608977574
 
 
   Jenkins CI successfully triggered : [unix-gpu, centos-gpu]

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] wkcn commented on issue #17952: 1bit gradient compression

Posted by GitBox <gi...@apache.org>.
wkcn commented on issue #17952: 1bit gradient compression
URL: https://github.com/apache/incubator-mxnet/pull/17952#issuecomment-609114493
 
 
   @shuo-ouyang It is not related to the code. The reason is that the CI is unstable now.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] mxnet-bot commented on issue #17952: 1bit gradient compression

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on issue #17952: 1bit gradient compression
URL: https://github.com/apache/incubator-mxnet/pull/17952#issuecomment-609001732
 
 
   Jenkins CI successfully triggered : [unix-gpu]

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] shuo-ouyang commented on issue #17952: 1bit gradient compression

Posted by GitBox <gi...@apache.org>.
shuo-ouyang commented on issue #17952: 1bit gradient compression
URL: https://github.com/apache/incubator-mxnet/pull/17952#issuecomment-609001712
 
 
   @mxnet-bot run ci [unix-gpu]

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] shuo-ouyang commented on issue #17952: 1bit gradient compression

Posted by GitBox <gi...@apache.org>.
shuo-ouyang commented on issue #17952: 1bit gradient compression
URL: https://github.com/apache/incubator-mxnet/pull/17952#issuecomment-609140100
 
 
   @wkcn I get it, thanks!

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] wkcn commented on issue #17952: 1bit gradient compression

Posted by GitBox <gi...@apache.org>.
wkcn commented on issue #17952: 1bit gradient compression
URL: https://github.com/apache/incubator-mxnet/pull/17952#issuecomment-610323453
 
 
   Hi @rahul003 , could you please help take a review? Thank you!

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] mxnet-bot commented on issue #17952: 1bit gradient compression

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on issue #17952: 1bit gradient compression
URL: https://github.com/apache/incubator-mxnet/pull/17952#issuecomment-609037008
 
 
   Jenkins CI successfully triggered : [unix-gpu]

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] wkcn commented on issue #17952: 1bit gradient compression

Posted by GitBox <gi...@apache.org>.
wkcn commented on issue #17952: 1bit gradient compression
URL: https://github.com/apache/incubator-mxnet/pull/17952#issuecomment-609036992
 
 
   @mxnet-bot run ci [unix-gpu]

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] mxnet-bot commented on issue #17952: 1bit gradient compression

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on issue #17952: 1bit gradient compression
URL: https://github.com/apache/incubator-mxnet/pull/17952#issuecomment-607163075
 
 
   Hey @shuo-ouyang , Thanks for submitting the PR 
   All tests are already queued to run once. If tests fail, you can trigger one or more tests again with the following commands: 
   - To trigger all jobs: @mxnet-bot run ci [all] 
   - To trigger specific jobs: @mxnet-bot run ci [job1, job2] 
   *** 
   **CI supported jobs**: [centos-gpu, miscellaneous, clang, unix-cpu, centos-cpu, sanity, website, windows-gpu, windows-cpu, unix-gpu, edge]
   *** 
   _Note_: 
    Only following 3 categories can trigger CI :PR Author, MXNet Committer, Jenkins Admin. 
   All CI tests must pass before the PR can be merged. 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] shuo-ouyang commented on issue #17952: 1bit gradient compression

Posted by GitBox <gi...@apache.org>.
shuo-ouyang commented on issue #17952: 1bit gradient compression
URL: https://github.com/apache/incubator-mxnet/pull/17952#issuecomment-610703052
 
 
   @mxnet-bot run ci [centos-gpu]

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] shuo-ouyang commented on pull request #17952: [v1.x][KVStore]1Bit gradient compression

Posted by GitBox <gi...@apache.org>.
shuo-ouyang commented on pull request #17952:
URL: https://github.com/apache/incubator-mxnet/pull/17952#issuecomment-671406788


   > What is the end2end speedup when using the 1bit compressor?
   > The accuracy drop on resnet20 is also very significant..
   
   Well, in our current experiments (ResNet-20 and ResNet-110 trained on CIFAR-10 dataset), 1bit compressor can achieve similar speed up with an adequate model accuracy compared with 2bit compressor. But CIFAR-10 is a small toy dataset, we will run more experiments on ImageNet dataset and compare these two compressors.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] szha edited a comment on pull request #17952: [WIP]1Bit gradient compression

Posted by GitBox <gi...@apache.org>.
szha edited a comment on pull request #17952:
URL: https://github.com/apache/incubator-mxnet/pull/17952#issuecomment-671019034


   Here are the error messages in the sanity check link
   ```
   [2020-08-09T05:50:42.728Z] src/kvstore/gradient_compression-inl.h:63:  Missing space before ( in for(  [whitespace/parens] [5]
   [2020-08-09T05:50:42.728Z] Done processing src/kvstore/gradient_compression-inl.h
   [2020-08-09T05:50:42.728Z] Category 'whitespace' errors found: 1
   [2020-08-09T05:50:42.728Z] Total errors found: 1
   [2020-08-09T05:50:42.728Z] src/kvstore/gradient_compression.cc:155:  Line ends in whitespace.  Consider deleting these extra spaces.  [whitespace/end_of_line] [4]
   [2020-08-09T05:50:42.728Z] Done processing src/kvstore/gradient_compression.cc
   [2020-08-09T05:50:42.728Z] Category 'whitespace' errors found: 1
   [2020-08-09T05:50:42.728Z] Total errors found: 1
   ...
   [2020-08-09T05:50:42.728Z] =====383/384 cpp-header files passed check=====
   [2020-08-09T05:50:42.728Z] src/kvstore/gradient_compression-inl.h: 1 Errors of 1 Categories map={'whitespace': 1}
   [2020-08-09T05:50:42.728Z] =====648/649 cpp-source files passed check=====
   [2020-08-09T05:50:42.728Z] src/kvstore/gradient_compression.cc: 1 Errors of 1 Categories map={'whitespace': 1}
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] szha merged pull request #17952: [v1.x][KVStore]1Bit gradient compression

Posted by GitBox <gi...@apache.org>.
szha merged pull request #17952:
URL: https://github.com/apache/incubator-mxnet/pull/17952


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] szha commented on a change in pull request #17952: [v1.x][KVStore]1Bit gradient compression

Posted by GitBox <gi...@apache.org>.
szha commented on a change in pull request #17952:
URL: https://github.com/apache/incubator-mxnet/pull/17952#discussion_r585815419



##########
File path: src/kvstore/gradient_compression.cc
##########
@@ -124,14 +151,14 @@ void GradientCompression::Quantize(const mxnet::NDArray &from, mxnet::NDArray *t
         }, from.ctx(), {from.var()}, {to->var(), residual->var()},
         mxnet::FnProperty::kNormal, priority, "QuantizeGPU");
       } else {
-        LOG(FATAL) << "unknown device mask";
+        LOG(FATAL) << "Unsupported quantization of type " << get_type_str();
       }
+    } else {
+      LOG(FATAL) << "unknown device mask";

Review comment:
       log what devices are received




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] shuo-ouyang commented on issue #17952: 1bit gradient compression

Posted by GitBox <gi...@apache.org>.
shuo-ouyang commented on issue #17952: 1bit gradient compression
URL: https://github.com/apache/incubator-mxnet/pull/17952#issuecomment-609019823
 
 
   @mxnet-label-bot add [KVStore, Distributed]

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] mxnet-bot commented on issue #17952: 1bit gradient compression

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on issue #17952: 1bit gradient compression
URL: https://github.com/apache/incubator-mxnet/pull/17952#issuecomment-610703072
 
 
   Jenkins CI successfully triggered : [centos-gpu]

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-mxnet] shuo-ouyang commented on pull request #17952: [v1.x][KVStore]1Bit gradient compression

Posted by GitBox <gi...@apache.org>.
shuo-ouyang commented on pull request #17952:
URL: https://github.com/apache/incubator-mxnet/pull/17952#issuecomment-795254115


   The reason may be that the onebit quantizer can exactly capture the direction (sign) of each element in gradients when the threshold is 0, whereas twobit quantizer cannot due to its limination (threshold != 0). By the way, the previous results are trained with additional code modification about error feedback part, which may lead to counterintuitive results. We have corrected them and uploaded the right results.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] szha commented on pull request #17952: 1bit gradient compression

Posted by GitBox <gi...@apache.org>.
szha commented on pull request #17952:
URL: https://github.com/apache/incubator-mxnet/pull/17952#issuecomment-650699895


   @wkcn since @eric-haibin-lin recently updated the kvstore interface, it would be best to have a review from him.
   
   @eric-haibin-lin can you help?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] szha commented on pull request #17952: 1bit gradient compression

Posted by GitBox <gi...@apache.org>.
szha commented on pull request #17952:
URL: https://github.com/apache/incubator-mxnet/pull/17952#issuecomment-633122678


   @mxnet-bot run ci [all]


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] shuo-ouyang commented on pull request #17952: [v1.x][KVStore]1Bit gradient compression

Posted by GitBox <gi...@apache.org>.
shuo-ouyang commented on pull request #17952:
URL: https://github.com/apache/incubator-mxnet/pull/17952#issuecomment-786680154


   @eric-haibin-lin 
   Very sorry for delayed response...The experiment results are updated, please check it.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] wkcn commented on pull request #17952: 1bit gradient compression

Posted by GitBox <gi...@apache.org>.
wkcn commented on pull request #17952:
URL: https://github.com/apache/incubator-mxnet/pull/17952#issuecomment-619109016


   Hi @eric-haibin-lin and @szha , could you please help take a reivew?
   
   Thank you!


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] szha commented on pull request #17952: [WIP]1Bit gradient compression

Posted by GitBox <gi...@apache.org>.
szha commented on pull request #17952:
URL: https://github.com/apache/incubator-mxnet/pull/17952#issuecomment-671010715


   @shuo-ouyang looks like cpp lint failed. You can reproduce it locally with
   ```
   ci/build.py -R --docker-registry mxnetci --platform ubuntu_cpu --docker-build-retries 3 --shm-size 500m /work/runtime_functions.sh sanity_cpp
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] wkcn commented on pull request #17952: 1bit gradient compression

Posted by GitBox <gi...@apache.org>.
wkcn commented on pull request #17952:
URL: https://github.com/apache/incubator-mxnet/pull/17952#issuecomment-641945289


   Hi @eric-haibin-lin , could you please help take a review?
   The PR is related to gradient compression.
   
   Thank you!


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] shuo-ouyang removed a comment on pull request #17952: [v1.x][KVStore]1Bit gradient compression

Posted by GitBox <gi...@apache.org>.
shuo-ouyang removed a comment on pull request #17952:
URL: https://github.com/apache/incubator-mxnet/pull/17952#issuecomment-671406788


   > What is the end2end speedup when using the 1bit compressor?
   > The accuracy drop on resnet20 is also very significant..
   
   Well, in our current experiments (ResNet-20 and ResNet-110 trained on CIFAR-10 dataset), 1bit compressor can achieve similar speed up with an adequate model accuracy compared with 2bit compressor. But CIFAR-10 is a small toy dataset, we will run more experiments on ImageNet dataset and compare these two compressors.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] shuo-ouyang commented on a change in pull request #17952: [v1.x][KVStore]1Bit gradient compression

Posted by GitBox <gi...@apache.org>.
shuo-ouyang commented on a change in pull request #17952:
URL: https://github.com/apache/incubator-mxnet/pull/17952#discussion_r587495312



##########
File path: src/kvstore/gradient_compression.cc
##########
@@ -142,35 +169,52 @@ void GradientCompression::Dequantize(const mxnet::NDArray &from, mxnet::NDArray
   const int a = from.ctx().dev_mask();
   const int b = to->ctx().dev_mask();
   const float threshold = threshold_;
-  if (type_ == CompressionType::kTwoBit) {
-    if (a == mshadow::cpu::kDevMask && b == mshadow::cpu::kDevMask) {
+  if (a == mshadow::cpu::kDevMask && b == mshadow::cpu::kDevMask) {
+    if (type_ == CompressionType::kOneBit) {
+      mxnet::Engine::Get()->PushSync([from, to, threshold](mxnet::RunContext ctx) {
+        std::vector<mxnet::TBlob> inputs = {from.data(), to->data()};
+        Dequantize1BitImpl(ctx.get_stream<mshadow::cpu>(), inputs, threshold);
+      }, from.ctx(), {from.var()}, {to->var()},
+      mxnet::FnProperty::kNormal, priority, "DequantizeCPU");
+    } else if (type_ == CompressionType::kTwoBit) {
       mxnet::Engine::Get()->PushSync([from, to, threshold](mxnet::RunContext ctx) {
         std::vector<mxnet::TBlob> inputs = {from.data(), to->data()};
         Dequantize2BitImpl(ctx.get_stream<mshadow::cpu>(), inputs, threshold);
       }, from.ctx(), {from.var()}, {to->var()},
       mxnet::FnProperty::kNormal, priority, "DequantizeCPU");
     } else {
+      LOG(FATAL) << "Unsupported dequantization of type " << get_type_str();
+    }
+  } else {
 #if MXNET_USE_CUDA
-      if (a == mshadow::gpu::kDevMask && b == mshadow::gpu::kDevMask) {
+    if (a == mshadow::gpu::kDevMask && b == mshadow::gpu::kDevMask) {
+      if (type_ == CompressionType::kOneBit) {
         mxnet::Engine::Get()->PushSync([from, to, threshold](mxnet::RunContext ctx) {
           std::vector<mxnet::TBlob> inputs = {from.data(), to->data()};
-          Dequantize2BitImpl(ctx.get_stream<mshadow::gpu>(), inputs, threshold);
+          Dequantize1BitImpl(ctx.get_stream<mshadow::gpu>(), inputs, threshold);
           // Wait GPU kernel to complete
           ctx.get_stream<mshadow::gpu>()->Wait();
         }, from.ctx(), {from.var()}, {to->var()},
         mxnet::FnProperty::kNormal, priority, "DequantizeGPU");
+      } else if (type_ == CompressionType::kTwoBit) {
+        mxnet::Engine::Get()->PushSync([from, to, threshold](mxnet::RunContext ctx) {
+          std::vector<mxnet::TBlob> inputs = {from.data(), to->data()};
+          Dequantize2BitImpl(ctx.get_stream<mshadow::gpu>(), inputs, threshold);
+          // Wait GPU kernel to completes
+          ctx.get_stream<mshadow::gpu>()->Wait();
+        }, from.ctx(), {from.var()}, {to->var()},
+        mxnet::FnProperty::kNormal, priority, "DequantizeGPU");
       } else {
-        LOG(FATAL) << "unknown device mask";
+        LOG(FATAL) << "Unsupported dequantization of type " << get_type_str();
       }
+    } else {
+      LOG(FATAL) << "unknown device mask";
+    }
 #else
-      LOG(FATAL) << MXNET_GPU_NOT_ENABLED_ERROR;
+    LOG(FATAL) << MXNET_GPU_NOT_ENABLED_ERROR;

Review comment:
       Thanks for your review. We will solve it as soon as possible.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] szha commented on pull request #17952: [v1.x][KVStore]1Bit gradient compression

Posted by GitBox <gi...@apache.org>.
szha commented on pull request #17952:
URL: https://github.com/apache/incubator-mxnet/pull/17952#issuecomment-790942231


   The results show that the 2-bit compression results in test perplexity higher than 1-bit compression, which seems surprising. Any explanation on why it's the case?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] wkcn commented on pull request #17952: 1bit gradient compression

Posted by GitBox <gi...@apache.org>.
wkcn commented on pull request #17952:
URL: https://github.com/apache/incubator-mxnet/pull/17952#issuecomment-650697325


   Hi @szha , could the PR be merged ?
   There seems to be no other committer reviewing this PR, and the PR has been blocked for about 3 months.
   The author provides the detailed training result, and I had reviewed the code.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] mxnet-bot commented on pull request #17952: 1bit gradient compression

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #17952:
URL: https://github.com/apache/incubator-mxnet/pull/17952#issuecomment-633122718


   Jenkins CI successfully triggered : [edge, centos-gpu, windows-cpu, centos-cpu, windows-gpu, clang, unix-cpu, miscellaneous, website, unix-gpu, sanity]


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] szha commented on pull request #17952: [WIP]1Bit gradient compression

Posted by GitBox <gi...@apache.org>.
szha commented on pull request #17952:
URL: https://github.com/apache/incubator-mxnet/pull/17952#issuecomment-671019034


   Here are the error messages in the sanity check link
   ```
   [2020-08-09T05:50:42.728Z] =====383/384 cpp-header files passed check=====
   [2020-08-09T05:50:42.728Z] src/kvstore/gradient_compression-inl.h: 1 Errors of 1 Categories map={'whitespace': 1}
   [2020-08-09T05:50:42.728Z] =====648/649 cpp-source files passed check=====
   [2020-08-09T05:50:42.728Z] src/kvstore/gradient_compression.cc: 1 Errors of 1 Categories map={'whitespace': 1}
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] shuo-ouyang commented on pull request #17952: [WIP]1Bit gradient compression

Posted by GitBox <gi...@apache.org>.
shuo-ouyang commented on pull request #17952:
URL: https://github.com/apache/incubator-mxnet/pull/17952#issuecomment-671018452


   > @shuo-ouyang looks like cpp lint failed. You can reproduce it locally with
   > 
   > ```
   > ci/build.py -R --docker-registry mxnetci --platform ubuntu_cpu --docker-build-retries 3 --shm-size 500m /work/runtime_functions.sh sanity_cpp
   > ```
   
   Sorry, cannot run it on my windows...


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] szha commented on a change in pull request #17952: [v1.x][KVStore]1Bit gradient compression

Posted by GitBox <gi...@apache.org>.
szha commented on a change in pull request #17952:
URL: https://github.com/apache/incubator-mxnet/pull/17952#discussion_r585815419



##########
File path: src/kvstore/gradient_compression.cc
##########
@@ -124,14 +151,14 @@ void GradientCompression::Quantize(const mxnet::NDArray &from, mxnet::NDArray *t
         }, from.ctx(), {from.var()}, {to->var(), residual->var()},
         mxnet::FnProperty::kNormal, priority, "QuantizeGPU");
       } else {
-        LOG(FATAL) << "unknown device mask";
+        LOG(FATAL) << "Unsupported quantization of type " << get_type_str();
       }
+    } else {
+      LOG(FATAL) << "unknown device mask";

Review comment:
       log what devices are recieved.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] szha commented on a change in pull request #17952: [v1.x][KVStore]1Bit gradient compression

Posted by GitBox <gi...@apache.org>.
szha commented on a change in pull request #17952:
URL: https://github.com/apache/incubator-mxnet/pull/17952#discussion_r585817352



##########
File path: src/kvstore/gradient_compression.cc
##########
@@ -142,35 +169,52 @@ void GradientCompression::Dequantize(const mxnet::NDArray &from, mxnet::NDArray
   const int a = from.ctx().dev_mask();
   const int b = to->ctx().dev_mask();
   const float threshold = threshold_;
-  if (type_ == CompressionType::kTwoBit) {
-    if (a == mshadow::cpu::kDevMask && b == mshadow::cpu::kDevMask) {
+  if (a == mshadow::cpu::kDevMask && b == mshadow::cpu::kDevMask) {
+    if (type_ == CompressionType::kOneBit) {
+      mxnet::Engine::Get()->PushSync([from, to, threshold](mxnet::RunContext ctx) {
+        std::vector<mxnet::TBlob> inputs = {from.data(), to->data()};
+        Dequantize1BitImpl(ctx.get_stream<mshadow::cpu>(), inputs, threshold);
+      }, from.ctx(), {from.var()}, {to->var()},
+      mxnet::FnProperty::kNormal, priority, "DequantizeCPU");
+    } else if (type_ == CompressionType::kTwoBit) {
       mxnet::Engine::Get()->PushSync([from, to, threshold](mxnet::RunContext ctx) {
         std::vector<mxnet::TBlob> inputs = {from.data(), to->data()};
         Dequantize2BitImpl(ctx.get_stream<mshadow::cpu>(), inputs, threshold);
       }, from.ctx(), {from.var()}, {to->var()},
       mxnet::FnProperty::kNormal, priority, "DequantizeCPU");
     } else {
+      LOG(FATAL) << "Unsupported dequantization of type " << get_type_str();
+    }
+  } else {
 #if MXNET_USE_CUDA
-      if (a == mshadow::gpu::kDevMask && b == mshadow::gpu::kDevMask) {
+    if (a == mshadow::gpu::kDevMask && b == mshadow::gpu::kDevMask) {
+      if (type_ == CompressionType::kOneBit) {
         mxnet::Engine::Get()->PushSync([from, to, threshold](mxnet::RunContext ctx) {
           std::vector<mxnet::TBlob> inputs = {from.data(), to->data()};
-          Dequantize2BitImpl(ctx.get_stream<mshadow::gpu>(), inputs, threshold);
+          Dequantize1BitImpl(ctx.get_stream<mshadow::gpu>(), inputs, threshold);
           // Wait GPU kernel to complete
           ctx.get_stream<mshadow::gpu>()->Wait();
         }, from.ctx(), {from.var()}, {to->var()},
         mxnet::FnProperty::kNormal, priority, "DequantizeGPU");
+      } else if (type_ == CompressionType::kTwoBit) {
+        mxnet::Engine::Get()->PushSync([from, to, threshold](mxnet::RunContext ctx) {
+          std::vector<mxnet::TBlob> inputs = {from.data(), to->data()};
+          Dequantize2BitImpl(ctx.get_stream<mshadow::gpu>(), inputs, threshold);
+          // Wait GPU kernel to completes
+          ctx.get_stream<mshadow::gpu>()->Wait();
+        }, from.ctx(), {from.var()}, {to->var()},
+        mxnet::FnProperty::kNormal, priority, "DequantizeGPU");
       } else {
-        LOG(FATAL) << "unknown device mask";
+        LOG(FATAL) << "Unsupported dequantization of type " << get_type_str();
       }
+    } else {
+      LOG(FATAL) << "unknown device mask";
+    }
 #else
-      LOG(FATAL) << MXNET_GPU_NOT_ENABLED_ERROR;
+    LOG(FATAL) << MXNET_GPU_NOT_ENABLED_ERROR;

Review comment:
       if GPU is not enabled and a wrong device type is received here that is neither gpu nor cpu, this error would be confusing. "gpu not enabled" error only makes sense to users when the input contexts are on gpu.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org