NVIDIA nvmath-python

nvmath-python is an open source Python library that provides native NVIDIA CUDA-X™ math library performance through high-level, reimagined Python APIs. It supports JIT compilation, kernel fusion, and multi-GPU distributed execution for linear algebra, FFT, and sparse operations — without requiring C++ or manual CUDA management. Compatible with NumPy, CuPy, and PyTorch. 

NVIDIA nvmath-python is designed to seamlessly enhance and complement the existing scientific Python ecosystem, it eliminates the performance compromises found in standard array libraries. 

Whether you’re a data practitioner, an open source library developer, or a specialist writing extreme-performance GPU kernels, nvmath-python provides the transparency and architectural access you need.


How does nvmath-python deliver GPU accelerated performance in Python?

nvmath-python bridges the gap between scientific Python ecosystems and low-level hardware acceleration by seamlessly routing standard mathematical expressions directly to high-performance NVIDIA CUDA-X libraries. The workflow begins when high-level data arrays from frameworks like NumPy, CuPy, or PyTorch are passed into nvmath-python’s stateful or stateless APIs. From there, the library’s internal Just-In-Time (JIT) machinery kicks in for the compilation of the Python code and/or for a kernel fusion to bring the performance efficiency to new heights. 

When single-GPU limits are reached, the library offers a seamless transition to multiple GPUs by offering distributed APIs that allow scaling your math library operations to thousands of GPUs, thanks to the underlying libraries like cuBLASMp, cuSOLVERMp, and cuFFTMp and backends like NCCL and NVSHMEM.

GitHub

Explore the open source repository for nvmath-python. Access the source code, report issues, and view real-world implementation examples that bridge Python with NVIDIA CUDA-X math libraries.

Notebooks

Get hands-on with a collection of interactive Jupyter notebooks. These practical examples cover everything from basic host APIs to advanced multi-GPU distributed linear algebra and custom device kernels.

Tutorials

A comprehensive guide demonstrating how to use stateful execution planning, advanced kernel fusion callbacks, and distributed process groups to scale workloads seamlessly across multiple GPUs and nodes.


Key Features of nvmath-python

Accelerate workloads with high-level APIs, seamless scaling, and zero ecosystem friction.

Intuitive Pythonic APIs

nvmath-python APIs cover sophisticated use cases that allow planning, autotuning, and JIT-compilation/ kernel fusions, which are impossible with standard NumPy-like libraries without performance compromises. And this architectural sophistication doesn’t come at the expense of simplicity; everything is as simple as NumPy.

Scalable Performance

Push execution limits close to underlying native CUDA-X libraries. Bypass the limitations of a single device with distributed entry points that seamlessly scale out to multi-GPU arrays and clustered nodes using NCCL backends. You can scale your linear algebra and FFT workloads across massive data grids without a major code rewrite.

Interoperability

Accelerate math operations without replacing your favorite array libraries. nvmath-python works as a drop-in companion to NumPy, CuPy, and PyTorch, supporting effortless transition between CPU and GPU memory spaces. Keep your familiar workflows, data structures, and indexing patterns intact while offloading heavy numerical math to native hardware.


How does nvmath-python achieve high-level performance?

nvmath-python bridges the gap between high-level Python and bare-metal performance. By leveraging automatic JIT compilation, dynamic kernel fusion, and execution planning amortization, it eliminates standard framework overheads to unlock native NVIDIA CUDA-X execution speeds.

API Preparation Costs Amortization (10 Matmuls)

This chart measures the total API overhead time in milliseconds (lower is better) to execute a sequence of 10 matrix multiplications, demonstrating how transitioning to a stateful class-form layout dramatically eliminates repeated execution planning overhead.

Bar chart showing API overhead time in milliseconds for 10 sequential matrix multiplications. Stateful class-form API reduces repeated execution planning overhead compared to stateless calls. Lower is better.

Compilable Callbacks (Spectral Filtering)

This chart contrasts the total GPU execution time in milliseconds (lower is better) between an unfused signal processing routine and an optimized routine that compiles custom filtering code straight into a native cuFFT execution stream via JIT-compiled callbacks.

Bar chart comparing total GPU execution time in milliseconds for spectral filtering. JIT-compiled cuFFT callback routine runs significantly faster than the unfused baseline. Lower is better

Custom Device Kernels (GBM Monte Carlo)

This chart highlights GPU time in milliseconds (lower is better) for a continuous simulation workflow, showing how nesting raw cuRAND primitives directly within custom Numba CUDA device kernels bypasses the performance-crippling host synchronization penalties of basic array operations.

Bar chart comparing total GPU execution time in milliseconds for spectral filtering. JIT-compiled cuFFT callback routine runs significantly faster than the unfused baseline. Lower is better

Kernel Fusion (Matmul)

This chart tracks GPU computation time in milliseconds (lower is better) to show the performance leap achieved when separate primitive operations are dynamically fused straight into a single, unified compute kernel at runtime.

Bar chart comparing GPU computation time in milliseconds for matrix multiplication with and without kernel fusion. Dynamically fused kernel at runtime achieves significantly faster execution than separate primitive operations. Lower is better.

Multi-GPU Scaling (Matmul)

This chart measures total GPU execution latency in milliseconds (lower is better) across expanding hardware topologies, illustrating how distributed process groups seamlessly scale computing throughput as workload demands outgrow a single device.

Bar chart measuring total GPU execution latency in milliseconds for matrix multiplication across multiple GPU configurations. nvmath-python distributed process groups scale throughput linearly as device count increases. Lower is better

nvmath-python Learning Paths: Kernel Fusion, Distributed Scaling, and More

These curated resource bundles provide structural paths to help you conquer common bottlenecks—whether you’re maximizing arithmetic intensity on a single GPU or distributing complex linear algebra operations across a cluster.

The Multi-GPU Distributed Scaling Blueprint

Transition seamlessly from single-device execution to multi-node configurations without altering your core numerical expressions.


Learning Library

nvmath-python Documentation, Tutorials, and Code Examples

Tech Blog

Simplify Sparse Deep Learning With Universal Sparse Tensor in nvmath-python

Tech Blog

Learn how Universal Sparse Tensor (UST) introduced in nvmath-python v0.9.0 enables accelerating sparse scientific and DL applications.

Code Samples

Examples

NVIDIA nvmath-python

Discover the hierarchy of mathematical operations across host, device, and raw CUDA-X bindings for dense and sparse structures.

Video

Deep Dive Into Math Libraries

GTC Session On-Demand

This session recording provides a deep dive into the advancements in NVIDIA’s GPU-accelerated Math Libraries. 

Tech Blog

Fusing Epilog Operations With Matrix Multiplication Using nvmath-python

Tech Blog

Learn how to fuse epilog operations with matrix multiplication in nvmath-python to implement common forward and backward pass operations of a neural network.

Webpage

CUDA Math Libraries

Libraries

Accelerate high-performance computing workloads by exploring the underlying suite of native NVIDIA CUDA-X math libraries, including cuBLAS, cuSPARSE, and cuSOLVER, which power nvmath-python’s execution engine.


nvmath-python FAQ

Get answers to common questions about NVIDIA® nvmath-python ®, including supported platforms, features, and applications.

nvmath-python is an open source library that provides high-level, Pythonic APIs to access NVIDIA’s high-performance CUDA-X math libraries. It allows developers to achieve near-native hardware acceleration while maintaining the simplicity of the standard scientific Python ecosystem, effectively eliminating performance bottlenecks found in conventional array libraries.

While standard libraries often suffer from performance overhead due to high-level abstractions, nvmath-python utilizes a Just-In-Time (JIT) machinery and kernel fusion to bridge the gap between high-level Python code and low-level hardware execution. It is designed to work as a drop-in companion rather than a replacement, allowing you to offload heavy numerical computations to native NVIDIA hardware. It is designed for interoperability and works as a companion to libraries like NumPy, CuPy, and PyTorch. It supports seamless transitions between CPU and GPU memory spaces, allowing you to keep your existing data structures and workflows intact.

To use nvmath-python, you should be familiar with the scientific Python ecosystem (NumPy/CuPy/PyTorch) and have access to an NVIDIA GPU. Understanding the basics of CUDA or HPC concepts can help you take full advantage of the library's performance-tuning features.

Yes, nvmath-python allows for advanced customization, including custom device kernels and JIT-compiled callbacks. This provides the flexibility to implement unique mathematical routines that run at hardware-native speeds.

nvmath-python includes support for sparse structures, such as the Universal Sparse Tensor (UST). This allows developers to accelerate sparse scientific and deep learning applications, simplifying the complexities traditionally associated with sparse tensor operations.

You can begin by installing the package from the NVIDIA documentation site. The site provides a comprehensive installation guide, quickstart tutorials, and links to open-source repositories to help you integrate nvmath-python into your existing workflows.

Yes, a collection of interactive Jupyter notebooks is available in the official GitHub repository. These notebooks cover a wide range of use cases, from basic host APIs to advanced multi-GPU distributed linear algebra and custom device kernels.

You can join the NVIDIA Developer Forums to discuss nvmath-python, report issues, and share experiences with other developers and NVIDIA experts.

While specific metrics vary by workload, the library enables significant performance leaps by eliminating host synchronization penalties and streamlining kernel execution. You can use the provided examples to benchmark your own workloads.

nvmath-python is an open source library, and contributions are encouraged. You can report bugs, request features, or submit pull requests directly to the repository on GitHub.


More Resources

Decorative image representing Developer Newsletter

Sign Up for the Developer Newsletter

Decorative image representing Developer Program

Join the NVIDIA Developer Program

 Decorative image representing Community

Accelerate Your Startup

Get started with nvmath-python

Install Now