Skip to content

Commit 93d168e

Browse files
committed
Docs page for DEVELOPMENT.md content
- update dev branch name
1 parent 41b81e8 commit 93d168e

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

DEVELOPMENT.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Development
22

33
The following features are under active development:
4+
The current development branch "dev/jax" implements
45

56
* [Experimental Support for GPUs/TPUs](#experimental-support-for-gpustpus)
67

docs/pages/gpu_features.rst

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
Experimental Support for GPUs/TPUs
2+
==================================
3+
The current development branch "dev/jax" implements experimental support
4+
for GPUs/TPUs.
5+
6+
Although OQuPy is built on top of the backend-agnostic
7+
`TensorNetwork <https://github.com/google/TensorNetwork>`__ library,
8+
OQuPy uses vanilla NumPy and SciPy throughout its implementation.
9+
10+
The "dev/jax" branch adds supports for GPUs/TPUs via the
11+
`JAX <https://jax.readthedocs.io/en/latest/>`__ library. A new
12+
``oqupy.backends.numerical_backend.py`` module handles the
13+
`breaking changes in JAX
14+
NumPy <https://jax.readthedocs.io/en/latest/notebooks/Common_Gotchas_in_JAX.html>`__,
15+
while the rest of the modules utilizes ``numpy`` and ``scipy.linalg``
16+
instances from there without explicitly importing JAX-based libraries.
17+
18+
Enabling Experimental Features
19+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20+
21+
To enable experimental features, switch to the ``dev/jax`` branch and use
22+
23+
.. code:: python
24+
25+
from oqupy.backends import enable_gpu_features
26+
enable_gpu_features()
27+
28+
Contributing Guidelines
29+
~~~~~~~~~~~~~~~~~~~~~~~
30+
31+
To contribute features compatible with the JAX backend,
32+
please adhere to the following set of guidelines:
33+
34+
- avoid wildcard imports of NumPy and SciPy.
35+
- use ``from oqupy.backends.numerical_backend import np`` instead of
36+
``import numpy as np`` and use the alias ``default_np`` in cases
37+
vanilla NumPy is explicitly required.
38+
- use ``from oqupy.backends.numerical_backend import la`` instead of
39+
``import scipy.linalg as la``, except that for non-symmetric
40+
eigen-decomposition, ``scipy.linalg.eig`` should be used.
41+
- use one of ``np.dtype_complex`` (``np.dtype_float``) or
42+
``oqupy.config.NumPyDtypeComplex`` (``oqupy.config.NumPyDtypeFloat``)
43+
instead of ``np.complex_`` (``np.float_``).
44+
- convert lists or tuples to arrays when passing them as arguments
45+
inside functions.
46+
- use ``array = np.update(array, indices, values)`` instead of
47+
``array[indices] = values``.
48+
- use ``np.get_random_floats(seed, shape)`` instead of
49+
``np.random.default_rng(seed).random(shape)``.
50+
- declare signatures for ``np.vectorize`` explicitly.
51+
- avoid directly changing the ``shape`` attribute of an array (use
52+
``.reshape`` instead)

0 commit comments

Comments
 (0)