Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Support shots as np.int64 #744

Merged
merged 7 commits into from
Oct 16, 2023
Merged

Support shots as np.int64 #744

merged 7 commits into from
Oct 16, 2023

Conversation

merav-aharoni
Copy link
Collaborator

Summary

Details and comments

Fixes #743

@merav-aharoni
Copy link
Collaborator Author

This fix could take two possible approaches - the one I took and another that would involve parsing "shots": {"type": "int", "value": 1000} on the server side. Let me know if you agree with my approach.

@coveralls
Copy link

coveralls commented Oct 3, 2023

Pull Request Test Coverage Report for Build 6536842070

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.02%) to 51.28%

Totals Coverage Status
Change from base Build 6460343546: 0.02%
Covered Lines: 3366
Relevant Lines: 6564

💛 - Coveralls

@merav-aharoni
Copy link
Collaborator Author

Here is a further explanation:
In this bug, the RuntimeEncoder outputs "shots": {"__type__": "int", "__value__": 1000} for np.int64(1000), whereas for 1000, it simply outputs "shots": 1000, which is what is output after my fix.
In the original implementation, somewhere in the server, there is a check that shots is an int, and therefore it fails when it detects a dict. I searched in ntc, ntc-ibm-programs and qiskit-ibm-primitives but couldn't find where this error message comes from.
Curiously, there is another parameter meas_level which is an int. When I tried to define this as np.int64, the output from the encoder was similar to above, but this did not give an error on the server side.
So the bottom line is, do we think there is value in preserving the original type of shots, and then we need to update the check on the server side.

@merav-aharoni merav-aharoni marked this pull request as ready for review October 9, 2023 16:10
@drew-distefano
Copy link
Collaborator

@kt474 please re-review, we plan to close soon

@kt474 kt474 added the Changelog: Bugfix Include in the Fixed section of the changelog label Oct 16, 2023
@kt474 kt474 merged commit 98dc9f4 into Qiskit:main Oct 16, 2023
14 checks passed
kt474 added a commit that referenced this pull request Oct 25, 2023
* Update main 0.7.1 (#719)

* Fix typing in `DAGCircuit.apply_operation_back` (#721)

It is not valid typing (per the documentation) to pass `None` to
`DAGCircuit.apply_operation_back` in either the `qargs` or `cargs`
field, though this has been silently accepted previously to support
mistaken code in the Terra schedulers, which this repository has
inherited.

* Update serialization for non-basic types (#715)

* Update json.py

* Update json.py

* Added test for metadata serialization

* added release notes

* Moved test here from qiskit-ibm-runtime (#722)

* Moved here from qiskit-ibm-runtime

* Fixed imports

* Removed code related to Schedule (#724)

* Removed code related to Schedule, qubit_lo_freq, mea_lo_freq, schedule_los

* black and lint

* Returned lines in documentation that were removed by mistake

* Fixed documentation

* Put back range parameters

* Removed auth parameter and migrate method (#727)

* Removed auth parameter and migrate method

* Updated documentation

* black

* Remove `qiskit-ibmq-provider` from `requirements-dev.txt` (#729)

* Remove qiskit-ibmq-provider from requirements-dev.txt

* Remove IBMQ

* Breaking change in Qiskit 0.45 - Gate.duration setting (#732)

* breaking change in Qiskit 0.45

* black

* Bit.index is deprecated since Apr 2021 (#733)

Co-authored-by: Kevin Tian <kevin.tian@ibm.com>

* Update hms_to_seconds to support times greater than 1 day (#731)

* Update hms_to_seconds

* add reno

* Add option to no pad idle qubits in scheduling passes (#725)

* Add option to no pad idle qubits in scheduling passes

This commit adds a new flag to the scheduling padding passes,
schedule_idle_qubits, which is used to opt-in to scheduling idle qubits.
By default these passes will only schedule qubits which are active. This
is a change in behavior from before where the previous default is all
qubits were scheduled. This was undesireable because it's adding
uneceesary instructions to the job payload which will need to be
processed which are effectively a no-op. The only real use case for
adding delays to idle wires is visualization, so it's left as an option
to re-enable the previous default.

Fixes #723

Co-authored-by: Thomas Alexander <thomas.a.alexander@ibm.com>

* Add missing inline type hint

* Don't put barriers on idle qubits either

* Fix formatting

* Add schedule_idle_qubits to parent constructor

* Reneable padding in control flow

* Omit idle qubits in control flow

* Run black

---------

Co-authored-by: Thomas Alexander <thomas.a.alexander@ibm.com>
Co-authored-by: Diego Ristè <10402430+dieris@users.noreply.github.com>
Co-authored-by: Kevin Tian <kevin.tian@ibm.com>

* Update test_jobs_filter (#738)

* readjust test_convert_id_to_delay (#739)

* readjust test_convert_id_to_delay

* disable not-context-manager

* duplicated entry

* Exceptions should inherit from Terra where suitable (#741)

* Changed inheritance of exception classes

* Changed error type

* Support method job.properties() (#742)

* Implemented job.properties() method

* release note

* Updated documentation

* Improved the tests

---------

Co-authored-by: Kevin Tian <kevin.tian@ibm.com>

* Use job creation date when returning backend properties in `job.properties()` (#746)

* use job creation date in properties

* add reno

* remove datetime param

* update test_job_backend_properties (#747)

* Support shots as np.int64 (#744)

* Fixed bug where shots defined as np.number

* Added test

* black

* add reno

---------

Co-authored-by: Kevin Tian <kevin.tian@ibm.com>

* use qpy.load from terra (#751)

* remove print statement in test (#752)

* Prepare release 0.7.1 (#753)

* Update main branch 0.7.2 (#754)

* migrate pypi trusted publisher (#750)

---------

Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
Co-authored-by: ItamarGoldman <51112651+ItamarGoldman@users.noreply.github.com>
Co-authored-by: merav-aharoni <merav@il.ibm.com>
Co-authored-by: Luciano Bello <bel@zurich.ibm.com>
Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
Co-authored-by: Thomas Alexander <thomas.a.alexander@ibm.com>
Co-authored-by: Diego Ristè <10402430+dieris@users.noreply.github.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Changelog: Bugfix Include in the Fixed section of the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Jobs fail if shots value comes from NumPy array
4 participants