qir-alliance / pyqir

PyQIR is a set of APIs for generating, parsing, and evaluating Quantum Intermediate Representation (QIR).
https://qir-alliance.github.io/pyqir
MIT License
54 stars 24 forks source link

Misnamed Function Attributes (required_num_* vs num_required_*) #250

Closed bmhowe23 closed 9 months ago

bmhowe23 commented 10 months ago

Describe the bug

The Base Profile Spec specifies that the required_num_qubits and required_num_results attributes must be attached to the entry point function, and while pyqir uses those attribute names in some places (like for internal variable names), there are some important places (like the LLVM interface) where num_required_qubits and num_required_results are used instead.

To Reproduce

Steps to reproduce the behavior:

  1. Modify qirlib/resources/tests/rt/initialize.ll to match the Base Profile specification by applying this patch:

    
    diff --git a/qirlib/resources/tests/rt/initialize.ll b/qirlib/resources/tests/rt/initialize.ll
    index 5a88b41..9ba9b22 100644
    --- a/qirlib/resources/tests/rt/initialize.ll
    +++ b/qirlib/resources/tests/rt/initialize.ll
    @@ -8,4 +8,4 @@ define void @main() #0 {
    
    declare void @__quantum__rt__initialize(i8*)

-attributes #0 = { "entry_point" "num_required_qubits"="0" "num_required_results"="0" "output_labeling_schema" "qir_profiles"="custom" } +attributes #0 = { "entry_point" "output_labeling_schema" "qir_profiles"="custom" "required_num_qubits"="0" "required_num_results"="0" }

2. Run `build.ps1`
3. Look for this failure message:
```bash
test rt::tests::initialize ... FAILED

Expected behavior

The test should not fail when using spec-compliant attributes.

Screenshots

N/A

System information

Additional context

N/A

idavis commented 9 months ago

Hi @bmhowe23 - I need to look at this. To my knowledge the base profile is only defined in qir-spec #25 PR which I just saw you had some comments on. Everything here is based on that PR trying to define the base profile.

idavis commented 9 months ago

Fixed in #251, not yet released. Thanks @bmhowe23 !