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 2018/11/29 03:21:35 UTC

[GitHub] zheng-da opened a new issue #13449: significant performance regression in SpMV

zheng-da opened a new issue #13449: significant performance regression in SpMV
URL: https://github.com/apache/incubator-mxnet/issues/13449
 
 
   It seems https://github.com/apache/incubator-mxnet/pull/12380 causes significant performance regression in SpMV. Here is the minimal code for reproducing the bug. It seems the problem occurs only when a model is initialized with multiple GPUs.
   
   use the code below to run the code.
   ```
   python3 sse_batch.py --graph-file ../../data/5_5_csr.nd --gpu 8
   ```
   
   The csr file can be downloaded from
   ```
   aws s3 cp s3://haibin-dgl/5_5_csr.nd .
   ```
   
   ```python
   """
   Learning Steady-States of Iterative Algorithms over Graphs
   Paper: http://proceedings.mlr.press/v80/dai18a.html
   
   """
   import argparse
   import random
   import numpy as np
   import time
   import math
   import mxnet as mx
   from mxnet import gluon
   
   def gcn_msg(edges):
       # TODO should we use concat?
       return {'m': mx.nd.concat(edges.src['in'], edges.src['h'], dim=1)}
   
   def gcn_reduce(nodes):
       return {'accum': mx.nd.sum(nodes.mailbox['m'], 1) / nodes.mailbox['m'].shape[1]}
   
   class NodeUpdate(gluon.Block):
       def __init__(self, out_feats, activation=None, alpha=0.1, **kwargs):
           super(NodeUpdate, self).__init__(**kwargs)
           self.linear1 = gluon.nn.Dense(out_feats, activation=activation)
           # TODO what is the dimension here?
           self.linear2 = gluon.nn.Dense(out_feats)
           self.alpha = alpha
   
       def forward(self, in_data, hidden_data, accum):
           tmp = mx.nd.concat(in_data, accum, dim=1)
           hidden = self.linear2(self.linear1(tmp))
           return hidden_data * (1 - self.alpha) + self.alpha * hidden
   
   def main(args, data):
       update_hidden_train = NodeUpdate(16, 'relu')
       train_ctxs = []
       for i in range(args.gpu):
           train_ctxs.append(mx.gpu(i))
       update_hidden_train.initialize(ctx=train_ctxs)
   
       csr = data.astype('float32')
       dns = mx.nd.ones((csr.shape[1], 200))
       mx.nd.waitall()
       t0 = time.time()
       for i in range(3):
           out = mx.nd.dot(csr, dns)
           out.wait_to_read()
           print(i, time.time() - t0)
           mx.nd.waitall()
   
   if __name__ == '__main__':
       parser = argparse.ArgumentParser(description='GCN')
       parser.add_argument("--graph-file", type=str, default="",
               help="graph file")
       parser.add_argument("--gpu", type=int, default=-1,
               help="gpu")
       args = parser.parse_args()
   
       # load and preprocess dataset
       csr = mx.nd.load(args.graph_file)[0]
       rets1 = main(args, csr)
       #rets2 = main(args, data)
       #for hidden1, hidden2 in zip(rets1, rets2):
       #    print("hidden: " + str(mx.nd.sum(mx.nd.abs(hidden1 - hidden2)).asnumpy()))
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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