Tensorcircuit Installation Guide on MacOS#

Contributed by Mark (Zixuan) Song

Apple has updated Tensorflow (for MacOS) so that installation on M-series (until M2) and Intel-series Mac can follow the exact same procedure.

Starting From Scratch#

For completely new Macos or Macos without Xcode installed.

If you have Xcode installed, skip to Install TC backends.

Install Xcode Command Line Tools#

Need graphical access to the machine.

Run xcode-select --install to install if on optimal internet.

Or Download it from Apple Command Line Tools installation image then install it if the internet connection is weak.

Install TC Backends#

There are four backends to choose from, Numpy, Tensorflow, Jax, and Torch.

Install Jax, Pytorch (Optional)#

pip install [Package Name]

Install Tensorcircuit#

pip install tensorcircuit

Benchmarking#

This data is collected by running benchmarks/scripts/vqe_tc.py 10 times and average results.

Vanilla Tensorflow Apple Tensorflow Apple Tensorflow with Metal Plugin
Construction Time 11.49241641s 11.31878941s 11.6103961s
Iteration time 0.002313011s 0.002333004s 0.046412581s
Total time 11.72371747s 11.55208979s 16.25165417s

Until July 2023, this has been tested on Intel Macs running Ventura, M1 Macs running Ventura, M2 Macs running Ventura, and M2 Macs running Sonoma beta.