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/08/08 09:30:03 UTC

[GitHub] [incubator-mxnet] ZiyueHuang opened a new pull request #18880: fix trainer when the model involves shared_parameter

ZiyueHuang opened a new pull request #18880:
URL: https://github.com/apache/incubator-mxnet/pull/18880


   ## Description ##
   Currently `python gluon-nlp/scripts/pretraining/run_electra.py --gpus 0,1` will raise an error message below
   
   ```
   Traceback (most recent call last):
     File "run_electra.py", line 545, in <module>
       train(args)
     File "run_electra.py", line 407, in train
       trainer.allreduce_grads()
     File "/home/ubuntu/mxnet/python/mxnet/gluon/trainer.py", line 383, in allreduc
   e_grads
       self._allreduce_grads()
     File "/home/ubuntu/mxnet/python/mxnet/gluon/trainer.py", line 409, in _allredu
   ce_grads
       self._kvstore.pushpull(i, grad_list, priority=-i)
     File "/home/ubuntu/mxnet/python/mxnet/kvstore/kvstore.py", line 418, in pushpu
   ll
       cvals, couts, ctypes.c_int(priority)))
     File "/home/ubuntu/mxnet/python/mxnet/base.py", line 246, in check_call
       raise get_last_ffi_error()
   mxnet.base.MXNetError: Traceback (most recent call last):
     File "/home/ubuntu/mxnet/src/kvstore/././comm.h", line 788
   MXNetError: Check failed: !merged.is_none(): unintialized merge buffer detected
   ```
   
   This error is because the `pushpull` could be called on a wrong key when the model uses shared_parameter, and I created a minimal reproducible example https://gist.github.com/ZiyueHuang/2c9384c60de04fb2ca943236bedd15b8. After this PR, the training will proceeds normally.
   
   The reason: when the model uses shared_parameter, `param` in this [line](https://github.com/apache/incubator-mxnet/blob/master/python/mxnet/gluon/trainer.py#L108) contains duplicate parameters while `self._params` contains distinct parameters, and in the current implementation `trainer._init_params` uses the index in `param` as the key (see [line](https://github.com/apache/incubator-mxnet/blob/master/python/mxnet/gluon/trainer.py#L175)) while `trainer._allreduce_grads` uses the index in `self._params` as the key, thus there exists a mismatch (meaning that for the same parameter, the init and all_reduce operation are performed on different keys).
   
   cc @sxjscience @eric-haibin-lin 
   
   ## 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)
   - [ ] 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)
   - [ ] 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



[GitHub] [incubator-mxnet] sxjscience commented on pull request #18880: fix trainer when the model involves share_parameters

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


   Also CC @ZheyuYe.


----------------------------------------------------------------
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] sxjscience edited a comment on pull request #18880: fix trainer when the model involves share_parameters

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


   ~~This change looks good to me. We should add a test case in https://github.com/apache/incubator-mxnet/blob/master/tests/python/unittest/test_gluon_trainer.py.~~ (Noticed that it's already added).


----------------------------------------------------------------
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] sxjscience merged pull request #18880: fix trainer when the model involves share_parameters

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


   


----------------------------------------------------------------
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 #18880: fix trainer when the model involves shared_parameter

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


   Hey @ZiyueHuang , 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**: [windows-cpu, sanity, edge, website, unix-gpu, centos-cpu, centos-gpu, clang, miscellaneous, windows-gpu, unix-cpu]
   *** 
   _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



[GitHub] [incubator-mxnet] sxjscience removed a comment on pull request #18880: fix trainer when the model involves share_parameters

Posted by GitBox <gi...@apache.org>.
sxjscience removed a comment on pull request #18880:
URL: https://github.com/apache/incubator-mxnet/pull/18880#issuecomment-670980554


   ~~This change looks good to me. We should add a test case in https://github.com/apache/incubator-mxnet/blob/master/tests/python/unittest/test_gluon_trainer.py.~~ (Noticed that it's already added).


----------------------------------------------------------------
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] sxjscience commented on pull request #18880: fix trainer when the model involves share_parameters

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


   This change looks good to me. We should add a test case in https://github.com/apache/incubator-mxnet/blob/master/tests/python/unittest/test_gluon_trainer.py.


----------------------------------------------------------------
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