Skip to content

[Python] Measurement result type#4000

Draft
khalatepradnya wants to merge 46 commits intoNVIDIA:mainfrom
khalatepradnya:py-measure-result
Draft

[Python] Measurement result type#4000
khalatepradnya wants to merge 46 commits intoNVIDIA:mainfrom
khalatepradnya:py-measure-result

Conversation

@khalatepradnya
Copy link
Copy Markdown
Collaborator

@khalatepradnya khalatepradnya commented Feb 18, 2026

Python frontend changes to support type distinction for measurement result.

Builds on top of #3800

khalatepradnya and others added 21 commits February 9, 2026 09:59
  in `qis` directory, remove the macro for library mode and drop the
  typedef to bool.
* Retain variable names assigned to measurement results
* Disallow measure_result as argument to entry-point kernels
* Drop the intrinsic funciton fro converting to Boolean vector
* Insert discriminate op wherever necessary
* Adjust tests
* WIP

Signed-off-by: Pradnya Khalate <pkhalate@nvidia.com>
  frontend
* Add support for RESULT type in the log parser - construct a
  `measure_result` object.
* Two tests are not working with `auto` - should be fixed
* Clean-up
* Handle the size for `measure_result` since it behaves differently on
  host and on device
* Log result output

Signed-off-by: Pradnya Khalate <pkhalate@nvidia.com>
  - Factory and Marshal
* Can use `auto` now
* NVQIR function for logging result record seems to have issues
* Test fixes

Signed-off-by: Pradnya Khalate <pkhalate@nvidia.com>
* Update passes to emit `result` type
* Fix tests for array recording calls

Signed-off-by: Pradnya Khalate <pkhalate@nvidia.com>
  from `measure_result` class
* Update kernel execution pass to handle measure_Result return types
* Fixed corresponding tests

Signed-off-by: Pradnya Khalate <pkhalate@nvidia.com>
  the use of `auto`

Signed-off-by: Pradnya Khalate <pkhalate@nvidia.com>
Signed-off-by: Pradnya Khalate <pkhalate@nvidia.com>
* Adjsut the host datatype accordingly
* Fix the logic to create sample_result from QIR log to read measure
  result type and make it efficient

Signed-off-by: Pradnya Khalate <pkhalate@nvidia.com>
Signed-off-by: Pradnya Khalate <pkhalate@nvidia.com>
  its vector)
* Should fix Python failure (which was a regression) in condiitonal
  kernel test.

Signed-off-by: Pradnya Khalate <pkhalate@nvidia.com>
  libstdc++ v/s libc++ differences

Signed-off-by: Pradnya Khalate <pkhalate@nvidia.com>
* Clean up

Signed-off-by: Pradnya Khalate <pkhalate@nvidia.com>
* Disallow tuples and dataclasses containing `measure_result`

Signed-off-by: Pradnya Khalate <pkhalate@nvidia.com>
@github-actions
Copy link
Copy Markdown

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

* Using `INT_MAX` as sentinel for unassigned ID.

Signed-off-by: Pradnya Khalate <pkhalate@nvidia.com>
Signed-off-by: Pradnya Khalate <pkhalate@nvidia.com>
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 4, 2026

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

  - entry-point kernels cannot return `measure_result` or a vector of it
  - use snake_case for public APIs

* Updated examples with `auto` to explicitly specify type

* Added new tests to cover the changes in the frontend

Signed-off-by: Pradnya Khalate <pkhalate@nvidia.com>
Signed-off-by: Pradnya Khalate <pkhalate@nvidia.com>
  else the cases like `inline-qpu-func.cpp` would crash.
* As a result, some of the existing tests need to have the attribute for
  entry-point kernels in order to succeed.

Signed-off-by: Pradnya Khalate <pkhalate@nvidia.com>
Signed-off-by: Pradnya Khalate <pkhalate@nvidia.com>
  replaced with public members)

Signed-off-by: Pradnya Khalate <pkhalate@nvidia.com>
@github-actions
Copy link
Copy Markdown

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

* Prevent direct invocation of kernels returning measure_result

Signed-off-by: Pradnya Khalate <pkhalate@nvidia.com>
@github-actions
Copy link
Copy Markdown

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

@github-actions
Copy link
Copy Markdown

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

@github-actions
Copy link
Copy Markdown

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

@github-actions
Copy link
Copy Markdown

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant