Skip to content

Commit

Permalink
[ITensors] Observers.jl package extension (#1381)
Browse files Browse the repository at this point in the history
  • Loading branch information
emstoudenmire committed Apr 16, 2024
1 parent 95c0a70 commit 4d64299
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 78 deletions.
77 changes: 0 additions & 77 deletions .github/workflows/comment_trigger_test_itensortdvp.yml

This file was deleted.

53 changes: 53 additions & 0 deletions .github/workflows/test_itensortdvp_ubuntu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Run ITensorTDVP tests (Unbuntu)

on:
push:
branches:
- main
tags: '*'
pull_request:

jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ matrix.threads }} thread(s)
runs-on: ${{ matrix.os }}
env:
JULIA_NUM_THREADS: ${{ matrix.threads }}
strategy:
matrix:
version:
- '1.6'
- '1'
os:
- ubuntu-latest
threads:
- '2'
arch:
- x64
exclude:
# MacOS not available on x86
- {os: 'macOS-latest', arch: 'x86'}
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@latest
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- name: Install Julia dependencies and run tests
shell: julia {0}
run: |
using Pkg;
try
Pkg.activate(temp=true);
Pkg.develop(path="./NDTensors");
Pkg.develop(path=".");
Pkg.add("ITensorTDVP");
Pkg.test("ITensorTDVP");
catch err
err isa Pkg.Resolve.ResolverError || rethrow()
# If we can't resolve that means this is incompatible by SemVer and this is fine
# It means we marked this as a breaking change, so we don't need to worry about
# Mistakenly introducing a breaking change, as we have intentionally made one
@info "ITensorTDVP not compatible with this release. Skipping this test." exception=err
exit(0) # Exit immediately, as a success
end
3 changes: 3 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ Zeros = "bd1ec220-6eb4-527a-9b49-e79c3db6233b"
ZygoteRules = "700de1a5-db45-46bc-99cf-38207098b444"

[weakdeps]
Observers = "338f10d5-c7f1-4033-a7d1-f9dec39bcaa0"
VectorInterface = "409d34a3-91d5-4945-b6ec-7529ddf182d8"

[extensions]
ITensorsObserversExt = "Observers"
ITensorsVectorInterfaceExt = "VectorInterface"

[compat]
Expand Down Expand Up @@ -72,4 +74,5 @@ ZygoteRules = "0.2.2"
julia = "1.6"

[extras]
Observers = "338f10d5-c7f1-4033-a7d1-f9dec39bcaa0"
VectorInterface = "409d34a3-91d5-4945-b6ec-7529ddf182d8"
11 changes: 11 additions & 0 deletions ext/ITensorsObserversExt/ITensorsObserversExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module ITensorsObserversExt

using Observers: Observers
using Observers.DataFrames: AbstractDataFrame
using ITensors.ITensorMPS: ITensorMPS

function ITensorMPS.update_observer!(observer::AbstractDataFrame; kwargs...)
return Observers.update!(observer; kwargs...)
end

end
2 changes: 1 addition & 1 deletion src/ITensorMPS/alternating_update.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function alternating_update(
)
end
current_time += time_step
update!(step_observer!; psi, sweep, outputlevel, current_time)
update_observer!(step_observer!; psi, sweep, outputlevel, current_time)
if outputlevel >= 1
print("After sweep ", sweep, ":")
print(" maxlinkdim=", maxlinkdim(psi))
Expand Down

0 comments on commit 4d64299

Please sign in to comment.