Skip to content

Commit 073b168

Browse files
authored
nvmath-python-0.2.1 (#14)
1 parent f8fe3cd commit 073b168

File tree

231 files changed

+6412
-2697
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

231 files changed

+6412
-2697
lines changed

.gitignore

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,13 @@ dist
1313
build
1414
wheelhouse
1515

16-
#Pytest
16+
#Test
1717
.pytest_cache
18+
*.pickle
19+
.hypothesis/*
1820

1921
#Pipenv
2022
.env*
2123
Pipfile*
2224
.venv*
2325
.pipenv-cache
24-
25-
#Test outputs
26-
*.pickle
27-
.hypothesis/*

.markdownlint.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
MD013:
2-
line_length: 120
2+
line_length: 92
3+
code_block_line_length: 88
34
code_blocks: true
45
tables: false
6+
stern: true
57
MD033:
68
allowed_elements:
79
- img

.pre-commit-config.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,15 @@ repos:
108108
rev: v0.41.0
109109
hooks:
110110
- id: markdownlint
111-
args: ["--fix"]
111+
# Ignore old internal README that will not be rendered as docs page
112+
args: ["--fix", "--ignore", "internal/gtc2024/README.md"]
113+
114+
- repo: https://github.com/sphinx-contrib/sphinx-lint
115+
rev: v1.0.0
116+
hooks:
117+
- id: sphinx-lint
118+
args: ["--enable", "all", "--max-line-length", "92"]
119+
exclude: ^(.*)generated/(.*)\.rst$
112120

113121
default_language_version:
114-
python: python3
122+
python: python310

CONTRIBUTING.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
# Contributing
22

3-
Thank you for your interest in contributing to `nvmath-python`! Based on the type of contribution, it will fall into
4-
three categories:
3+
Thank you for your interest in contributing to `nvmath-python`! Based on the type of
4+
contribution, it will fall into three categories:
55

66
1. You want to report a bug, feature request, or documentation issue
7-
- File an [issue](https://github.com/NVIDIA/nvmath-python/issues) describing what you encountered or what you want
8-
to see changed.
9-
- The NVIDIA team will evaluate the issues and triage them, scheduling them for a release. If you believe the issue
10-
needs priority attention comment on the issue to notify the team.
7+
- File an [issue](https://github.com/NVIDIA/nvmath-python/issues) describing what you
8+
encountered or what you want to see changed.
9+
- The NVIDIA team will evaluate the issues and triage them, scheduling them for a
10+
release. If you believe the issue needs priority attention comment on the issue to
11+
notify the team.
1112
2. You want to implement a feature or bug-fix
12-
- At this time we do not accept code contributions. However, we do plan to change and accept contributions in the
13-
near future, although the timeline is TBD. Please let us know if you're interested in contributing (and in what
14-
aspect) so that we can plan accordingly.
13+
- At this time we do not accept code contributions. However, we do plan to change and
14+
accept contributions in the near future, although the timeline is TBD. Please let us
15+
know if you're interested in contributing (and in what aspect) so that we can plan
16+
accordingly.
1517
3. You want to share your nice work built upon `nvmath-python`:
16-
- We would love to hear more about your work! Please share with us on [NVIDIA/nvmath-python GitHub
17-
Discussions](https://github.com/NVIDIA/nvmath-python/discussions)! We also take any `nvmath-python`-related
18-
questions on this forum.
18+
- We would love to hear more about your work! Please share with us on
19+
[NVIDIA/nvmath-python GitHub
20+
Discussions](https://github.com/NVIDIA/nvmath-python/discussions)! We also take any
21+
`nvmath-python`-related questions on this forum.

DESCRIPTION.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
nvmath-python: NVIDIA Math Libraries for the Python Ecosystem
33
*************************************************************
44

5-
`nvmath-python <https://developer.nvidia.com/nvmath-python>`_ brings the power and performance of NVIDIA math libraries to the Python ecosystem
6-
with intuitive, pythonic APIs. The ultimate goal is to provide users full access to all of the available library features in a variety of execution spaces.
5+
`nvmath-python <https://developer.nvidia.com/nvmath-python>`_ brings the power and
6+
performance of NVIDIA math libraries to the Python ecosystem with intuitive, pythonic APIs.
7+
The ultimate goal is to provide users full access to all of the available library features
8+
in a variety of execution spaces.
79

810
* `Documentation <https://docs.nvidia.com/cuda/nvmath-python/index.html>`_
911
* `Examples <https://github.com/NVIDIA/nvmath-python/tree/main/examples>`_
@@ -15,4 +17,6 @@ Installation
1517
1618
pip install nvmath-python[cu12]
1719
18-
Please refer to the `installation instructions <https://docs.nvidia.com/cuda/nvmath-python/latest/getting-started.html>`_ for different ways of installing nvmath-python, including building from source.
20+
Please refer to the `installation instructions
21+
<https://docs.nvidia.com/cuda/nvmath-python/latest/installation.html>`_ for different
22+
ways of installing nvmath-python, including building from source.

README.md

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,48 @@
11
<h1 align="center"><img
22
src="docs/sphinx/_static/nvmath-python-green-r4.svg"
3-
alt="A green cube with three sides visible. Dots, a sine wave, and a grid on the three faces."
3+
alt="A cube with three sides visible. Dots, a sine wave, and a grid on the faces."
44
width="200"/>
55
</h1>
66

77
# nvmath-python: NVIDIA Math Libraries for the Python Ecosystem
88

9-
nvmath-python brings the power of the NVIDIA math libraries to the Python ecosystem. The package aims to provide
10-
intuitive pythonic APIs that provide users full access to all the features offered by NVIDIA's libraries in a variety of
11-
execution spaces. nvmath-python works seamlessly with existing Python array/tensor frameworks and focuses on providing
9+
nvmath-python brings the power of the NVIDIA math libraries to the Python ecosystem. The
10+
package aims to provide intuitive pythonic APIs that provide users full access to all the
11+
features offered by NVIDIA's libraries in a variety of execution spaces. nvmath-python works
12+
seamlessly with existing Python array/tensor frameworks and focuses on providing
1213
functionality that is missing from those frameworks.
1314

1415
## Some Examples
1516

16-
Using the nvmath-python API allows access to all parameters of the underlying NVIDIA cuBLASLt library. Some of these
17-
parameters are unavailable in other wrappings of NVIDIA's C-API libraries.
17+
Using the nvmath-python API allows access to all parameters of the underlying NVIDIA
18+
cuBLASLt library. Some of these parameters are unavailable in other wrappings of NVIDIA's
19+
C-API libraries.
1820

1921
```python
2022
import cupy as cp
2123
import nvmath
2224

23-
# Prepare sample input data. nvmath-python accepts input tensors from pytorch, cupy, and numpy.
25+
# Prepare sample input data. nvmath-python accepts input tensors from pytorch, cupy, and
26+
# numpy.
2427
m, n, k = 123, 456, 789
2528
a = cp.random.rand(m, k).astype(cp.float32)
2629
b = cp.random.rand(k, n).astype(cp.float32)
2730
bias = cp.random.rand(m, 1).astype(cp.float32)
2831

29-
# Use the stateful Matmul object in order to perform multiple matrix multiplications without replanning. The nvmath API
30-
# allows us to fine-tune our operations by, for example, selecting a mixed-precision compute type.
32+
# Use the stateful Matmul object in order to perform multiple matrix multiplications
33+
# without replanning. The nvmath API allows us to fine-tune our operations by, for
34+
# example, selecting a mixed-precision compute type.
3135
mm = nvmath.linalg.advanced.Matmul(
3236
a,
3337
b,
34-
options={"compute_type": nvmath.linalg.advanced.MatmulComputeType.COMPUTE_32F_FAST_16F},
38+
options={
39+
"compute_type": nvmath.linalg.advanced.MatmulComputeType.COMPUTE_32F_FAST_16F
40+
},
3541
)
3642

37-
# Plan the matrix multiplication. Planning returns a sequence of algorithms that can be configured. We can also select
38-
# epilog operations which are applied to the result of the multiplication without a separate function call.
43+
# Plan the matrix multiplication. Planning returns a sequence of algorithms that can be
44+
# configured. We can also select epilog operations which are applied to the result of
45+
# the multiplication without a separate function call.
3946
mm.plan(
4047
epilog=nvmath.linalg.advanced.MatmulEpilog.BIAS,
4148
epilog_inputs={"bias": bias},
@@ -47,23 +54,27 @@ result = mm.execute()
4754
# Remember to free the Matmul object when finished or use it as a context manager
4855
mm.free()
4956

50-
# Synchronize the default stream, since by default the execution is non-blocking for GPU operands.
57+
# Synchronize the default stream, since by default the execution is non-blocking for
58+
# GPU operands.
5159
cp.cuda.get_current_stream().synchronize()
5260
print(f"Input types = {type(a), type(b)}, device = {a.device, b.device}")
5361
print(f"Result type = {type(result)}, device = {result.device}")
5462
```
5563

56-
nvmath-python exposes NVIDIA's device-side (Dx) APIs. This allows developers to call NVIDIA library functions inside
57-
their custom device kernels. For example, a numba jit function can call cuFFT in order to implement FFT-based
58-
convolution.
64+
nvmath-python exposes NVIDIA's device-side (Dx) APIs. This allows developers to call NVIDIA
65+
library functions inside their custom device kernels. For example, a numba jit function can
66+
call cuFFT in order to implement FFT-based convolution.
5967

6068
```python
6169
import numpy as np
6270
from numba import cuda
6371
from nvmath.device import fft
6472

6573
def random_complex(shape, real_dtype):
66-
return np.random.randn(*shape).astype(real_dtype) + 1.j * np.random.randn(*shape).astype(real_dtype)
74+
return (
75+
np.random.randn(*shape).astype(real_dtype)
76+
+ 1.j * np.random.randn(*shape).astype(real_dtype)
77+
)
6778

6879
def main():
6980

@@ -148,9 +159,9 @@ if __name__ == "__main__":
148159
main()
149160
```
150161

151-
nvmath-python provides the ability to write custom prologs and epilogs for FFT functions as a Python functions and
152-
compiled them LTO-IR. For example, to have unitary scaling for an FFT, we can define an epilog which rescales the output
153-
by 1/sqrt(N).
162+
nvmath-python provides the ability to write custom prologs and epilogs for FFT functions as
163+
a Python functions and compiled them LTO-IR. For example, to have unitary scaling for an
164+
FFT, we can define an epilog which rescales the output by 1/sqrt(N).
154165

155166
```python
156167
import cupy as cp
@@ -175,7 +186,8 @@ with cp.cuda.Device():
175186
# Perform the forward FFT, applying the filter as a epilog...
176187
r = nvmath.fft.fft(a, axes=[-1], epilog={"ltoir": epilog})
177188

178-
# Finally, we can test that the fused FFT run result matches the result of separate calls
189+
# Finally, we can test that the fused FFT run result matches the result of separate
190+
# calls
179191
s = cp.fft.fftn(a, axes=[-1], norm="ortho")
180192

181193
assert cp.allclose(r, s)
@@ -187,5 +199,6 @@ All files hosted in this repository are subject to the [Apache 2.0](./LICENSE) l
187199

188200
## Disclaimer
189201

190-
nvmath-python is in a Beta state. Beta products may not be fully functional, may contain errors or design flaws, and may
191-
be changed at any time without notice. We appreciate your feedback to improve and iterate on our Beta products.
202+
nvmath-python is in a Beta state. Beta products may not be fully functional, may contain
203+
errors or design flaws, and may be changed at any time without notice. We appreciate your
204+
feedback to improve and iterate on our Beta products.

SECURITY.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,32 @@
11
# Security
22

3-
NVIDIA is dedicated to the security and trust of our software products and services, including all source code
4-
repositories managed through our organization.
3+
NVIDIA is dedicated to the security and trust of our software products and services,
4+
including all source code repositories managed through our organization.
55

6-
If you need to report a security issue, please use the appropriate contact points outlined below. **Please do not report
7-
security vulnerabilities through GitHub/GitLab.**
6+
If you need to report a security issue, please use the appropriate contact points outlined
7+
below. **Please do not report security vulnerabilities through GitHub/GitLab.**
88

99
## Reporting Potential Security Vulnerability in nvmath-python
1010

1111
To report a potential security vulnerability in nvmath-python:
1212

13-
- Web: [Security Vulnerability Submission Form](https://www.nvidia.com/object/submit-security-vulnerability.html)
13+
- Web: [Security Vulnerability Submission
14+
Form](https://www.nvidia.com/object/submit-security-vulnerability.html)
1415
- E-Mail: <[email protected]>
15-
- We encourage you to use the following PGP key for secure email communication: [NVIDIA public PGP Key for communication](https://www.nvidia.com/en-us/security/pgp-key)
16+
- We encourage you to use the following PGP key for secure email communication: [NVIDIA
17+
public PGP Key for communication](https://www.nvidia.com/en-us/security/pgp-key)
1618
- Please include the following information:
1719
- Product/Driver name and version/branch that contains the vulnerability
1820
- Type of vulnerability (code execution, denial of service, buffer overflow, etc.)
1921
- Instructions to reproduce the vulnerability
2022
- Proof-of-concept or exploit code
21-
- Potential impact of the vulnerability, including how an attacker could exploit the vulnerability
23+
- Potential impact of the vulnerability, including how an attacker could exploit the
24+
vulnerability
2225

23-
While NVIDIA currently does not have a bug bounty program, we do offer acknowledgement when an externally reported
24-
security issue is addressed under our coordinated vulnerability disclosure policy. Please visit our [Product Security
25-
Incident Response Team (PSIRT)](https://www.nvidia.com/en-us/security/psirt-policies/) policies page for more
26+
While NVIDIA currently does not have a bug bounty program, we do offer acknowledgement when
27+
an externally reported security issue is addressed under our coordinated vulnerability
28+
disclosure policy. Please visit our [Product Security Incident Response Team
29+
(PSIRT)](https://www.nvidia.com/en-us/security/psirt-policies/) policies page for more
2630
information.
2731

2832
## NVIDIA Product Security

builder/utils.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,11 @@ def _prep_includes_libs_rpaths(self, lib_name):
9393
if lib_name is not None:
9494
ldflag = "-Wl,--disable-new-dtags"
9595
if lib_name == "nvpl":
96-
# 1. the nvpl bindings land in site-packages/nvmath/bindings/nvpl/_internal/
97-
# as opposed to other packages that have their bindings in
98-
# site-packages/nvmath/bindings/_internal/, so we need one extra `..`
99-
# to get into `site-packages` and then the lib_name=nvpl is not in nvidia
96+
# 1. the nvpl bindings land in
97+
# site-packages/nvmath/bindings/nvpl/_internal/ as opposed to other
98+
# packages that have their bindings in
99+
# site-packages/nvmath/bindings/_internal/, so we need one extra `..` to
100+
# get into `site-packages` and then the lib_name=nvpl is not in nvidia
100101
# dir but directly in the site-packages.
101102
# 2. mkl lib is placed directly in the python `lib` directory, not in
102103
# python{ver}/site-packages

docs/Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ SHELL=/bin/bash
33

44
# You can set these variables from the command line or environment
55
SPHINX_NVMATH_PYTHON_VER ?= $(shell [[ $$(< ../nvmath/_version.py) =~ __version__[^0-9.]*([0-9.]*) ]] && echo $${BASH_REMATCH[1]})
6-
SPHINXOPTS ?= -j auto
6+
SPHINXOPTS ?= -W
77
SPHINXBUILD ?= sphinx-build
88
SOURCEDIR = sphinx
99
BUILDDIR ?= _build/html
@@ -27,4 +27,10 @@ html: Makefile
2727
cd $(BUILDDIR) && cp -a ${SPHINX_NVMATH_PYTHON_VER}/* latest/
2828
cp $(BUILDDIR)/latest/objects.inv $(BUILDDIR)
2929

30-
.PHONY: help Makefile clean html
30+
31+
linkcheck: Makefile
32+
$(eval $@_BUILDDIR := $(shell mktemp -d))
33+
$(SPHINXBUILD) -b $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
34+
rm -rf $($@_BUILDDIR)
35+
36+
.PHONY: help Makefile clean html linkcheck
File renamed without changes.

0 commit comments

Comments
 (0)