QuTech-Delft / OpenQL

OpenQL: A Portable Quantum Programming Framework for Quantum Accelerators. https://dl.acm.org/doi/10.1145/3474222
https://openql.readthedocs.io
Other
97 stars 44 forks source link

Support for parametrized operations in gate decomposition #419

Closed MiguelSMoreira closed 2 years ago

MiguelSMoreira commented 3 years ago

This issue will track developments in the support for the definition of gates with arbitrary parameters, which could be used for the implementation of arbitrary rotation gates (for example, virtual-Z gates). Although such a feature would require changes at various levels of PycQED, this issue should only track the developments necessary in OpenQL .

wvlothuizen commented 2 years ago

Tests to perform:

MiguelSMoreira commented 2 years ago

After attempting to test this feature, both myself and @wvlothuizen realized that we are currently unaware of how to specify parametric operations in OpenQL. Therefore, we shall ask @jvansomeren for pointers to documentation of this feature before proceeding

jvansomeren commented 2 years ago

Hi, Are you using the new IR and the new decomposition specifications? Without those it will not work. With it, it is new unexplored territory, the new decomposition was meant to handle parameterised operations but it may very well not be sufficient for your needs. I hope there are examples or tests for it that could help us to learn how to do it. And of course the doc. Otherwise we have to dive into the code of the decomposer pass.

Groet,

Hans van Someren

Op 18 jan. 2022 om 15:21 heeft Miguel Serrão Moreira @.***> het volgende geschreven:



After attempting to test this feature, both myself and @wvlothuizenhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_wvlothuizen&d=DwMCaQ&c=XYzUhXBD2cD-CornpT4QE19xOJBbRy-TBPLK0X9U2o8&r=kNdT9ewT6pQdYFkBLR_5-ZqsrSTk7k5Hdd7MSC_Vnzg&m=Q4OBa8t0_k9BTuodx5AkgyOXWmVQE6V1-96DsVFt0S4&s=dnYeUKPxCuzZ85QE-uiqONhGLBwgdWeVNyuVISY9Lu8&e= realized that we are currently unaware of how to specify parametric operations in OpenQL. Therefore, we shall ask @jvansomerenhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_jvansomeren&d=DwMCaQ&c=XYzUhXBD2cD-CornpT4QE19xOJBbRy-TBPLK0X9U2o8&r=kNdT9ewT6pQdYFkBLR_5-ZqsrSTk7k5Hdd7MSC_Vnzg&m=Q4OBa8t0_k9BTuodx5AkgyOXWmVQE6V1-96DsVFt0S4&s=WmnzizZMBAmGurVAKYstVGx6ZIqYmvoF8-bQMzOER28&e= for pointers to documentation of this feature before proceeding

— Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_QE-2DLab_OpenQL_issues_419-23issuecomment-2D1015459046&d=DwMCaQ&c=XYzUhXBD2cD-CornpT4QE19xOJBbRy-TBPLK0X9U2o8&r=kNdT9ewT6pQdYFkBLR_5-ZqsrSTk7k5Hdd7MSC_Vnzg&m=Q4OBa8t0_k9BTuodx5AkgyOXWmVQE6V1-96DsVFt0S4&s=DUgKmEXx1crmEwqDRMIgKUqhAqUFshczKOib4cJUjA4&e=, or unsubscribehttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AEDTBNXKKHL3RMHX3TZ4HA3UWVZP5ANCNFSM46N2L6EA&d=DwMCaQ&c=XYzUhXBD2cD-CornpT4QE19xOJBbRy-TBPLK0X9U2o8&r=kNdT9ewT6pQdYFkBLR_5-ZqsrSTk7k5Hdd7MSC_Vnzg&m=Q4OBa8t0_k9BTuodx5AkgyOXWmVQE6V1-96DsVFt0S4&s=f79G55Xuy2GV2zCJ_L9mYwvhVeLKrU5xVoCQmD5n53U&e=. Triage notifications on the go with GitHub Mobile for iOShttps://urldefense.proofpoint.com/v2/url?u=https-3A__apps.apple.com_app_apple-2Dstore_id1477376905-3Fct-3Dnotification-2Demail-26mt-3D8-26pt-3D524675&d=DwMCaQ&c=XYzUhXBD2cD-CornpT4QE19xOJBbRy-TBPLK0X9U2o8&r=kNdT9ewT6pQdYFkBLR_5-ZqsrSTk7k5Hdd7MSC_Vnzg&m=Q4OBa8t0_k9BTuodx5AkgyOXWmVQE6V1-96DsVFt0S4&s=smcLxKuMkFKuekQ6b3QjHl6hcw3Qez452FKMq_lmp-8&e= or Androidhttps://urldefense.proofpoint.com/v2/url?u=https-3A__play.google.com_store_apps_details-3Fid-3Dcom.github.android-26referrer-3Dutm-5Fcampaign-253Dnotification-2Demail-2526utm-5Fmedium-253Demail-2526utm-5Fsource-253Dgithub&d=DwMCaQ&c=XYzUhXBD2cD-CornpT4QE19xOJBbRy-TBPLK0X9U2o8&r=kNdT9ewT6pQdYFkBLR_5-ZqsrSTk7k5Hdd7MSC_Vnzg&m=Q4OBa8t0_k9BTuodx5AkgyOXWmVQE6V1-96DsVFt0S4&s=LqwpfVv8OJ3ly1vil8pkVsJB7XqNshHgbFdfSeTVnj4&e=. You are receiving this because you were mentioned.Message ID: @.***>

wvlothuizen commented 2 years ago

After rereading https://openql.readthedocs.io/en/latest/gen/reference_configuration.html#decomposition-key and some testing, parameterized decompositions using the new method just seem to work as expected.

Using decomposition https://github.com/DiCarloLab-Delft/PycQED_py3/blob/feature/cc/pycqed/measurement/openql_experiments/config/config_cc_s17_direct_iq.json.in#L373 in conjunction with cQasm program https://github.com/DiCarloLab-Delft/PycQED_py3/blob/feature/cc/pycqed/tests/openql/test_cqasm.py#L49 works up to the the CC backend, which then fails within 'if' condition: in expression '3 < 45': cannot currently handle functions on two literal parameters. And without the if's, arbitrary rotation gates using pycQED are not feasible.

jvansomeren commented 2 years ago

Hi, Great! Wrt the decomposition rule, I would expect the qubit to be of X type, not of Z type since it concerns an X rotation. Wrt the condition, I would expect that the condition is compiler-evaluated and the if then else be reduced to the branch of choice.

Groet,

Hans van Someren

Op 19 jan. 2022 om 13:22 heeft Wouter Vlothuizen @.***> het volgende geschreven:



After rereading https://openql.readthedocs.io/en/latest/gen/reference_configuration.html#decomposition-keyhttps://urldefense.proofpoint.com/v2/url?u=https-3A__openql.readthedocs.io_en_latest_gen_reference-5Fconfiguration.html-23decomposition-2Dkey&d=DwMCaQ&c=XYzUhXBD2cD-CornpT4QE19xOJBbRy-TBPLK0X9U2o8&r=kNdT9ewT6pQdYFkBLR_5-ZqsrSTk7k5Hdd7MSC_Vnzg&m=7-dkpbhK_hVaXCXeQmrA1mAHlYED3EOsbkDdkcjFUHA&s=yYsat-ntUvAl0hnVK5gD0DAdW9h4MM3RKdSgb4pkrBU&e= and some testing, parameterized decompositions using the new method just seem to work as expected.

Using decomposition https://github.com/DiCarloLab-Delft/PycQED_py3/blob/feature/cc/pycqed/measurement/openql_experiments/config/config_cc_s17_direct_iq.json.in#L373https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_DiCarloLab-2DDelft_PycQED-5Fpy3_blob_feature_cc_pycqed_measurement_openql-5Fexperiments_config_config-5Fcc-5Fs17-5Fdirect-5Fiq.json.in-23L373&d=DwMCaQ&c=XYzUhXBD2cD-CornpT4QE19xOJBbRy-TBPLK0X9U2o8&r=kNdT9ewT6pQdYFkBLR_5-ZqsrSTk7k5Hdd7MSC_Vnzg&m=7-dkpbhK_hVaXCXeQmrA1mAHlYED3EOsbkDdkcjFUHA&s=sYjM6ZQpobjuNpHfAxmD3ghZPi92XDh_aX74VyXdzm4&e= in conjunction with cQasm program https://github.com/DiCarloLab-Delft/PycQED_py3/blob/feature/cc/pycqed/tests/openql/test_cqasm.py#L49https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_DiCarloLab-2DDelft_PycQED-5Fpy3_blob_feature_cc_pycqed_tests_openql_test-5Fcqasm.py-23L49&d=DwMCaQ&c=XYzUhXBD2cD-CornpT4QE19xOJBbRy-TBPLK0X9U2o8&r=kNdT9ewT6pQdYFkBLR_5-ZqsrSTk7k5Hdd7MSC_Vnzg&m=7-dkpbhK_hVaXCXeQmrA1mAHlYED3EOsbkDdkcjFUHA&s=gaMDYQBkMn2Gbaylr6a--L_yjZ0pwDlf55YRHHEC3O4&e= works up to the the CC backend, which then fails within 'if' condition: in expression '3 < 45': cannot currently handle functions on two literal parameters. And without the if's, arbitrary rotation gates using pycQED are not feasible.

— Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_QE-2DLab_OpenQL_issues_419-23issuecomment-2D1016415670&d=DwMCaQ&c=XYzUhXBD2cD-CornpT4QE19xOJBbRy-TBPLK0X9U2o8&r=kNdT9ewT6pQdYFkBLR_5-ZqsrSTk7k5Hdd7MSC_Vnzg&m=7-dkpbhK_hVaXCXeQmrA1mAHlYED3EOsbkDdkcjFUHA&s=jWJKIJj3NFbWPerey0fHU-eWViwS8fxwxbua6mmRPeA&e=, or unsubscribehttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AEDTBNXL27US7PSVHRL56PDUW2UJ5ANCNFSM46N2L6EA&d=DwMCaQ&c=XYzUhXBD2cD-CornpT4QE19xOJBbRy-TBPLK0X9U2o8&r=kNdT9ewT6pQdYFkBLR_5-ZqsrSTk7k5Hdd7MSC_Vnzg&m=7-dkpbhK_hVaXCXeQmrA1mAHlYED3EOsbkDdkcjFUHA&s=eyFU0JhTZbUwFTPu8z_GQNpI8-ZCRkmlicgj_Btyxck&e=. Triage notifications on the go with GitHub Mobile for iOShttps://urldefense.proofpoint.com/v2/url?u=https-3A__apps.apple.com_app_apple-2Dstore_id1477376905-3Fct-3Dnotification-2Demail-26mt-3D8-26pt-3D524675&d=DwMCaQ&c=XYzUhXBD2cD-CornpT4QE19xOJBbRy-TBPLK0X9U2o8&r=kNdT9ewT6pQdYFkBLR_5-ZqsrSTk7k5Hdd7MSC_Vnzg&m=7-dkpbhK_hVaXCXeQmrA1mAHlYED3EOsbkDdkcjFUHA&s=oc8i7mRwv_1Xxf3BkqZet8PKAEVCWxqY0_it9qDF_Rw&e= or Androidhttps://urldefense.proofpoint.com/v2/url?u=https-3A__play.google.com_store_apps_details-3Fid-3Dcom.github.android-26referrer-3Dutm-5Fcampaign-253Dnotification-2Demail-2526utm-5Fmedium-253Demail-2526utm-5Fsource-253Dgithub&d=DwMCaQ&c=XYzUhXBD2cD-CornpT4QE19xOJBbRy-TBPLK0X9U2o8&r=kNdT9ewT6pQdYFkBLR_5-ZqsrSTk7k5Hdd7MSC_Vnzg&m=7-dkpbhK_hVaXCXeQmrA1mAHlYED3EOsbkDdkcjFUHA&s=y3OMmvstBg-KJk6UD7OMyfskH1Vj1RN0O8xRGTXpR7w&e=. You are receiving this because you were mentioned.Message ID: @.***>

wvlothuizen commented 2 years ago

You're right about the X!

Currently, constant expressions are passed to the backend, and the CC backend doesn't handle them (because it would probably be better to make a separate pass that can be reused across architectures)