You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**horqrux** is a [JAX](https://jax.readthedocs.io/en/latest/)-based state vector simulator designed for quantum machine learning.
4
-
It acts as a backend for [`Qadence`](https://github.com/pasqal-io/qadence), a digital-analog quantum programming interface.
5
+
`horqrux` is a [JAX](https://jax.readthedocs.io/en/latest/)-based state vector simulator designed for quantum machine learning and acts as a backend for [`Qadence`](https://github.com/pasqal-io/qadence), a digital-analog quantum programming interface.
5
6
6
7
## Installation
7
8
8
-
`horqrux` (CPU-only) can be installed from PyPI with `pip` as follows:
9
+
To install the CPU-only version, simply use `pip`:
9
10
```bash
10
11
pip install horqrux
11
12
```
12
-
If you want to install the GPU version, simply do:
`horqrux` adopts a minimalistic and functional interface however the [docs](https://pasqal-io.github.io/horqrux/latest/) provide a comprehensive A-Z guide ranging from how to apply simple primitive and parametric gates, to using [adjoint differentiation](https://arxiv.org/abs/2009.02823) to fit a nonlinear function and implementing [DQC](https://arxiv.org/abs/2011.10395) to solve a partial differential equation.
21
21
22
+
## Contributing
22
23
23
-
## Install from source
24
+
To learn how to contribute, please visit the [CONTRIBUTING](docs/CONTRIBUTING.md) page.
24
25
25
-
We recommend to use the [`hatch`](https://hatch.pypa.io/latest/) environment manager to install `horqrux` from source:
26
+
When developing within `horqrux`, you can either use the python environment manager [`hatch`](https://hatch.pypa.io/latest/):
26
27
27
28
```bash
28
-
python -m pip install hatch
29
+
pip install hatch
29
30
30
-
#get into a shell with all the dependencies
31
-
python -m hatch shell
31
+
#enter a shell with containing all the dependencies
32
+
hatch shell
32
33
33
34
# run a command within the virtual environment with all the dependencies
34
-
python -m hatch run python my_script.py
35
+
hatch run python my_script.py
35
36
```
36
37
37
-
Please note that `hatch` will not combine nicely with other environment managers such Conda. If you want to use Conda, install `horqrux` from source using `pip`:
38
+
When using any other environment manager like `venv` or `conda`, simply do:
38
39
39
40
```bash
40
-
# within the Conda environment
41
-
python -m pip install -e .
41
+
# within the virtual environment
42
+
pip install -e .
42
43
```
43
-
44
-
## Contributing
45
-
46
-
Please refer to [CONTRIBUTING](docs/CONTRIBUTING.md) to learn how to contribute to `horqrux`.
`horqrux` also allows for global state evolution via the `HamiltonianEvolution` operation.
74
+
Note that it expects a hamiltonian and a time evolution parameter passed as `numpy` or `jax.numpy` arrays. To build arbitrary Pauli hamiltonians, we recommend using [Qadence](https://github.com/pasqal-io/qadence/blob/main/examples/backends/low_level/horqrux_analog.py).
75
+
76
+
```python exec="on" source="material-block"
77
+
from jax.numpy import pi, array, diag, kron, cdouble
78
+
from horqrux.analog import HamiltonianEvolution
79
+
from horqrux.apply import apply_gate
80
+
from horqrux.utils import uniform_state
81
+
82
+
sigmaz = diag(array([1.0, -1.0], dtype=cdouble))
83
+
Hbase = kron(sigmaz, sigmaz)
84
+
85
+
Hamiltonian = kron(Hbase, Hbase)
86
+
n_qubits =4
87
+
t_evo = pi /4
88
+
hamevo = HamiltonianEvolution(tuple([i for i inrange(n_qubits)]))
0 commit comments