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:
[email protected]


Reply via email to