Giter Site home page Giter Site logo

qiskit-research's People

Contributors

ajrazander avatar arnaucasau avatar eric-arellano avatar garrison avatar georgezhou20 avatar kevinsung avatar nbronn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

qiskit-research's Issues

Runtime

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?

Cost function using virtual qubits

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.

https://github.com/qiskit-research/qiskit-research/blob/f4c1fe929d1e865a7c01fc85f85207a3a966aaff/qiskit_research/utils/cost_funcs.py#L54

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

SECRCalibrationBuilder does not work with Runtime

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."

qiskit-terra 0.21.2 incompatible installation error

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.

Update XXPlusYYGate decomposition for latest Qiskit

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.

release?

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

Fix mypy

qiskit_research/utils/gate_decompositions.py:58: error: Name "cr_sched" is used before definition  [used-before-def]

'int' object is not subscriptable error when running result

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!

Kernel dead error

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!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.