-
Notifications
You must be signed in to change notification settings - Fork 101
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
Implement gemm!
for (LazyTensor, LazyProduct) combo
#190
Comments
As a remark, the issue you are having can actually be traced back to the fact that no form of tensor product (lazy or normal) is implemented for the To explain: While it is true that The problem in your example now is, that |
I have implemented a first working version of the If you change the Hamiltonian as follows, everything works fine with the time evolution: Hkinx = LazyTensor(b_momentum ⊗ b_momentumy, [1, 2], [momentum(b_momentum)^2/2, one(b_momentumy)])
Hkiny = LazyTensor(b_momentum ⊗ b_momentumy, [1, 2], [one(b_momentum), momentum(b_momentumy)^2/2])
Hkin = LazyProduct(Txp ⊗ Typ, LazySum(Hkinx, Hkiny), Tpx ⊗ Tpy) Note, that instead of A first quick round of benchmarks already looks quite promising: @benchmark timeevolution.schroedinger(T, ψ, H)
BenchmarkTools.Trial:
memory estimate: 81.15 MiB
allocs estimate: 50534
--------------
minimum time: 291.918 ms (1.53% GC)
median time: 294.519 ms (2.15% GC)
mean time: 305.641 ms (5.65% GC)
maximum time: 390.605 ms (26.00% GC)
--------------
samples: 17
evals/sample: 1 As compared to the very inefficient case that was previously used here: Hsparse = sparse(full(H))
@benchmark timeevolution.schroedinger(T, ψ, Hsparse)
BenchmarkTools.Trial:
memory estimate: 6.43 MiB
allocs estimate: 2036
--------------
minimum time: 17.420 s (0.00% GC)
median time: 17.420 s (0.00% GC)
mean time: 17.420 s (0.00% GC)
maximum time: 17.420 s (0.00% GC)
--------------
samples: 1
evals/sample: 1 But also when comparing it to a more elegant implementation that was already possible, namely: Hkinx_old = LazyTensor(b_comp, [1, 2], [momentum(b_position)^2/2, one(b_positiony)])
Hkiny_old = LazyTensor(b_comp, [1, 2], [one(b_position), momentum(b_positiony)^2/2])
H_old = LazySum(Hkinx_old, Hkiny_old, V_comp)
@benchmark timeevolution.schroedinger(T, ψ, H_old)
BenchmarkTools.Trial:
memory estimate: 7.98 MiB
allocs estimate: 31514
--------------
minimum time: 4.025 s (0.00% GC)
median time: 4.037 s (0.00% GC)
mean time: 4.037 s (0.00% GC)
maximum time: 4.049 s (0.00% GC)
--------------
samples: 2
evals/sample: 1 we see that we have a huge speed-up. @Datseris Please have a go at this and let me know if everything works fine for you as well. There are still some open issues here, that I have to address though:
Do any other things come to mind? EDIT: One more thing for the list:
|
Hi David, I have to say that your latest post blew away my mind. Unfortunatelly at the moment I have been extremely busy with other projects (involving Husimi functions) and that is why I haven't made any moves yet. I really hope I can get to this on Friday, else I will do something over the weekend. |
The benchmarks keep giving me inconsistent results on different runs, even though I am reserving a CPU core for them. I am not sure why this is happening. Sometimes the new implementation is even faster than the old one in 1D, which is quite surprising. In any case, I think the difference is negligible. Basically, we can now move on the remaining points raised above. I will look into it. @Datseris No worries, I know that time is always a very limited resource. |
The |
For reference:
Now doing
gives the error that
gemm!
is not defined for LazyTensor and LazyProduct. Instead one has to work-around by passingHfull = sparse(full(H))
instead ofH
totimeevolution
.The text was updated successfully, but these errors were encountered: