-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#3312 | Large Pulse backend mock #3797
#3312 | Large Pulse backend mock #3797
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's exciting to see this getting started! Thank you @IceKhan13 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is coming along nicely @IceKhan13. I think you are on the right track with the FakeBackendBuilder
. What I would like to see is an arbitrary FakeBackendBuilder
that you can pass a number of qubits too, a grid size and potentially just examples for single-qubit properties and frequencies. We could then provide a FakeOpenPulse100Q
or FakeOpenPulse1000Q
which upon calling would generate the fake backend. This would remove the need for storing configuration and properties json.
For example
def fake_backend_generator(n_qubits, name, coupling_map=None, version='1.1', pulse=True, basis_gates=['id', 'u1', 'u2', 'u3', 'cx'], 1q_error_rate=0.001, 2q_error_rate=0.01, T1=100, T2=200) -> FakeBackend:
...
and then we would have
FakeOpenPulse100Q = fake_backend_generator(100, ...)
FakeOpenPulse1000Q = fake_backend_generator(1000, ...)
Note the backend generation shouldn't actually happen until the mock backend is instantiated, ie., calling FakeOpenPulse100Q()
should cause the backend to be generated. These generated backends could then be tested by the tests described here #3892.
…o utils package; props generation; TODO: build conf, tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is coming along nicely, a couple of comments here and then we should figure out how to test this.
…ters documentation, style fixes
Team, I need some input from you 😄 It goes as usual: desired_vector = [1 / math.sqrt(2), 0, 0, 1 / math.sqrt(2)]
qr = QuantumRegister(2, "qr")
qc = QuantumCircuit(qr)
qc.initialize(desired_vector, [qr[0], qr[1]]) then I build a backend and try to transpile cirquit, create schedule and assemble qobj: FakeOpenPulse10Q = FakeBackendBuilder("Tashkent", n_qubits=10).build()
backend = FakeOpenPulse10Q()
experiments = transpile(qc, backend=backend)
experiments = schedule(circuits=experiments, backend=backend)
qobj = assemble(experiments, backend=backend) and everything works but to finish logical sequence for
Same thing happens when I try to use
This can be solved (I assume) by using Anyhow both of this errors occurs in I think, I can create other Any suggestions how to overcome this?) P.S |
It's totally ok to ping me 😄. I was tried to run the sample code import math
from qiskit import QuantumRegister, QuantumCircuit, transpile, schedule, assemble
from qiskit.test.mock.utils.fake_backend_builder import FakeBackendBuilder
desired_vector = [1 / math.sqrt(2), 0, 0, 1 / math.sqrt(2)]
qr = QuantumRegister(2, "qr")
qc = QuantumCircuit(qr)
qc.initialize(desired_vector, [qr[0], qr[1]])
FakeOpenPulse10Q = FakeBackendBuilder("Tashkent", n_qubits=10).build()
backend = FakeOpenPulse10Q()
experiments = transpile(qc, backend=backend)
experiments = schedule(circuits=experiments, backend=backend)
qobj = assemble(experiments, backend=backend) but am getting the error
If I look at the coupling_map, it includes too many qubits. >>> backend.configuration().coupling_map
[[0, 4], [1, 2], [2, 3], [2, 6], [3, 4], [4, 8], [5, 6], [6, 7], [6, 10], [7, 8], [8, 12], [9, 10]] |
The backend is missing a parameter |
I can, however, recreate your error with import math
from qiskit import QuantumRegister, QuantumCircuit, transpile, schedule, assemble
from qiskit.test.mock.utils.fake_backend_builder import FakeBackendBuilder
from qiskit.test.mock import FakeOpenPulse2Q
desired_vector = [1 / math.sqrt(2), 0, 0, 1 / math.sqrt(2)]
qr = QuantumRegister(2, "qr")
qc = QuantumCircuit(qr)
qc.initialize(desired_vector, [qr[0], qr[1]])
FakeOpenPulse10Q = FakeBackendBuilder("Tashkent", n_qubits=4, coupling_map=[[0, 1], [1,2], [2,3]]).build()
#backend = FakeOpenPulse2Q()
backend = FakeOpenPulse10Q()
experiments = transpile(qc, backend=backend)
experiments = schedule(circuits=experiments, backend=backend)
qobj = assemble(experiments, backend=backend, rep_time=100)
job = backend.run(qobj)
result = job.result() Please try again after updating to master of qiskit which has changed this method. |
Did merging in master help? |
Fake job changed. So, no it's using Aer simulator and reads hamiltonian. Now I need to generate Hamiltonian correctly and continue with tests. But all of your comments above correct and it helped :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for sticking with this and pushing it through to completion
def setUp(self) -> None: | ||
self.backend = ConfigurableBackend("Tashkent", n_qubits=4) | ||
|
||
def test_transpile_schedule_and_assemble(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is partial overlap here with: https://github.com/Qiskit/qiskit-terra/blob/master/test/python/providers/test_fake_backends.py#L51 but this is different enough that it's probably fine. It might be a good follow up to expand this or the other to cover both use cases and deduplicate things a bit.
@IceKhan13 Can the name be changed to |
In Qiskit#3797 tests were incorrectly outside of test/python. This meant that python unittest discovery did not find or execute these tests because we set the discovery path to test/python. This commit corrects the oversight so that we are running these tests. However, one of the unittests there is dependent on aer being installed so a skip condition is set on that test so we only attempt to run it if aer installed. But, that same test is also triggering an aer bug see Qiskit/qiskit-aer#741 so an additional unconditional skip is added until that gets fixed in aer.
This commit fixes an issue with the fake configurable backend which was introduced in Qiskit#3797. Due to an error in how the test files were added this was not being exersiced by local test runs or CI (this has been corrected in Qiskit#4424). However, because no tests were being run for this module it was merged with a broken type for scale. The UchannelLO object expects a complex input not a list of complex components. This commit corrects this oversight so that the backends created with this can be used for pulse simulations and other use cases where the scale parameter is used. At the same time this renames the class to be a bit more descriptive to avoid confusion.
Hello, we had a similar project to this one titled: open pulse mock backend for spin based qubits from qiskit camp Africa 2019, the mock qubits where associated with the 13-C nuclear spins coupled to NV centres in a diamond. Based on the computational ability of carbon atoms, it was my believe that these carbon atoms could be used as fake backends that will participate as reactive groups in drug design to combat the covid19 pandemic. If we treat the electron spin as a quantum bus, we can adjust the states that correspond to the syndrome measurements and thus the 13-C nuclear spins provide a platform to design the proper chemistry that will help mitigate the syndrome. There is a lot of research on the development of viral nanoparticles as a template for organising materials at the nano scales and I think that it is time to consolidate these efforts. |
I think it is fine to still have an example backend for an NV center system. Would it be possible to use @IceKhan13's work for this and choose the right parameters? Maybe some slight modifications would be required? |
Yes, with 100 qubits we can realise a 100*100 tabular qubit ordering, how do I become part of this discussion so that I may be able to present my attempts? |
If you open up a draft PR with your attempts we can comment directly on it 😄 |
In #3797 tests were incorrectly outside of test/python. This meant that python unittest discovery did not find or execute these tests because we set the discovery path to test/python. This commit corrects the oversight so that we are running these tests. However, one of the unittests there is dependent on aer being installed so a skip condition is set on that test so we only attempt to run it if aer installed. But, that same test is also triggering an aer bug see Qiskit/qiskit-aer#741 so an additional unconditional skip is added until that gets fixed in aer. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* Fix U Channel LO property in fake configurable backend This commit fixes an issue with the fake configurable backend which was introduced in #3797. Due to an error in how the test files were added this was not being exersiced by local test runs or CI (this has been corrected in #4424). However, because no tests were being run for this module it was merged with a broken type for scale. The UchannelLO object expects a complex input not a list of complex components. This commit corrects this oversight so that the backends created with this can be used for pulse simulations and other use cases where the scale parameter is used. At the same time this renames the class to be a bit more descriptive to avoid confusion. * Fix broken tests * Fix import in pulse builder tests
* LargePulseBackendMock: skeleton of backend * LargePulseBackendMock: fake backend builder works; todo: fix values generation * FakePulseBackend: fake backend builder generate Almaden like cmap * FakePulseBackend: defaults initial implementation * FakePulseBackend: fake backend generation function; move generation to utils package; props generation; TODO: build conf, tests * FakePulseBackend: move generation function into builder class, parameters documentation, style fixes * FakePulseBackend: simple testing * LargePulseBackendMock: build method return FakeBackend, simple tests * LargePulseBackendMock: hamiltonian generation * LargePulseBackendMock: test * LargePulseBackendMock: backend builder configuration + tests * LargePulseBackendMock: list + fix test; TODO: run test after Aer release * LargePulseBackendMock: list * LargePulseBackendMock: list * LargePulseBackendMock: lint * LargePulseBackendMock: job run test with released aer * LargePulseBackendMock: default cmap * LargePulseBackendMock: linter fixes * LargePulseBackendMock: release note * LargePulseBackendMock: release note fix * LargePulseBackendMock: release note fix * LargePulseBackendMock: docstring example fix * Update qiskit/test/mock/utils/fake_backend_builder.py Co-Authored-By: Lauren Capelluto <[email protected]> * Update qiskit/test/mock/utils/fake_backend_builder.py Co-Authored-By: Lauren Capelluto <[email protected]> * Update releasenotes/notes/large-mock-backend-builder-af0623b43bdcc35e.yaml Co-Authored-By: Matthew Treinish <[email protected]> * LargePulseBackendMock: gate length, gate error, coupling map fixes * LargePulseBackendMock: t1, t2, rerror, frequency as arrays * LargePulseBackendMock: for some reason liner complains about types * LargePulseBackendMock: rename to configurable backend, move build to init, fix tests Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Lauren Capelluto <[email protected]> Co-authored-by: Matthew Treinish <[email protected]>
In Qiskit#3797 tests were incorrectly outside of test/python. This meant that python unittest discovery did not find or execute these tests because we set the discovery path to test/python. This commit corrects the oversight so that we are running these tests. However, one of the unittests there is dependent on aer being installed so a skip condition is set on that test so we only attempt to run it if aer installed. But, that same test is also triggering an aer bug see Qiskit/qiskit-aer#741 so an additional unconditional skip is added until that gets fixed in aer. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Summary
Create a large (100Q) Pulse backend mock and/or create a util method or a script to generate reasonable Pulse-enabled backend
Issue #3312
Details and comments
The pulse module of Qiskit has yet to be benchmarked. The purpose of benchmarking is to provide a deterministic way to assess performance of software over time. There is room for improvement in the performance of pulse operations; building benchmarks will allow us to quantify progress and justify code refactors.