tooffoli门的定义函数:
def toffoli(qc,i1,i2,i3):
qc.h(i3)
qc.cx(i2,i3)
qc.tdg(i3)
qc.cx(i1,i3)
qc.t(i3)
qc.cx(i2,i3)
qc.tdg(i3)
qc.cx(i1,i3)
qc.t(i3)
qc.tdg(i2)
qc.cx(i1,i2)
qc.h(i3)
qc.tdg(i2)
qc.cx(i1,i2)
qc.t(i1)
qc.s(i2)
定义寄存器:
qr=QuantumRegister(5)
cr=ClassicalRegister(5)
qc=QuantumCircuit(qr,cr)
运行代码:
qc.x(qr[0])
qc.x(qr[1])
toffoli(qc,qr[0],qr[1],qr[2])
qc.measure(qr[0],cr[0])
qc.measure(qr[1],cr[1])
qc.measure(qr[2],cr[2])
circuits=[qc]
job=execute(circuits,backend="local_qasm_simulator")
result=job.result()
错误:
BrokenProcessPool Traceback (most recent call last)
<ipython-input-10-47786bf8d782> in <module>()
1 circuits=[qc]
----> 2 job=execute(circuits,backend)
3 job.status
4 result=job.result()
~\Anaconda3\envs\QISKitenv\lib\site-packages\qiskit\wrapper\_wrapper.py in execute(circuits, backend, config, basis_gates, coupling_map,initial_layout, shots, max_credits, seed, qobj_id, hpc, skip_translation)
202 q_job = QuantumJob(qobj, backend=backend, preformatted=True,
resources={
203 'max_credits': qobj['config']['max_credits']})
--> 204 return backend.run(q_job)
~\Anaconda3\envs\QISKitenv\lib\site-
packages\qiskit\backends\local\qasm_simulator_cpp.py in run(self, q_job)
83 def run(self, q_job):
84 """Run a QuantumJob on the the backend."""
---> 85 return LocalJob(self._run_job, q_job)
86
87 def _run_job(self, q_job):
~\Anaconda3\envs\QISKitenv\lib\site-packages\qiskit\backends\local\localjob.py in __init__(self, fn, q_job)
44 self._q_job = q_job
45 self._backend_name = q_job.backend.name
---> 46 self._future = self._executor.submit(fn, q_job)
47
48 def result(self, timeout=None):
~\Anaconda3\envs\QISKitenv\lib\concurrent\futures\process.py in submit(self,
fn, *args, **kwargs)
450 with self._shutdown_lock:
451 if self._broken:
--> 452 raise BrokenProcessPool('A child process terminated
'
453 'abruptly, the process pool is not usable
anymore')
454 if self._shutdown_thread:
BrokenProcessPool: A child process terminated abruptly, the process pool is
not usable anymore
我早些时候执行了这段代码,它工作了。现在无论我在 Jupyter 笔记本中运行哪个代码,我都会在该行中遇到故障进程池错误
job=execute(circuits,backend)
我无法理解如何消除此错误。我在 Jupyter Notebook 中运行的任何代码都会在这一行中遇到相同的错误。我将此代码发送给了一位朋友,并在他的 jupyter notebook 中执行。请帮忙。