Skip to content

Commit 63b7297

Browse files
authored
✅ Improve test stability (#1794)
## Description This PR should improve the stability of some of the timing-based QDMI tests. We have recently seen them failing more and more. ## Checklist - [x] The pull request only contains commits that are focused and relevant to this change. - [x] ~~I have added appropriate tests that cover the new/changed functionality.~~ - [x] ~~I have updated the documentation to reflect these changes.~~ - [x] ~~I have added entries to the changelog for any noteworthy additions, changes, fixes, or removals.~~ - [x] ~~I have added migration instructions to the upgrade guide (if needed).~~ - [x] The changes follow the project's style guidelines and introduce no new warnings. - [x] The changes are fully tested and pass the CI checks. - [x] I have reviewed my own code changes.
1 parent 5a12960 commit 63b7297

5 files changed

Lines changed: 18 additions & 35 deletions

File tree

test/algorithms/test_qpe.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ TEST_P(QPE, IQPETest) {
175175
auto qc = qc::createIterativeQPE(lambda, precision);
176176
ASSERT_EQ(qc.getNqubits(), 2U);
177177

178-
constexpr auto shots = 8192U;
178+
constexpr auto shots = 16384U;
179179
const auto measurements = dd::sample(qc, shots);
180180

181181
// sort the measurements

test/qdmi/devices/dd/device_status_test.cpp

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ TEST(DeviceStatus, TransitionsBusyThenIdleAfterJob) {
3939
// it. Submit a job to force BUSY then completion to IDLE.
4040
const qdmi_test::JobGuard j{s.session};
4141
ASSERT_EQ(qdmi_test::setProgram(j.job, QDMI_PROGRAM_FORMAT_QASM3,
42-
qdmi_test::QASM3_BELL_SAMPLING),
42+
qdmi_test::QASM3_HEAVY_SAMPLING),
4343
QDMI_SUCCESS);
44-
ASSERT_EQ(qdmi_test::setShots(j.job, 4096), QDMI_SUCCESS);
44+
ASSERT_EQ(qdmi_test::setShots(j.job, 16384), QDMI_SUCCESS);
4545
ASSERT_EQ(MQT_DDSIM_QDMI_device_job_submit(j.job), QDMI_SUCCESS);
4646

4747
// Poll while running to observe BUSY at least once.
@@ -65,30 +65,3 @@ TEST(DeviceStatus, TransitionsBusyThenIdleAfterJob) {
6565
// After completion, the status should be IDLE.
6666
EXPECT_EQ(queryStatus(s.session), QDMI_DEVICE_STATUS_IDLE);
6767
}
68-
69-
TEST(DeviceStatus, MultipleConcurrentJobsKeepBusyUntilLastFinishes) {
70-
const qdmi_test::SessionGuard s{};
71-
72-
const qdmi_test::JobGuard j1{s.session};
73-
const qdmi_test::JobGuard j2{s.session};
74-
ASSERT_EQ(qdmi_test::setProgram(j1.job, QDMI_PROGRAM_FORMAT_QASM3,
75-
qdmi_test::QASM3_BELL_SAMPLING),
76-
QDMI_SUCCESS);
77-
ASSERT_EQ(qdmi_test::setProgram(j2.job, QDMI_PROGRAM_FORMAT_QASM3,
78-
qdmi_test::QASM3_HEAVY_SAMPLING5),
79-
QDMI_SUCCESS);
80-
ASSERT_EQ(qdmi_test::setShots(j1.job, 1024), QDMI_SUCCESS);
81-
ASSERT_EQ(qdmi_test::setShots(j2.job, 16384), QDMI_SUCCESS);
82-
83-
ASSERT_EQ(MQT_DDSIM_QDMI_device_job_submit(j1.job), QDMI_SUCCESS);
84-
ASSERT_EQ(MQT_DDSIM_QDMI_device_job_submit(j2.job), QDMI_SUCCESS);
85-
86-
// Wait for first to finish
87-
ASSERT_EQ(MQT_DDSIM_QDMI_device_job_wait(j1.job, 0), QDMI_SUCCESS);
88-
// Status should still be BUSY while the second runs
89-
EXPECT_EQ(queryStatus(s.session), QDMI_DEVICE_STATUS_BUSY);
90-
91-
// Wait for second, then status should go IDLE
92-
ASSERT_EQ(MQT_DDSIM_QDMI_device_job_wait(j2.job, 0), QDMI_SUCCESS);
93-
EXPECT_EQ(queryStatus(s.session), QDMI_DEVICE_STATUS_IDLE);
94-
}

test/qdmi/devices/dd/error_handling_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ TEST_F(ErrorHandling, GetResultsBeforeDone) {
7575
const qdmi_test::SessionGuard s{};
7676
const qdmi_test::JobGuard j{s.session};
7777
ASSERT_EQ(qdmi_test::setProgram(j.job, QDMI_PROGRAM_FORMAT_QASM3,
78-
qdmi_test::QASM3_BELL_SAMPLING),
78+
qdmi_test::QASM3_HEAVY_SAMPLING),
7979
QDMI_SUCCESS);
80-
ASSERT_EQ(qdmi_test::setShots(j.job, 64), QDMI_SUCCESS);
80+
ASSERT_EQ(qdmi_test::setShots(j.job, 16384), QDMI_SUCCESS);
8181
// Before submit → invalid
8282
EXPECT_EQ(MQT_DDSIM_QDMI_device_job_get_results(
8383
j.job, QDMI_JOB_RESULT_HIST_KEYS, 0, nullptr, nullptr),

test/qdmi/devices/dd/helpers/circuits.hpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ cx q[0], q[1];
3232

3333
inline constexpr const char* QASM3_MALFORMED = "Definitely not OpenQASM";
3434

35-
// A slightly heavier 5-qubit sampling circuit to prolong runtime slightly while
35+
// A slightly heavier dynamic sampling circuit to prolong runtime slightly while
3636
// remaining fast
37-
inline constexpr auto QASM3_HEAVY_SAMPLING5 = R"(
37+
inline constexpr auto QASM3_HEAVY_SAMPLING = R"(
3838
OPENQASM 3;
3939
include "stdgates.inc";
4040
qubit[5] q;
@@ -58,6 +58,16 @@ cx q[1], q[2];
5858
cx q[0], q[1];
5959
// Measure all qubits
6060
c = measure q;
61+
// Add dynamic component
62+
if (c == 3) {
63+
rx(0.7) q[0];
64+
ry(0.5) q[1];
65+
rz(1.1) q[2];
66+
ry(0.3) q[3];
67+
rx(0.9) q[4];
68+
}
69+
// Measure all qubits again
70+
c = measure q;
6171
)";
6272

6373
} // namespace qdmi_test

test/qdmi/devices/dd/job_lifecycle_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ TEST(JobLifecycle, FreeWhileRunningWaitsForCompletion) {
111111
ASSERT_EQ(MQT_DDSIM_QDMI_device_session_create_device_job(s.session, &job),
112112
QDMI_SUCCESS);
113113
ASSERT_EQ(qdmi_test::setProgram(job, QDMI_PROGRAM_FORMAT_QASM3,
114-
qdmi_test::QASM3_HEAVY_SAMPLING5),
114+
qdmi_test::QASM3_HEAVY_SAMPLING),
115115
QDMI_SUCCESS);
116116
ASSERT_EQ(qdmi_test::setShots(job, 4096), QDMI_SUCCESS);
117117
ASSERT_EQ(MQT_DDSIM_QDMI_device_job_submit(job), QDMI_SUCCESS);

0 commit comments

Comments
 (0)