qiskit-community / qiskit-research Goto Github PK
View Code? Open in Web Editor NEWResearch using Qiskit.
Home Page: https://qiskit-community.github.io/qiskit-research/
License: Apache License 2.0
Research using Qiskit.
Home Page: https://qiskit-community.github.io/qiskit-research/
License: Apache License 2.0
in utils/gates.py. Perhaps it can inherit from CalibrationBuilder.
The documentation link in the readme does not work and gives a 404 error.
Documentation is located here.
Issue was brought up here originally https://qiskit.slack.com/archives/C7SJ0PJ5A/p1686905326778079
I am running the code as is in VS Code, and I get the following error when I get to the line:
result = protein_folding_problem.interpret(raw_result=raw_result)
The full error is,
TypeError Traceback (most recent call last)
Cell In[11], line 1
----> 1 result = protein_folding_problem.interpret(raw_result=raw_result)
2 print(
3 "The bitstring representing the shape of the protein during optimization is: ",
4 result.turn_sequence,
5 )
6 print("The expanded expression is:", result.get_result_binary_vector())
File c:\Users\8J6010897\AppData\Local\anaconda3\envs\py39\lib\site-packages\qiskit_research\protein_folding\protein_folding_problem.py:113, in ProteinFoldingProblem.interpret(self, raw_result)
110 from .protein_folding_result import ProteinFoldingResult
112 best_turn_sequence = max(raw_result.eigenstate, key=raw_result.eigenstate.get)
--> 113 return ProteinFoldingResult(
114 unused_qubits=self.unused_qubits,
115 peptide=self.peptide,
116 turn_sequence=best_turn_sequence,
117 )
File c:\Users\8J6010897\AppData\Local\anaconda3\envs\py39\lib\site-packages\qiskit_research\protein_folding\protein_folding_result.py:67, in ProteinFoldingResult.init(self, peptide, unused_qubits, turn_sequence)
62 self._main_chain_length = len(
63 self._peptide.get_main_chain.main_chain_residue_sequence
64 )
65 self._side_chain_hot_vector = self._peptide.get_side_chain_hot_vector()
---> 67 self._protein_shape_decoder = ProteinShapeDecoder(
...
107 main_turns_bitstring = (
108 main_turns_bitstring[:-5] + "1" + main_turns_bitstring[-5:]
109 )
TypeError: 'int' object is not subscriptable
Not sure how to fix it, thank you very much!
Since Qiskit/qiskit#7949 changed the definition of the gate, the decomposition breaks with the development version of Qiskit.
Plan:
When Qiskit 0.21 is released, update the decomposition, and set the minimum version of Qiskit to at least 0.21. Until then, the CI workflow that tests against the development version of Qiskit Terra will be broken.
When trying to get the error for qubits used by the CX gate the code below assumes that the layout is virtual and it will raise errors with certain layouts for physical qubits.
The correct version would be:
fid *= (1-props.gate_error('cx', [layout[q0], layout[q1]]))
where layout
is one of the matching layouts for the circuit. this is how it is handled in the original cost function code in mapomatic: https://github.com/Qiskit-Partners/mapomatic/blob/965ad30f20482fc14984cde371d5e1ab6b8335db/mapomatic/layouts.py#L210
PeriodicDynamicalDecoupling should be ported to Qiskit Terra by directly modifying PadDynamicalDecoupling
I am trying to import Peptide from qiskit_research by using this code:
from qiskit_research.protein_folding.peptide.pepetide import *
But I am getting this error:
No module named qiskit_research.protein_folding
I will appreciate if someone can explain why I am getting this error
qiskit_research/utils/gate_decompositions.py:58: error: Name "cr_sched" is used before definition [used-before-def]
are you planning on a release of qiskit-research so users can just pip install
?
I keep advertising qiskit-research , this would be great for increased ease of use
Blocked by #114
After qiskit-community/qiskit-nature#828 is fixed.
When installing qiskit-research, I get the following message:
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. qiskit-research 0.1.dev399+g88b5dec requires qiskit-terra==0.21, but you have qiskit-terra 0.21.2 which is incompatible.
Is the dependency such that qiskit-research will not work with terra 0.21.2? If I try to downgrade terra, pip says that qiskit 0.37.2 requires terra 0.21.2.
I have been trying to import qiskit_research inside a runtime job, without success. Is it planned to upload the code to the runtime server or should i copy-paste all the code inside my script?
The mapomatic commit that broke the code was introduced between mapomatic versions 0.9 and 0.10: qiskit-community/mapomatic@208989e
This prevents us from upgrading mapomatic past 0.9, which in turn blocks us from upgrading to Qiskit 1.0, because mapomatic 0.9 depends on qiskit-terra
.
Example test failure (see CI logs of #107 for full test failures):
_______________________________________________________________________________________ TestScaledCostFuncs.test_cost_func_dd _______________________________________________________________________________________
self = <test.utils.test_cost_funcs.TestScaledCostFuncs testMethod=test_cost_func_dd>
def test_cost_func_dd(self):
"""Test cost function for RZX"""
backend = FakeWashington()
qc = QuantumCircuit(5)
qc.h(0)
qc.cx(0, 1)
qc.cx(1, 2)
qc2 = qc.copy()
qc2.cx(2, 3)
qc2.cx(3, 4)
layout = [0, 1, 2, 3, 4]
qc_t = transpile(qc, backend, initial_layout=layout)
qc_dd = add_dynamical_decoupling(qc_t, backend, "XY4pm")
> best_layout = evaluate_layouts(
qc_dd,
layout,
backend,
cost_function=cost_func_scaled_cr,
)[0]
E IndexError: list index out of range
test/utils/test_cost_funcs.py:151: IndexError
Related: Qiskit/qiskit-ibm-runtime#571
from qiskit import QuantumCircuit, pulse
from qiskit_ibm_runtime import QiskitRuntimeService, Sampler
from qiskit.transpiler import PassManager
from qiskit.providers.fake_provider import FakeBelemV2
from qiskit_research.utils.pulse_scaling import SECRCalibrationBuilder
from qiskit_research.utils.gates import SECRGate
service = QiskitRuntimeService()
backend = service.backend("ibm_perth")
sampler = Sampler(session=backend)
inst_sched_map = backend.defaults().instruction_schedule_map
channel_map = backend.configuration().qubit_channel_mapping
pass_manager = PassManager([SECRCalibrationBuilder(inst_sched_map, channel_map)])
circuit = QuantumCircuit(2)
circuit.append(SECRGate(0.1), [0, 1])
circuit.measure_all()
transpiled = pass_manager.run(circuit)
job = sampler.run([transpiled], shots=1000)
---------------------------------------------------------------------------
QpyError Traceback (most recent call last)
<ipython-input-1-205f6bf86f68> in <module>
18 circuit.measure_all()
19 transpiled = pass_manager.run(circuit)
---> 20 job = sampler.run([transpiled], shots=1000)
~/projects/qiskit-ibm-runtime/qiskit_ibm_runtime/sampler.py in run(self, circuits, parameter_values, parameters, **kwargs)
194 parameters = [parameters]
195
--> 196 return super().run(
197 circuits=circuits,
198 parameter_values=parameter_values,
~/projects/qiskit-ibm-runtime/qiskit_ibm_runtime/qiskit/primitives/base_sampler.py in run(self, circuits, parameter_values, parameters, **run_options)
368 )
369
--> 370 return self._run(circuits, parameter_values, parameter_views, **run_options)
371
372 @abstractmethod
~/projects/qiskit-ibm-runtime/qiskit_ibm_runtime/sampler.py in _run(self, circuits, parameter_values, parameters, **kwargs)
235 inputs.update(Options._get_program_inputs(combined))
236
--> 237 return self._session.run(
238 program_id=self._PROGRAM_ID,
239 inputs=inputs,
~/projects/qiskit-ibm-runtime/qiskit_ibm_runtime/session.py in _wrapper(self, *args, **kwargs)
32 if not self._active:
33 raise RuntimeError("The session is closed.")
---> 34 return func(self, *args, **kwargs)
35
36 return _wrapper
~/projects/qiskit-ibm-runtime/qiskit_ibm_runtime/session.py in run(self, program_id, inputs, options, result_decoder)
137 options["backend"] = self._backend
138
--> 139 job = self._service.run(
140 program_id=program_id,
141 options=options,
~/projects/qiskit-ibm-runtime/qiskit_ibm_runtime/qiskit_runtime_service.py in run(self, program_id, inputs, options, callback, result_decoder, instance, session_id, job_tags, max_execution_time, start_session)
932 result_decoder = result_decoder or ResultDecoder
933 try:
--> 934 response = self._api_client.program_run(
935 program_id=program_id,
936 backend_name=options["backend"],
~/projects/qiskit-ibm-runtime/qiskit_ibm_runtime/api/clients/runtime.py in program_run(self, program_id, backend_name, params, image, hgp, log_level, session_id, job_tags, max_execution_time, start_session)
148 hub, group, project = from_instance_format(hgp)
149 hgp_dict = {"hub": hub, "group": group, "project": project}
--> 150 return self._api.program_run(
151 program_id=program_id,
152 backend_name=backend_name,
~/projects/qiskit-ibm-runtime/qiskit_ibm_runtime/api/rest/runtime.py in program_run(self, program_id, backend_name, params, image, hub, group, project, log_level, session_id, job_tags, max_execution_time, start_session)
181 payload["group"] = group
182 payload["project"] = project
--> 183 data = json.dumps(payload, cls=RuntimeEncoder)
184 return self.session.post(url, data=data).json()
185
/usr/lib/python3.10/json/__init__.py in dumps(obj, skipkeys, ensure_ascii, check_circular, allow_nan, cls, indent, separators, default, sort_keys, **kw)
236 check_circular=check_circular, allow_nan=allow_nan, indent=indent,
237 separators=separators, default=default, sort_keys=sort_keys,
--> 238 **kw).encode(obj)
239
240
/usr/lib/python3.10/json/encoder.py in encode(self, o)
197 # exceptions aren't as detailed. The list call should be roughly
198 # equivalent to the PySequence_Fast that ''.join() would do.
--> 199 chunks = self.iterencode(o, _one_shot=True)
200 if not isinstance(chunks, (list, tuple)):
201 chunks = list(chunks)
/usr/lib/python3.10/json/encoder.py in iterencode(self, o, _one_shot)
255 self.key_separator, self.item_separator, self.sort_keys,
256 self.skipkeys, _one_shot)
--> 257 return _iterencode(o, 0)
258
259 def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,
~/projects/qiskit-ibm-runtime/qiskit_ibm_runtime/utils/json.py in default(self, obj)
216 if isinstance(obj, BlueprintCircuit):
217 obj = obj.decompose()
--> 218 value = _serialize_and_encode(
219 data=obj,
220 serializer=lambda buff, data: dump(data, buff), # type: ignore[no-untyped-call]
~/projects/qiskit-ibm-runtime/qiskit_ibm_runtime/utils/json.py in _serialize_and_encode(data, serializer, compress, **kwargs)
95 """
96 with io.BytesIO() as buff:
---> 97 serializer(buff, data, **kwargs)
98 buff.seek(0)
99 serialized_data = buff.read()
~/projects/qiskit-ibm-runtime/qiskit_ibm_runtime/utils/json.py in <lambda>(buff, data)
218 value = _serialize_and_encode(
219 data=obj,
--> 220 serializer=lambda buff, data: dump(data, buff), # type: ignore[no-untyped-call]
221 )
222 return {"__type__": "QuantumCircuit", "__value__": value}
~/projects/qiskit-terra/qiskit/utils/deprecation.py in wrapper(*args, **kwargs)
26 if kwargs:
27 _rename_kwargs(func.__name__, kwargs, kwarg_map, category)
---> 28 return func(*args, **kwargs)
29
30 return wrapper
~/projects/qiskit-ibm-runtime/qiskit_ibm_runtime/qpy/interface.py in dump(programs, file_obj, metadata_serializer)
167
168 for program in programs:
--> 169 writer( # type: ignore[no-untyped-call]
170 file_obj, program, metadata_serializer=metadata_serializer
171 )
~/projects/qiskit-ibm-runtime/qiskit_ibm_runtime/qpy/binary_io/circuits.py in write_circuit(file_obj, circuit, metadata_serializer)
847
848 # Write calibrations
--> 849 _write_calibrations(file_obj, circuit.calibrations, metadata_serializer)
850
851
~/projects/qiskit-ibm-runtime/qiskit_ibm_runtime/qpy/binary_io/circuits.py in _write_calibrations(file_obj, calibrations, metadata_serializer)
725 len(qubits),
726 len(params),
--> 727 type_keys.Program.assign(schedule),
728 )
729 file_obj.write(defheader)
~/projects/qiskit-ibm-runtime/qiskit_ibm_runtime/qpy/type_keys.py in assign(cls, obj)
376 return cls.SCHEDULE_BLOCK
377
--> 378 raise exceptions.QpyError(
379 f"Object type '{type(obj)}' is not supported in {cls.__name__} namespace."
380 )
QpyError: "Object type '<class 'qiskit.pulse.schedule.Schedule'>' is not supported in Program namespace."
Hello! I have been trying to a modified version of the code here https://qiskit-research.github.io/qiskit-research/protein_folding/protein_folding.html
I was able to run it successfully with no issues until a month ago. But now I keep receiving kernel dead error both in VS Code and Jupyter notebook. The kernel dies when I try to run the following line:
raw_result = vqe.compute_minimum_eigenvalue(qubit_op)
Here I attach the juypter log related to the error:
error 11:15:44.140: Error in waiting for cell to complete [Error: Canceled future for execute_request message before replies were done
at t.KernelShellFutureHandler.dispose (c:\Users\8J6010897.vscode\extensions\ms-toolsai.jupyter-2023.3.1201040234\out\extension.node.js:2:32419)
at c:\Users\8J6010897.vscode\extensions\ms-toolsai.jupyter-2023.3.1201040234\out\extension.node.js:2:51471
at Map.forEach ()
at y._clearKernelState (c:\Users\8J6010897.vscode\extensions\ms-toolsai.jupyter-2023.3.1201040234\out\extension.node.js:2:51456)
at y.dispose (c:\Users\8J6010897.vscode\extensions\ms-toolsai.jupyter-2023.3.1201040234\out\extension.node.js:2:44938)
at c:\Users\8J6010897.vscode\extensions\ms-toolsai.jupyter-2023.3.1201040234\out\extension.node.js:17:96826
at ee (c:\Users\8J6010897.vscode\extensions\ms-toolsai.jupyter-2023.3.1201040234\out\extension.node.js:2:1589492)
at jh.dispose (c:\Users\8J6010897.vscode\extensions\ms-toolsai.jupyter-2023.3.1201040234\out\extension.node.js:17:96802)
at Lh.dispose (c:\Users\8J6010897.vscode\extensions\ms-toolsai.jupyter-2023.3.1201040234\out\extension.node.js:17:104079)
at process.processTicksAndRejections (node:internal/process/task_queues:96:5)]
warn 11:15:44.140: Cell completed with errors {
message: 'Canceled future for execute_request message before replies were done'
I tried uninstalling/reinstalling jupyter extensions, VS Code, python and anaconda. Nothing seems to fix it. I also recloned the qiskit-research 0.0.1 and installed it. Here are the other details related to my device:
OS: Windows 11
Python: 3.10.10 (I also tried it on 3.9.16)
qiskit 0.42.1
qiskit-aer 0.12.0
qiskit-ibmq-provider 0.20.2
qiskit-terra 0.23.3
Thank you!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.