Product Information

nvmath-python Epilog and NEWS DETAIL

Current Position:Home > News and Insights
News and technical insightsNews and Insights ITZKXY enterprise networking and AI infrastructure support2025-01-20

nvmath-python (Beta) Python, Python provides NVIDIA CUDA-X nvmath-python is a networking product designed for enterprise and data center networking.

, nvmath-python Product Information FFT is a networking product designed for enterprise and data center networking.

nvmath-python, Product Information This product is a networking product designed for enterprise and data center networking.

RELU_BIAS

epilogs is a networking product designed for enterprise and data center networking.

ReLU is a networking product designed for enterprise and data center networking.

Product Information

relu(Wx + B)

Product Information

  • x Product Information n 	imes b:

    • n This product is a networking product designed for enterprise and data center networking.

    • b This product is a networking product designed for enterprise and data center networking.

  • W Product Information m 	imes n:

    • m This product is a networking product designed for enterprise and data center networking.

    • n This product is a networking product designed for enterprise and data center networking.

  • B Product Information m This product is a networking product designed for enterprise and data center networking.

, and CuPy:

num_inputs, num_outputs = 784, 100
batch_size = 256
 
weights = cupy.random.rand(num_outputs, num_inputs)
bias = cupy.random.rand(num_outputs)
x = cupy.zeros((num_inputs, batch_size))

, nvmath-python WxReLU is a networking product designed for enterprise and data center networking.

Product Information nvmath.linalg.advanced.Matmul class.html is a networking product designed for enterprise and data center networking. Matmul nvmath.linalg.advanced.Matmul is a networking product designed for enterprise and data center networking.

mm = Matmul(weights, x)
mm.plan()
 
def forward():
    y = mm.execute()
    y += bias[:,cupy.newaxis]
    y[y 0] = 0
    return y

RELU_BIAS is a networking product designed for enterprise and data center networking.

Product Information Matmul.plan Product Information epilog This product is a networking product designed for enterprise and data center networking. RELU_BIASProduct Information epilog_inputs This product is a networking product designed for enterprise and data center networking. nvmath.linalg.advanced.Matmul 

from nvmath.linalg.advanced import MatmulEpilog
 
mm = Matmul(weights, x)
mm.plan(epilog=MatmulEpilog.RELU_BIAS, epilog_inputs={"bias": bias})
 
def forward():
    y = mm.execute()
    return y

ReLU is a networking product designed for enterprise and data center networking. ReLU Product Information RELU_AUX_BIAS This product is a networking product designed for enterprise and data center networking.

Product InformationMatmul.execute This product is a networking product designed for enterprise and data center networking. RELU_AUX_BIAS Product Information relu_auxReLu is a networking product designed for enterprise and data center networking.

from nvmath.linalg.advanced import MatmulEpilog
 
mm = Matmul(weights, x)
mm.plan(epilog=MatmulEpilog.RELU_AUX_BIAS, epilog_inputs={"bias": bias})
 
relu_mask = None
 
def forward():
    global relu_mask
    y, aux_outputs = mm.execute()
     relu_aux = aux_outputs["relu_aux"]
    return y

A block diagram shows the operations of a forward pass: multiplication by the weights, addition of bias and application of ReLU. Matmul with RELU_AUX_BIAS epilog is handling all three operations, and producing the ReLU mask as an auxiliary output.
1, Matmul RELU_AUX_BIAS

Product Information RELU_AUX_BIAS epilog is a networking product designed for enterprise and data center networking.

A bar plot showing the performance of the naive implementation and RELU_AUX_BIAS. Naive implementation reaches 62.8% of peak TFLOP/s, and RELU_AUX_BIAS reaches 79.7%.
2.

65536 is a NVIDIA networking product designed for enterprise and data center networking.

DRELU_BGRAD

This product is a networking product designed for enterprise and data center networking.

This product is a networking product designed for enterprise and data center networking. Product Information 

ReLU is a networking product designed for enterprise and data center networking.

A block diagram shows the operations of a forward pass with multiple linear layers: multiplication by weights, adding bias, applying ReLU, multiplying by weights, adding bias, and so on. The backward pass box covers adding bias, applying ReLu, and multiplying by weights.
3. forward and backward covering

Product Information t_0 Product Information t_1t_2 and t_3 Product Information

  • t_1 = x + B

  • t_2 = relu(t_1)

  • t_3 = Wt_3

, loss function L Product Information t_3Product Information rac{partial L}{partial t_3}This product is a networking product designed for enterprise and data center networking. Automatic Differentiation and Neural Networks 

  • rac{partial L}{partial W} = t_2^T rac{partial L}{partial t_3}

  • rac{partial L}{partial t_2} = W^T rac{partial L}{partial t_3}

  • rac{partial L}{partial t_1} = 0Product Information t_1 Product Informationrac{partial L}{partial t_1} = rac{partial L}{partial t_2}Product Information t_2 (ReLU)

  • rac{partial L}{partial B} Product Information rac{partial L}{partial t_1}, and

A block diagram shows the operations of a forward pass and backward pass, with the formulas for gradients. Matmul with DRELU_BGRAD epilog covers computing the gradients for t2 (multiplying by weights), t1 (applying ReLU mask) and B (batch sum). Computing the gradients for W is not covered by the DRELU_BGRAD epilog.
4., DRELU_BGRAD

Product Information rac{partial L}{partial B} and rac{partial L}{partial t_1} for MatmulThis product is a networking product designed for enterprise and data center networking.

mm = Matmul(weights.T, grad)
mm.plan()
 
def backward():
    grad_t1 = mm.execute()
    grad_t1[mask] = 0  # assuming that `mask = (t1
    grad_bias = cupy.sum(grad_t1, axis=1)
    return grad_t1, grad_bias

Product Information DRELU_BGRAD This product is a networking product designed for enterprise and data center networking. rac{partial L}{partial t_3} CuPy grad This product is a networking product designed for enterprise and data center networking.DRELU_BGRAD epilog relu_auxProduct Information RELU_AUX_BIAS epilog is a networking product designed for enterprise and data center networking. rac{partial L}{partial B}

mm = Matmul(weights.T, grad)
mm.plan(epilog=MatmulEpilog.DRELU_BGRAD, epilog_inputs={"relu_aux":relu_mask})
 
def backward():
    grad_t1, aux_outputs = mm.execute()
    grad_bias = aux_outputs["drelu_bgrad"]
    return grad_t1, grad_bias

A bar plot shows the performance of the naive implementation and DRELU_BGRAD. Naive implementation reaches 56.9% of peak TFLOP/s, and DRELU_BGRAD reaches 66.4%.
5. Performance comparison of backward pass implementations

65536 is a NVIDIA networking product designed for enterprise and data center networking.