Narrow QPY 18 SPARSE_OBSERVABLE bit terms from uint16_t to uint8_t - #16800
Conversation
… bytes to 1 byte Signed-off-by: mohamedmahameed <mohamed.mahameed@ibm.com>
Signed-off-by: mohamedmahameed <mohamed.mahameed@ibm.com>
|
Thank you for opening a new pull request. Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient. While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone. One or more of the following people are relevant to this code:
|
| /// representation is always `u8` and this parser absorbs the difference, so nothing downstream has | ||
| /// to care which version produced the payload. | ||
| #[binrw::parser(reader, endian)] | ||
| fn read_bitterms(version: u8, count: u64) -> BinResult<Vec<u8>> { |
There was a problem hiding this comment.
Good way to deal with this.
|
|
||
| let data = match gate_type { | ||
| CircuitInstructionType::PauliEvolutionGate => Some(serialize( | ||
| // The evolution payload needs the target QPY version: the width of the observable's bit |
There was a problem hiding this comment.
No need to elaborate on this here.
There was a problem hiding this comment.
removed unnecessary comment
Signed-off-by: mohamedmahameed <mohamed.mahameed@ibm.com>
Summary
QPY 18 now stores the bit terms of a
SPARSE_OBSERVABLEpayload as (uint8_t) instead of (uint16_t).SparseObservableoperators is now one byte smaller per bit term, with no loss of information.The change is backwards compatible: v17 and earlier payloads load exactly as before, and
qpy.dump(..., version=17)still emits the older encoding.Tests
test/python/qpy/test_v18.py::TestV18SparseObservablecovers an evolution gate whose observableuses every
BitTermvariant and one over a mixedSparseObservable/SparsePauliOplist, eachround-tripped at v17 and v18 so both widths are exercised.
Note
This PR also depends on the bug fix PR: #16788
After merging the fix more test cases can be added.
AI/LLM disclosure