Quick start

The main function of the Pychop is the method Chop, which is loaded by

from pychop import Chop

Pychop supports NumPy (default), JAX, Torch as backend for simulation. Before performing the quantization, to set backend:

pychop.backend('numpy') # use NumPy as backend, other options: 'torch' and 'jax'

Note

Users do not need to specify the backend for precision emulation. By using pychop.backend("auto") (which is the default setting), Pychop will automatically detect the required backend

The difference between setting backend and without setting backend is that the speed of the first run is different, others are almost identical:

import pychop
from pychop import Chop
import numpy as np
from time import time

pychop.backend('numpy', 1) # Specify different backends, e.g., jax and torch
np.random.seed(0)
X = np.random.randn(5000, 5000)

ch = Chop(exp_bits=5, sig_bits=10, rmode=3) # half precision

st = time()
X_q = ch(X)
et = time()

print("runtime: ", et - st)
Load NumPy backend.
runtime:  0.65281081199646
import pychop
from pychop import Chop
import numpy as np
from time import time

X = np.random.randn(5000, 5000)

ch = Chop(exp_bits=5, sig_bits=10, rmode=3) # half precision

st = time()
X_q = ch(X)
et = time()

print("runtime: ", et - st)
print(X_q[:10, 0])
runtime:  0.9031667709350586