Skip to content

Commit c7769a1

Browse files
committed
🎮 Lanczos tests on GPU
1 parent b0722e3 commit c7769a1

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

test/ext-test/gpu/cuda_ext.jl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,29 @@ end
154154
@test ρ_ss_cpu.data Array(ρ_ss_gpu_csr.data) atol = 1e-8 * length(ρ_ss_cpu)
155155
end
156156

157+
@testset "CUDA spectrum" begin
158+
N = 10
159+
a = cu(destroy(N))
160+
H = a' * a
161+
c_ops = [sqrt(0.1 * (0.01 + 1)) * a, sqrt(0.1 * (0.01)) * a']
162+
solver = Lanczos(steadystate_solver = SteadyStateLinearSolver())
163+
164+
ω_l = range(0, 3, length = 1000)
165+
spec = spectrum(H, ω_l, c_ops, a', a; solver = solver)
166+
167+
spec = collect(spec)
168+
spec = spec ./ maximum(spec)
169+
170+
test_func = maximum(real.(spec)) * (0.1 / 2)^2 ./ ((ω_l .- 1) .^ 2 .+ (0.1 / 2)^2)
171+
idxs = test_func .> 0.05
172+
@test sum(abs2.(spec[idxs] .- test_func[idxs])) / sum(abs2.(test_func[idxs])) < 0.01
173+
174+
# TODO: Fix this
175+
# @testset "Type Inference spectrum" begin
176+
# @inferred spectrum(H, ω_l, c_ops, a', a; solver = solver)
177+
# end
178+
end
179+
157180
@testset "CUDA ptrace" begin
158181
g = fock(2, 1)
159182
e = fock(2, 0)

0 commit comments

Comments
 (0)