From 9d0dc1bdaa62eeb3340b68136f7e43ddbe39e761 Mon Sep 17 00:00:00 2001 From: Thien Nguyen Date: Fri, 13 Dec 2024 02:50:00 +0000 Subject: [PATCH 1/2] Always clear threadToQpuId when we clear platformQPUs Signed-off-by: Thien Nguyen --- runtime/cudaq/platform/mqpu/MultiQPUPlatform.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/runtime/cudaq/platform/mqpu/MultiQPUPlatform.cpp b/runtime/cudaq/platform/mqpu/MultiQPUPlatform.cpp index bdde97a464..198a214c16 100644 --- a/runtime/cudaq/platform/mqpu/MultiQPUPlatform.cpp +++ b/runtime/cudaq/platform/mqpu/MultiQPUPlatform.cpp @@ -31,6 +31,7 @@ class MultiQPUQuantumPlatform : public cudaq::quantum_platform { // Make sure that we clean up the client QPUs first before cleaning up the // remote servers. platformQPUs.clear(); + threadToQpuId.clear(); platformNumQPUs = 0; m_remoteServers.clear(); } @@ -154,6 +155,7 @@ class MultiQPUQuantumPlatform : public cudaq::quantum_platform { qpuSubType)); if (qpuSubType == "NvcfSimulatorQPU") { platformQPUs.clear(); + threadToQpuId.clear(); auto simName = getOpt(description, "backend"); if (simName.empty()) simName = "custatevec-fp32"; @@ -199,6 +201,7 @@ class MultiQPUQuantumPlatform : public cudaq::quantum_platform { } else if (qpuSubType == "orca") { auto urls = cudaq::split(getOpt(description, "url"), ','); platformQPUs.clear(); + threadToQpuId.clear(); for (std::size_t qId = 0; qId < urls.size(); ++qId) { // Populate the information and add the QPUs platformQPUs.emplace_back(cudaq::registry::get("orca")); @@ -244,6 +247,7 @@ class MultiQPUQuantumPlatform : public cudaq::quantum_platform { "receiving {}, expecting {}.", sims.size(), urls.size())); platformQPUs.clear(); + threadToQpuId.clear(); for (std::size_t qId = 0; qId < urls.size(); ++qId) { const auto simName = sims.size() == 1 ? sims.front() : sims[qId]; // Populate the information and add the QPUs From b0b5f4ae3640e17e5ab52d53f6fac9a71d875c19 Mon Sep 17 00:00:00 2001 From: Thien Nguyen Date: Fri, 13 Dec 2024 04:54:49 +0000 Subject: [PATCH 2/2] Clear threadToQpuId for DefaultQuantumPlatform for consistency Signed-off-by: Thien Nguyen --- runtime/cudaq/platform/default/DefaultQuantumPlatform.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/runtime/cudaq/platform/default/DefaultQuantumPlatform.cpp b/runtime/cudaq/platform/default/DefaultQuantumPlatform.cpp index df8a89e6f4..b24637c2ce 100644 --- a/runtime/cudaq/platform/default/DefaultQuantumPlatform.cpp +++ b/runtime/cudaq/platform/default/DefaultQuantumPlatform.cpp @@ -82,6 +82,7 @@ class DefaultQuantumPlatform : public cudaq::quantum_platform { /// specified by that variable. void setTargetBackend(const std::string &backend) override { platformQPUs.clear(); + threadToQpuId.clear(); platformQPUs.emplace_back(std::make_unique()); cudaq::info("Backend string is {}", backend); @@ -121,6 +122,7 @@ class DefaultQuantumPlatform : public cudaq::quantum_platform { auto qpuName = config.BackendConfig->PlatformQpu; cudaq::info("Default platform QPU subtype name: {}", qpuName); platformQPUs.clear(); + threadToQpuId.clear(); platformQPUs.emplace_back(cudaq::registry::get(qpuName)); if (platformQPUs.front() == nullptr) throw std::runtime_error(