갈루아의 반서재

 

 

Cirq는 양자회로를 작성, 조작, 최적화하고 양자컴퓨터와 시뮬레이터에서 구동하는 소프트웨어 라이브러리이다. Cirq는 하드웨어 상세를 추상화시켜 사용하지 못하게하는 대신에 하드웨어 상세를 노출하고자 한다. 왜냐하면, Noisy Intermediate-Scale Quantum (NISQ) 체제에서는 이러한 하드웨어 상세가 회로를 구동시킬 것인지 말 것인지를 결정하기 때문이다. 

이하 리눅스 환경에서의 cirq 설치에 대해 알아본다. 먼저 설치된 파이썬 버전이 3.6.0 이상인지 확인한다. 향후 텐서플로우 사용을 고려하면 3.7 버전이 적당하겠다.

(tfquantum) founder@hilbert:~$ python --version
Python 3.7.7

 

pip를 사용하여 cirq 를 설치한다. 먼저 pip 를 최신버전으로 업그레이드한다.

(tfquantum) founder@hilbert:~$ python -m pip install --upgrade pip
Requirement already up-to-date: pip in ./anaconda3/envs/tfquantum/lib/python3.7/site-packages (20.0.2)

cirq 를 설치한다.

(tfquantum) founder@hilbert:~$ python -m pip install cirq
Successfully installed cachetools-4.0.0 chardet-3.0.4 cirq-0.7.0 cycler-0.10.0 google-api-core-1.16.0 google-api-python-client-1.8.0 google-auth-1.12.0 google-auth-httplib2-0.0.3 googleapis-common-protos-1.51.0 httplib2-0.17.0 idna-2.9 kiwisolver-1.1.0 matplotlib-3.2.1 mpmath-1.1.0 networkx-2.3 numpy-1.18.2 pandas-1.0.3 protobuf-3.8.0 pyasn1-0.4.8 pyasn1-modules-0.2.8 pyparsing-2.4.6 pytz-2019.3 requests-2.23.0 rsa-4.0 scipy-1.4.1 sortedcontainers-2.1.0 sympy-1.4 typing-extensions-3.7.4.1 uritemplate-3.0.1 urllib3-1.25.8

(선택사항) cirq.contrib 의 의존 라이브러리를 설치한다.

(tfquantum) founder@hilbert:~$ python -m pip install cirq[contrib]
Successfully installed ordered-set-3.1.1 ply-3.11 pylatex-1.3.1

설치가 끝나면 다음의 결과가 정상적으로 출력되는지 확인한다.

 

(tfquantum) founder@hilbert:~$ python -c 'import cirq; print(cirq.google.Foxtail)'
(0, 0)───(0, 1)───(0, 2)───(0, 3)───(0, 4)───(0, 5)───(0, 6)───(0, 7)───(0, 8)───(0, 9)───(0, 10)
│        │        │        │        │        │        │        │        │        │        │
│        │        │        │        │        │        │        │        │        │        │
(1, 0)───(1, 1)───(1, 2)───(1, 3)───(1, 4)───(1, 5)───(1, 6)───(1, 7)───(1, 8)───(1, 9)───(1, 10)

윈도우 등 다른 OS 에서의 설치에 대해서는 하단 링크를 참고한다.

https://github.com/quantumlib/Cirq/blob/master/docs/install.md

 

quantumlib/Cirq

A python framework for creating, editing, and invoking Noisy Intermediate Scale Quantum (NISQ) circuits. - quantumlib/Cirq

github.com