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 2019/06/11 18:26:59 UTC
[GitHub] [incubator-mxnet] jschmitz28 opened a new issue #15215: MXNet Row
Sparse SGD Update fails when Row Sparse weights are sparsely populated
jschmitz28 opened a new issue #15215: MXNet Row Sparse SGD Update fails when Row Sparse weights are sparsely populated
URL: https://github.com/apache/incubator-mxnet/issues/15215
## Description
Running the SGD optimizer in MXNet with row sparse weights only seems to work when the weights are not actually sparsely populated: https://github.com/apache/incubator-mxnet/blob/master/src/operator/optimizer_op-inl.h#L541 Would it be feasible to extend this implementation to support cases in which the row sparse weights occupy less storage than if they were dense?
## Environment info (Required)
```
root@a2bbd27fe66f:/opt/amazon# python diagnose.py
----------Python Info----------
Version : 3.6.8
Compiler : GCC 5.4.0 20160609
Build : ('default', 'Dec 24 2018 19:24:27')
Arch : ('64bit', '')
------------Pip Info-----------
Version : 19.1
Directory : /usr/local/lib/python3.6/dist-packages/pip
----------MXNet Info-----------
Version : 1.4.0
Directory : /usr/local/lib/python3.6/dist-packages/mxnet
Commit Hash : a03d59ed867ba334d78d61246a1090cd1868f5da
----------System Info----------
Platform : Linux-4.9.137-0.1.ac.218.74.329.metal1.x86_64-x86_64-with-Ubuntu-16.04-xenial
system : Linux
node : a2bbd27fe66f
release : 4.9.137-0.1.ac.218.74.329.metal1.x86_64
version : #1 SMP Wed Dec 5 15:11:05 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): 16
On-line CPU(s) list: 0-15
Thread(s) per core: 2
Core(s) per socket: 8
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 62
Model name: Intel(R) Xeon(R) CPU E5-2680 v2 @ 2.80GHz
Stepping: 4
CPU MHz: 2800.190
BogoMIPS: 5600.12
Hypervisor vendor: Xen
Virtualization type: full
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 25600K
NUMA node0 CPU(s): 0-15
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx lm constant_tsc rep_good nopl xtopology nonstop_tsc pni pclmulqdq ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm kaiser fsgsbase smep erms xsaveopt
----------Network Test----------
Setting timeout: 10
Timing for MXNet: https://github.com/apache/incubator-mxnet, DNS: 0.0012 sec, LOAD: 0.5148 sec.
Timing for Gluon Tutorial(en): http://gluon.mxnet.io, DNS: 0.0376 sec, LOAD: 0.2087 sec.
Timing for Gluon Tutorial(cn): https://zh.gluon.ai, DNS: 0.0181 sec, LOAD: 0.1037 sec.
Timing for FashionMNIST: https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/gluon/dataset/fashion-mnist/train-labels-idx1-ubyte.gz, DNS: 0.0869 sec, LOAD: 0.1663 sec.
Timing for PYPI: https://pypi.python.org/pypi/pip, DNS: 0.0072 sec, LOAD: 0.3834 sec.
Timing for Conda: https://repo.continuum.io/pkgs/free/, DNS: 0.0213 sec, LOAD: 0.0646 sec.
```
## Error Message:
```
mxnet.base.MXNetError: [21:43:29] src/operator/contrib/…/./operator_common.h:477: Check failed: arr.storage_shape()[0] == arr.shape()[0] SGDUpdate for RowSparse weights is only implemented for RowSparse weights with all rows containing non-zeros. Expects weights.data.shape[0] (6) == weights.shape[0] (100000000).
```
## Minimum reproducible example
```
import mxnet as mx
from mxnet.gluon.contrib.nn import SparseEmbedding
class NDArrayWeightInitializer(mx.init.Initializer):
def __init__(self, nd_array):
super(NDArrayWeightInitializer, self).__init__()
self._nd_array = nd_array
def _init_weight(self, _, arr):
self._nd_array.copyto(arr)
total_users = 100000000
embedding_dimensionality = 100
user_ids_in_context = mx.nd.array([0,2,4,6,8,10])
dense_weights_for_users_in_context = mx.nd.ones((user_ids_in_context.shape[0], embedding_dimensionality))
sparse_weights_for_users_in_context = mx.nd.sparse.row_sparse_array((dense_weights_for_users_in_context, user_ids_in_context), shape=(total_users, embedding_dimensionality))
layer = SparseEmbedding(total_users, embedding_dimensionality)
layer.initialize(init=NDArrayWeightInitializer(sparse_weights_for_users_in_context))
trainer = mx.gluon.Trainer(layer.collect_params(), 'sgd')
user_ids_in_minibatch = mx.nd.array([0,4,8])
with mx.autograd.record():
y = layer(user_ids_in_minibatch)
y.backward()
trainer.step(user_ids_in_minibatch.shape[0])
print(layer.weight.row_sparse_data(row_id=user_ids_in_context).data)
```
## Steps to reproduce
Write minimum repro code to repro.py and run: ```python repro.py```
## What have you tried to solve it?
I have not been able to successfully solve the problem. I posted this onto the MXNet discussion forums here: https://discuss.mxnet.io/t/distributed-training-model-parallelism-with-sparse-embeddings-in-gluon/4147 but haven't gotten a response and it seems github issues may be more active.
----------------------------------------------------------------
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