From dc47f4c9730ef7ce35cf4673bce3135cd96822a2 Mon Sep 17 00:00:00 2001 From: Haochen Wang Date: Tue, 3 Dec 2024 15:23:13 -0500 Subject: [PATCH 01/10] remove parsing catalyst device attr dict for shots --- .../lightning_gpu/catalyst/LightningGPUSimulator.hpp | 3 --- .../lightning_kokkos/catalyst/LightningKokkosSimulator.hpp | 3 --- .../simulators/lightning_qubit/catalyst/LightningSimulator.hpp | 3 --- 3 files changed, 9 deletions(-) diff --git a/pennylane_lightning/core/src/simulators/lightning_gpu/catalyst/LightningGPUSimulator.hpp b/pennylane_lightning/core/src/simulators/lightning_gpu/catalyst/LightningGPUSimulator.hpp index 1c9238a5b..38e87a417 100644 --- a/pennylane_lightning/core/src/simulators/lightning_gpu/catalyst/LightningGPUSimulator.hpp +++ b/pennylane_lightning/core/src/simulators/lightning_gpu/catalyst/LightningGPUSimulator.hpp @@ -108,9 +108,6 @@ class LightningGPUSimulator final : public Catalyst::Runtime::QuantumDevice { public: explicit LightningGPUSimulator(const std::string &kwargs = "{}") { auto &&args = Catalyst::Runtime::parse_kwargs(kwargs); - device_shots = args.contains("shots") - ? static_cast(std::stoll(args["shots"])) - : 0; } ~LightningGPUSimulator() = default; diff --git a/pennylane_lightning/core/src/simulators/lightning_kokkos/catalyst/LightningKokkosSimulator.hpp b/pennylane_lightning/core/src/simulators/lightning_kokkos/catalyst/LightningKokkosSimulator.hpp index dd162569f..f11144765 100644 --- a/pennylane_lightning/core/src/simulators/lightning_kokkos/catalyst/LightningKokkosSimulator.hpp +++ b/pennylane_lightning/core/src/simulators/lightning_kokkos/catalyst/LightningKokkosSimulator.hpp @@ -109,9 +109,6 @@ class LightningKokkosSimulator final : public Catalyst::Runtime::QuantumDevice { explicit LightningKokkosSimulator( const std::string &kwargs = "{}") noexcept { auto &&args = Catalyst::Runtime::parse_kwargs(kwargs); - device_shots = args.contains("shots") - ? static_cast(std::stoll(args["shots"])) - : 0; } ~LightningKokkosSimulator() noexcept = default; diff --git a/pennylane_lightning/core/src/simulators/lightning_qubit/catalyst/LightningSimulator.hpp b/pennylane_lightning/core/src/simulators/lightning_qubit/catalyst/LightningSimulator.hpp index c4edb70db..f0dafc2ce 100644 --- a/pennylane_lightning/core/src/simulators/lightning_qubit/catalyst/LightningSimulator.hpp +++ b/pennylane_lightning/core/src/simulators/lightning_qubit/catalyst/LightningSimulator.hpp @@ -101,9 +101,6 @@ class LightningSimulator final : public Catalyst::Runtime::QuantumDevice { const std::string &kwargs = "{}") // NOLINT(hicpp-member-init) { auto &&args = Catalyst::Runtime::parse_kwargs(kwargs); - device_shots = args.contains("shots") - ? static_cast(std::stoll(args["shots"])) - : 0; mcmc = args.contains("mcmc") ? args["mcmc"] == "True" : false; num_burnin = args.contains("num_burnin") ? static_cast(std::stoll(args["num_burnin"])) From 3f49c35030deeeb79c7ffbbe117e15e0f24f3c75 Mon Sep 17 00:00:00 2001 From: ringo-but-quantum Date: Tue, 3 Dec 2024 20:28:26 +0000 Subject: [PATCH 02/10] Auto update version from '0.40.0-dev24' to '0.40.0-dev25' --- pennylane_lightning/core/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pennylane_lightning/core/_version.py b/pennylane_lightning/core/_version.py index 17c98c7d1..43e4a2f30 100644 --- a/pennylane_lightning/core/_version.py +++ b/pennylane_lightning/core/_version.py @@ -16,4 +16,4 @@ Version number (major.minor.patch[-label]) """ -__version__ = "0.40.0-dev24" +__version__ = "0.40.0-dev25" From 52e166be414c0c0e14016767ffada411548db7f4 Mon Sep 17 00:00:00 2001 From: Haochen Wang Date: Wed, 4 Dec 2024 14:20:51 -0500 Subject: [PATCH 03/10] default to zero shots --- .../simulators/lightning_gpu/catalyst/LightningGPUSimulator.hpp | 2 +- .../simulators/lightning_qubit/catalyst/LightningSimulator.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pennylane_lightning/core/src/simulators/lightning_gpu/catalyst/LightningGPUSimulator.hpp b/pennylane_lightning/core/src/simulators/lightning_gpu/catalyst/LightningGPUSimulator.hpp index 38e87a417..117e46b66 100644 --- a/pennylane_lightning/core/src/simulators/lightning_gpu/catalyst/LightningGPUSimulator.hpp +++ b/pennylane_lightning/core/src/simulators/lightning_gpu/catalyst/LightningGPUSimulator.hpp @@ -61,7 +61,7 @@ class LightningGPUSimulator final : public Catalyst::Runtime::QuantumDevice { Catalyst::Runtime::CacheManager> cache_manager{}; bool tape_recording{false}; - std::size_t device_shots; + std::size_t device_shots{0}; std::mt19937 *gen{nullptr}; diff --git a/pennylane_lightning/core/src/simulators/lightning_qubit/catalyst/LightningSimulator.hpp b/pennylane_lightning/core/src/simulators/lightning_qubit/catalyst/LightningSimulator.hpp index f0dafc2ce..d47fdd4a6 100644 --- a/pennylane_lightning/core/src/simulators/lightning_qubit/catalyst/LightningSimulator.hpp +++ b/pennylane_lightning/core/src/simulators/lightning_qubit/catalyst/LightningSimulator.hpp @@ -50,7 +50,7 @@ class LightningSimulator final : public Catalyst::Runtime::QuantumDevice { Catalyst::Runtime::QubitManager qubit_manager{}; Catalyst::Runtime::CacheManager> cache_manager{}; bool tape_recording{false}; - size_t device_shots; + size_t device_shots{0}; std::mt19937 *gen = nullptr; From 952dd051b0aa16efdcf011b3766277887f183d8f Mon Sep 17 00:00:00 2001 From: Haochen Wang Date: Wed, 4 Dec 2024 14:36:03 -0500 Subject: [PATCH 04/10] change a `shots` to `my_attr` to avoid potential misunderstanding in parsing tests --- .../lightning_qubit/catalyst/tests/Test_LightningDriver.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pennylane_lightning/core/src/simulators/lightning_qubit/catalyst/tests/Test_LightningDriver.cpp b/pennylane_lightning/core/src/simulators/lightning_qubit/catalyst/tests/Test_LightningDriver.cpp index 41ab41738..0daad2b71 100644 --- a/pennylane_lightning/core/src/simulators/lightning_qubit/catalyst/tests/Test_LightningDriver.cpp +++ b/pennylane_lightning/core/src/simulators/lightning_qubit/catalyst/tests/Test_LightningDriver.cpp @@ -26,9 +26,9 @@ TEST_CASE("Test parse_kwargs coverage", "[Utils]") { std::string case1; CHECK(parse_kwargs(case1).empty()); - std::string case2{"{shots : 1000}"}; - std::string case3{"shots : 1000"}; - std::string case4{"'shots':'1000'"}; + std::string case2{"{my_attr : 1000}"}; + std::string case3{"my_attr : 1000"}; + std::string case4{"'my_attr':'1000'"}; CHECK(parse_kwargs(case2) == parse_kwargs(case3)); CHECK(parse_kwargs(case3) == parse_kwargs(case4)); From e2cc1c24ef1ec70a4c696e77f1e3a1cbea8dda59 Mon Sep 17 00:00:00 2001 From: Haochen Wang Date: Wed, 4 Dec 2024 14:37:38 -0500 Subject: [PATCH 05/10] remove shots parsing test --- .../lightning_qubit/catalyst/tests/Test_LightningDriver.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pennylane_lightning/core/src/simulators/lightning_qubit/catalyst/tests/Test_LightningDriver.cpp b/pennylane_lightning/core/src/simulators/lightning_qubit/catalyst/tests/Test_LightningDriver.cpp index 0daad2b71..bc4809908 100644 --- a/pennylane_lightning/core/src/simulators/lightning_qubit/catalyst/tests/Test_LightningDriver.cpp +++ b/pennylane_lightning/core/src/simulators/lightning_qubit/catalyst/tests/Test_LightningDriver.cpp @@ -40,13 +40,12 @@ TEST_CASE("Test parse_kwargs coverage", "[Utils]") { CHECK((res5.contains("E") && res5["E"] == "F")); std::string case6{ - "device_type : braket.aws.qubit,{'shots': 0, 'device_arn': 'sv1', " + "device_type : braket.aws.qubit,{'device_arn': 'sv1', " "'s3_destination_folder': \"('catalyst-op3-s3', 'prefix')\"}"}; auto res6 = parse_kwargs(case6); CHECK(res6.size() == 4); CHECK((res6.contains("device_type") && res6["device_type"] == "braket.aws.qubit")); - CHECK((res6.contains("shots") && res6["shots"] == "0")); CHECK((res6.contains("device_arn") && res6["device_arn"] == "sv1")); CHECK((res6.contains("s3_destination_folder") && res6["s3_destination_folder"] == "('catalyst-op3-s3', 'prefix')")); From 06370427720a4b491789210f51c5c4eb2dc6290b Mon Sep 17 00:00:00 2001 From: Haochen Wang Date: Wed, 4 Dec 2024 14:46:38 -0500 Subject: [PATCH 06/10] update test --- .../lightning_qubit/catalyst/tests/Test_LightningDriver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pennylane_lightning/core/src/simulators/lightning_qubit/catalyst/tests/Test_LightningDriver.cpp b/pennylane_lightning/core/src/simulators/lightning_qubit/catalyst/tests/Test_LightningDriver.cpp index bc4809908..81f08deb3 100644 --- a/pennylane_lightning/core/src/simulators/lightning_qubit/catalyst/tests/Test_LightningDriver.cpp +++ b/pennylane_lightning/core/src/simulators/lightning_qubit/catalyst/tests/Test_LightningDriver.cpp @@ -43,7 +43,7 @@ TEST_CASE("Test parse_kwargs coverage", "[Utils]") { "device_type : braket.aws.qubit,{'device_arn': 'sv1', " "'s3_destination_folder': \"('catalyst-op3-s3', 'prefix')\"}"}; auto res6 = parse_kwargs(case6); - CHECK(res6.size() == 4); + CHECK(res6.size() == 3); CHECK((res6.contains("device_type") && res6["device_type"] == "braket.aws.qubit")); CHECK((res6.contains("device_arn") && res6["device_arn"] == "sv1")); From 24f91cf2d5a0134f7e485eb664a64e2f477ce150 Mon Sep 17 00:00:00 2001 From: ringo-but-quantum Date: Thu, 5 Dec 2024 14:51:28 +0000 Subject: [PATCH 07/10] Auto update version from '0.40.0-dev28' to '0.40.0-dev29' --- pennylane_lightning/core/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pennylane_lightning/core/_version.py b/pennylane_lightning/core/_version.py index 3ecb65af2..f748fa2b7 100644 --- a/pennylane_lightning/core/_version.py +++ b/pennylane_lightning/core/_version.py @@ -16,4 +16,4 @@ Version number (major.minor.patch[-label]) """ -__version__ = "0.40.0-dev28" +__version__ = "0.40.0-dev29" From 50043cd4f353496fc9e16ce130bc207bcd1d5525 Mon Sep 17 00:00:00 2001 From: Haochen Wang Date: Thu, 5 Dec 2024 11:06:37 -0500 Subject: [PATCH 08/10] changelog --- .github/CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index 1509f65b3..e071acf50 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -26,6 +26,9 @@ ### Improvements +* Catalyst device interfaces supports dynamic shots, and no longer parses the device init op's attribute dictionary for a static shots literal. + [(#1017)](https://github.com/PennyLaneAI/pennylane-lightning/pull/1017) + * Reduce flaky test and increase test shots count. [(#1015)](https://github.com/PennyLaneAI/pennylane-lightning/pull/1015) From fdd627c03f996703739499fa30d336d6dfc6890a Mon Sep 17 00:00:00 2001 From: ringo-but-quantum Date: Thu, 5 Dec 2024 16:07:30 +0000 Subject: [PATCH 09/10] Auto update version from '0.40.0-dev29' to '0.40.0-dev30' --- pennylane_lightning/core/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pennylane_lightning/core/_version.py b/pennylane_lightning/core/_version.py index f748fa2b7..8eb04fefb 100644 --- a/pennylane_lightning/core/_version.py +++ b/pennylane_lightning/core/_version.py @@ -16,4 +16,4 @@ Version number (major.minor.patch[-label]) """ -__version__ = "0.40.0-dev29" +__version__ = "0.40.0-dev30" From 59841a50d074ab5fea6eb7c81de71294950347da Mon Sep 17 00:00:00 2001 From: Haochen Wang Date: Thu, 5 Dec 2024 11:11:34 -0500 Subject: [PATCH 10/10] grammar --- .github/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index e071acf50..c09d84436 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -26,7 +26,7 @@ ### Improvements -* Catalyst device interfaces supports dynamic shots, and no longer parses the device init op's attribute dictionary for a static shots literal. +* Catalyst device interfaces support dynamic shots, and no longer parses the device init op's attribute dictionary for a static shots literal. [(#1017)](https://github.com/PennyLaneAI/pennylane-lightning/pull/1017) * Reduce flaky test and increase test shots count.