Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dia data layer to benchmarks #47

Merged
merged 4 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions qutip_benchmark/benchmarks/bench_linear_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

# Available datatypes (using qutip_dense and qutip_csr to avoid confusion
# with density parameters)
@pytest.fixture(params=["numpy", "scipy_csr", "qutip_dense", "qutip_csr"])
@pytest.fixture(
params=["numpy", "scipy_csr", "qutip_dense", "qutip_csr", "qutip_dia"]
)
def dtype(request):
return request.param

Expand Down Expand Up @@ -41,6 +43,8 @@ def left_oper(size, density, dtype):
return res.to("dense")
if dtype == "qutip_csr":
return res.to("csr")
if dtype == "qutip_dia":
return res.to("dia")
raise Exception("The specified dtype is invalid")


Expand All @@ -63,6 +67,8 @@ def right_oper(size, density, dtype):
return res.to("dense")
if dtype == "qutip_csr":
return res.to("csr")
if dtype == "qutip_dia":
return res.to("dia")
raise Exception("The specified dtype is invalid")


Expand All @@ -81,6 +87,8 @@ def right_ket(size, density, dtype):
return res.to("dense")
if dtype == "qutip_csr":
return res.to("csr")
if dtype == "qutip_dia":
return res.to("dia")
raise Exception("The specified dtype is invalid")


Expand All @@ -97,26 +105,20 @@ def add(left, right):
return left + right

# Run benchmark
result = benchmark(add, left_oper, right_oper)

return result
benchmark(add, left_oper, right_oper)


@pytest.mark.nightly
def bench_matmul_oper_oper(benchmark, left_oper, right_oper):
benchmark.group = "math:matmul:op-times-op"

# Benchmark operations
result = benchmark(matmul, left_oper, right_oper)

return result
benchmark(matmul, left_oper, right_oper)


@pytest.mark.nightly
def bench_matmul_oper_ket(benchmark, left_oper, right_ket):
benchmark.group = "math:matmul:op-times-ket"

# Run benchmark
result = benchmark(matmul, left_oper, right_ket)

return result
benchmark(matmul, left_oper, right_ket)
4 changes: 1 addition & 3 deletions qutip_benchmark/benchmarks/bench_qobjevo.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,4 @@ def matmul(left, right):
def bench_matmul_QobjEvo_ket(benchmark, left_QobjEvo, right_ket):
benchmark.group = "math:matmul:qobjevo-op-times-ket"

result = benchmark(matmul, left_QobjEvo, right_ket)

return result
benchmark(matmul, left_QobjEvo, right_ket)
Loading