       for (int j=0; j<nChildren; j++)
       {
         // multiply accumulate weights
-        atomicAdd(&nodeGradWeight[j*nInput + i], scale*nodeGradOutput[j]*buffer[tx]);
-        CudaAssert(isfinite(nodeGradWeight[j*nInput + i]))
+        float dw = scale*nodeGradOutput[j]*buffer[tx];
+        CudaAssert(isfinite(dw))
+        atomicAdd(&nodeGradWeight[j*nInput + i], dw);
       }
     }
     

    for (int j=tx; j<nChildren; j+=i_step)
    {
      // multiply accumulate biases
      atomicAdd(&nodeGradBias[j], scale*nodeGradOutput[j]);
      CudaAssert(isfinite(nodeGradBias[j]))
    }
    
    // keep track of which node gets gradients

    parentIdx = (int)node[0] - 1;
    nChildren = (int)node[1];
    
    CudaAssert(childIdx < nChildren)
    /* Linear */
    
    nodeWeight = weight + parentIdx*nInput;
