Skip to content

Commit

Permalink
v1.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Quleaf committed Jan 28, 2021
1 parent 588b460 commit bfde39e
Show file tree
Hide file tree
Showing 43 changed files with 395 additions and 561 deletions.
20 changes: 18 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,27 @@
- Local graph drawing;
- More examples.

## [1.0.3] - Jan-15-2021
### Added
- New cloud simulators:
+ cloud_baidu_sim2_water
+ cloud_baidu_sim2_earth
+ cloud_baidu_sim2_thunder
+ cloud_baidu_sim2_heaven
- Examples update;
- Related docs update;
- Requirements update.
### Changed
- Local file/dir name;
### Deprecated
- cloud_baidu_sim2;
+ New name is cloud_baidu_sim2_water.

## [1.0.2] - Sep-14-2020
### Added
- Update doc links;
- Examples updates;
- Detailed Docs;
- Examples update;
- Related update docs;
- Update requirements.

## [0.0.1] - Sep-02-2020
Expand Down
Binary file added DocRelease/Quick Guide - En.pdf
Binary file not shown.
Binary file removed DocRelease/QuickGuide-En.pdf
Binary file not shown.
Binary file added DocRelease/快速使用指南 - Zh.pdf
Binary file not shown.
Binary file removed DocRelease/快速使用指南-Zh.pdf
Binary file not shown.
Binary file modified DocRelease/用户手册.pdf
Binary file not shown.
20 changes: 13 additions & 7 deletions Example/Level_1/GHZ_Cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,27 @@
from QCompute import *

# Your token:
Define.hubToken = ''
# Define.hubToken = ''

# Create environment
env = QuantumEnvironment()
# Baidu Cloud Quantum Simulator-Sim2
env.backend(BackendName.CloudBaiduSim2)
# Choose backend Baidu Cloud Quantum Simulator-Sim2
env.backend(BackendName.CloudBaiduSim2Water)

q = [env.Q[0], env.Q[1], env.Q[2]] # prepare quantum registers in need
# Initialize the three-qubit circuit
q = [env.Q[0], env.Q[1], env.Q[2]]

# apply gates and measurement operations to construct the circuit:
# Apply a Hadamard gate on the 0th qubit
H(q[0])

# Apply some CX gates where the 0th qubit controls flipping each other qubit
CX(q[0], q[1])
CX(q[0], q[2])

# Measure with the computational basis
MeasureZ(q, range(3))

taskResult = env.commit(1024, fetchMeasure=True) # submit the circuit and execute
# Commit the quest with 1024 shots to the cloud
taskResult = env.commit(1024, fetchMeasure=True)

pprint(taskResult)
pprint(taskResult)
10 changes: 8 additions & 2 deletions Example/Level_1/GHZ_Local.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,25 @@
sys.path.append('../..') # "from QCompute import *" requires this
from QCompute import *


# Create environment
env = QuantumEnvironment()
# Baidu Local Quantum Simulator-Sim2
# Choose backend Baidu Local Quantum Simulator-Sim2
env.backend(BackendName.LocalBaiduSim2)

# Initialize the three-qubit circuit
q = [env.Q[0], env.Q[1], env.Q[2]]

# Apply a Hadamard gate on the 0th qubit
H(q[0])

# Apply some CX gates where the 0th qubit controls flipping each other qubit
CX(q[0], q[1])
CX(q[0], q[2])

# Measure with the computational basis
MeasureZ(q, range(3))

# Commit the quest with 1024 shots to the cloud
taskResult = env.commit(1024, fetchMeasure=True)

pprint(taskResult)
21 changes: 16 additions & 5 deletions Example/Level_1/HCNOT_Cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,31 @@
from QCompute import *

# Your token:
Define.hubToken = ''
# Define.hubToken = ''

# Create environment
env = QuantumEnvironment()
# Baidu Cloud Quantum Simulator-Sim2
env.backend(BackendName.CloudBaiduSim2)
# Choose backend Baidu Cloud Quantum Simulator-Sim2
env.backend(BackendName.CloudBaiduSim2Water)

# Initialize the two-qubit circuit
q = [env.Q[0], env.Q[1]]

# X(q[0])
H(q[0])
# We apply an X gate on the 0th qubit firstly.
# Also, you can comment it as you like.
X(q[0])

# Then we apply a Hadamard gate on the 0th qubit,
# where we comment the gate in order to hint the user you to try yourself.
# H(q[0])

# We need a CX gate to generate an entangle quantum state
CX(q[0], q[1])

# Measure with the computational basis
MeasureZ(q, range(2))

# Commit the request with 1024 shots to the cloud
taskResult = env.commit(1024, fetchMeasure=True)

pprint(taskResult)
23 changes: 16 additions & 7 deletions Example/Level_1/HCNOT_Local.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,31 @@
import sys
from pprint import pprint


sys.path.append('../..') # "from QCompute import *" requires this
from QCompute import *

# Create environment
env = QuantumEnvironment()
# Baidu Local Quantum Simulator-Sim2
# Choose backend Baidu Local Quantum Simulator-Sim2
env.backend(BackendName.LocalBaiduSim2)

q = [env.Q[0], env.Q[1], env.Q[2], env.Q[3], env.Q[4]]
q = [env.Q[0], env.Q[1], env.Q[2], env.Q[3], env.Q[4]] # More then used

# We apply an X gate on the 0th qubit firstly.
# Also, you can comment it as you like.
X(q[0])

# Then we apply a Hadamard gate on the 0th qubit,
# where we comment the gate in order to hint the user you to try yourself.
# H(q[0])

# X(q[0])
H(q[0])
# We need a CX gate to generate an entangle quantum state
CX(q[0], q[1])

MeasureZ([q[0], q[1], q[2]], range(3))
# Measure with the computational basis
MeasureZ([q[0], q[1], q[2]], range(3)) # Interval and disorder

taskResult = env.commit(1000, fetchMeasure=True)
# Commit the request with 1024 shots to the cloud
taskResult = env.commit(1024, fetchMeasure=True)

pprint(taskResult)
17 changes: 12 additions & 5 deletions Example/Level_1/Hybrid_Cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,31 @@
from QCompute import *

# Your token:
Define.hubToken = ''
# Define.hubToken = ''

# Create environment
env = QuantumEnvironment()
# Baidu Cloud Quantum Simulator-Sim2
env.backend(BackendName.CloudBaiduSim2)
# Choose backend Baidu Cloud Quantum Simulator-Sim2
env.backend(BackendName.CloudBaiduSim2Water)

# We set the number of qubits in our quantum register as
TotalNumQReg = 8

# Initialize an empty quantum register firstly
q = []
# Then generate some qubits and append them into the register above
for index in range(TotalNumQReg):
q.append(env.Q[index])

# We apply a Hadamard gate on each qubit in the register above,
# and also other gates as you like such as a X gate.
for index in range(TotalNumQReg):
H(q[index])
# X(q[index])

# Measure with the computational basis
MeasureZ(q, range(TotalNumQReg))

# Commit the quest with 1000 shots to the cloud
taskResult = env.commit(1000, fetchMeasure=True)
pprint(taskResult)

pprint(taskResult)
13 changes: 10 additions & 3 deletions Example/Level_1/Hybrid_Local.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,29 @@
sys.path.append('../..') # "from QCompute import *" requires this
from QCompute import *

# Create environment
env = QuantumEnvironment()
# Baidu Local Quantum Simulator-Sim2
# Choose backend Baidu Local Quantum Simulator-Sim2
env.backend(BackendName.LocalBaiduSim2)

# We set the number of qubits in our quantum register as
TotalNumQReg = 8

# Initialize an empty quantum register firstly
q = []
# Then generate some qubits and append them into the register above
for index in range(TotalNumQReg):
q.append(env.Q[index])

# We apply a Hadamard gate on each qubit in the register above,
# and also other gates as you like such as a X gate.
for index in range(TotalNumQReg):
H(q[index])
# X(q[index])

# Measure with the computational basis
MeasureZ(q, range(TotalNumQReg))

# Commit the quest with 1000 shots to the cloud
taskResult = env.commit(1000, fetchMeasure=True)
pprint(taskResult)

pprint(taskResult)
14 changes: 7 additions & 7 deletions Example/Level_1/Interact_Cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@
Adjust parameter of rotation gate to eliminate '0' state.
"""

from pprint import pprint
import sys

sys.path.append('../..') # "from QCompute import *" requires this
from QCompute import *

# Your token:
Define.hubToken = ''
# Define.hubToken = ''

uValue = 1 # flag of intereactions
for _ in range(15):

print("uValue is :", uValue)

env = QuantumEnvironment() # environment set-up

env.backend(BackendName.CloudBaiduSim2) # set a backend to execute the quantum program
# Create environment
env = QuantumEnvironment()
# Choose backend Baidu Cloud Quantum Simulator-Sim2
env.backend(BackendName.CloudBaiduSim2Water)

q = [env.Q[0]] # define quantum registers in need

Expand All @@ -50,8 +50,8 @@

# interaction: change parameters of unitary in next experiment according to current result
CountsDict = taskResult['counts']
if CountsDict['0'] > 5:
if CountsDict.get('0', 0) > 5:
uValue = uValue * 2
else:
print("When the parameter is %d, 0 is eliminated." % uValue)
break
break
10 changes: 5 additions & 5 deletions Example/Level_1/Interact_Local.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
Adjust parameter of rotation gate to eliminate '0' state.
"""

from pprint import pprint
import sys

sys.path.append('../..') # "from QCompute import *" requires this
Expand All @@ -31,9 +30,10 @@

print("uValue is :", uValue)

env = QuantumEnvironment() # environment set-up

env.backend(BackendName.LocalBaiduSim2) # set a backend to execute the quantum program
# Create environment
env = QuantumEnvironment()
# Choose backend Baidu Local Quantum Simulator-Sim2
env.backend(BackendName.LocalBaiduSim2)

q = [env.Q[0]] # define quantum registers in need

Expand All @@ -47,7 +47,7 @@

# interaction: change parameters of unitary in next experiment according to current result
CountsDict = taskResult['counts']
if CountsDict['0'] > 5:
if CountsDict.get('0', 0) > 5:
uValue = uValue * 2
else:
print("When the parameter is %d, 0 is eliminated." % uValue)
Expand Down
Loading

0 comments on commit bfde39e

Please sign in to comment.