-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:jurajHasik/tn-torch_dev
- Loading branch information
Showing
149 changed files
with
110,771 additions
and
1,974 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
[submodule "yast"] | ||
path = yast | ||
url = https://gitlab.com/marekrams/yast.git | ||
[submodule "yastn"] | ||
path = yastn | ||
url = https://github.com/yastn/yastn.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import pytest | ||
import context | ||
import config as cfg | ||
|
||
def pytest_addoption(parser): | ||
parser.addoption( | ||
"--device", | ||
default="cpu", | ||
help="choose device", | ||
) | ||
|
||
def pytest_configure(config): | ||
device= config.getoption("--device") | ||
cfg.global_args.device= device |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import os | ||
import sys | ||
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../'))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import context | ||
import pytest | ||
import torch | ||
import config as cfg | ||
from ipeps.ipeps import IPEPS | ||
from ctm.generic.env import ENV, init_random | ||
from models.spin_triangular import J1J2J4_1SITE, eval_nn_per_site, eval_nnn_per_site, eval_nn_and_chirality_per_site | ||
|
||
import logging | ||
logging.basicConfig(filename=f"{__file__}.log", filemode='w', level=logging.INFO) | ||
|
||
test_dims=[(3,27), (3,54), (4,32)] | ||
|
||
|
||
@pytest.mark.parametrize("dims",test_dims) | ||
@pytest.mark.parametrize("unroll",[True,False]) | ||
def test_profile_j1j2_loop_oe_semimanual(dims, unroll, benchmark): | ||
D,X= dims | ||
|
||
state= IPEPS({(0,0): torch.rand((2,)+(D,)*4,\ | ||
dtype=cfg.global_args.torch_dtype,device=cfg.global_args.device)-0.5}, lX=1, lY=1) | ||
env= ENV(X, state) | ||
init_random(env) | ||
|
||
model= J1J2J4_1SITE(phys_dim=2, j1=1.0, j2=1.0, j4=0, jchi=0, global_args=cfg.global_args) | ||
|
||
def test_f(): | ||
nn_h_v,nn_diag= eval_nn_per_site((0,0),state,env,model.R,model.R@model.R,model.SS,model.SS) | ||
nnn= eval_nnn_per_site((0,0),state,env,None,None,model.SS,looped=unroll,use_checkpoint=False) | ||
|
||
benchmark.pedantic(test_f, args=(),\ | ||
iterations=1, rounds=2, warmup_rounds=1) | ||
|
||
@pytest.mark.parametrize("dims",test_dims) | ||
@pytest.mark.parametrize("unroll",[True,False]) | ||
def test_profile_j1j2jX_loop_oe_semimanual(dims, unroll, benchmark): | ||
D,X= dims | ||
|
||
state= IPEPS({(0,0): torch.rand((2,)+(D,)*4,\ | ||
dtype=cfg.global_args.torch_dtype,device=cfg.global_args.device)-0.5}, lX=1, lY=1) | ||
env= ENV(X, state) | ||
init_random(env) | ||
|
||
model= J1J2J4_1SITE(phys_dim=2, j1=1.0, j2=1.0, j4=0, jchi=0, global_args=cfg.global_args) | ||
|
||
def test_f(): | ||
nnn= eval_nnn_per_site((0,0),state,env,None,None,model.SS,looped=unroll,use_checkpoint=False) | ||
nn_h_v,nn_diag,chi= eval_nn_and_chirality_per_site((0,0),state,env,\ | ||
model.R,model.R@model.R,model.SS,model.SS,model.h_chi,looped=unroll,use_checkpoint=False) | ||
|
||
benchmark.pedantic(test_f, args=(),\ | ||
iterations=1, rounds=2, warmup_rounds=1) | ||
|
||
@pytest.mark.parametrize("dims",test_dims) | ||
@pytest.mark.parametrize("unroll",[True,False]) | ||
def test_profile_rdm2x3_loop_manual(dims, unroll, benchmark): | ||
D,X= dims | ||
|
||
state= IPEPS({(0,0): torch.rand((2,)+(D,)*4,\ | ||
dtype=cfg.global_args.torch_dtype,device=cfg.global_args.device)-0.5}, lX=1, lY=1) | ||
env= ENV(X, state) | ||
init_random(env) | ||
|
||
model= J1J2J4_1SITE(phys_dim=2, j1=1.0, j2=1.0, j4=0, jchi=0, global_args=cfg.global_args) | ||
|
||
benchmark.pedantic(model.energy_1x3, args=(state,env,-1,unroll,\ | ||
cfg.ctm_args,cfg.global_args),\ | ||
iterations=1, rounds=2, warmup_rounds=1) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import context | ||
import pytest | ||
import torch | ||
import config as cfg | ||
from ipeps.ipeps import IPEPS | ||
from ctm.generic.env import ENV, init_random | ||
from ctm.generic import rdm_mc | ||
|
||
import logging | ||
logging.basicConfig(filename=f"{__file__}.log", filemode='w', level=logging.INFO) | ||
|
||
test_dims=[(3,27), (3,54), (4,32)] | ||
|
||
|
||
@pytest.mark.parametrize("dims",test_dims) | ||
@pytest.mark.parametrize("open_inds",[[0,1,2,3,4,5]]) | ||
@pytest.mark.parametrize("unroll",[True,False]) | ||
def test_profile_rdm2x3_loop_oe(dims, open_inds, unroll, benchmark): | ||
D,X= dims | ||
|
||
state= IPEPS({(0,0): torch.rand((2,)+(D,)*4,\ | ||
dtype=cfg.global_args.torch_dtype,device=cfg.global_args.device)-0.5}, lX=1, lY=1) | ||
env= ENV(X, state) | ||
init_random(env) | ||
|
||
print(f"{dims} {unroll}") | ||
benchmark.pedantic(rdm_mc.rdm2x3_loop_oe, args=((0,0), state, env, open_inds, unroll),\ | ||
iterations=1, rounds=2, warmup_rounds=1) | ||
|
||
@pytest.mark.parametrize("dims",test_dims) | ||
@pytest.mark.parametrize("open_inds",[[0,1,2,3,4,5]]) | ||
@pytest.mark.parametrize("unroll",[True,False]) | ||
def test_profile_rdm2x3_loop_oe_semimanual(dims, open_inds, unroll, benchmark): | ||
D,X= dims | ||
|
||
state= IPEPS({(0,0): torch.rand((2,)+(D,)*4,\ | ||
dtype=cfg.global_args.torch_dtype,device=cfg.global_args.device)-0.5}, lX=1, lY=1) | ||
env= ENV(X, state) | ||
init_random(env) | ||
|
||
print(f"{dims} {unroll}") | ||
benchmark.pedantic(rdm_mc.rdm2x3_loop_oe_semimanual, args=((0,0), state, env, open_inds, unroll),\ | ||
iterations=1, rounds=2, warmup_rounds=1) | ||
|
||
|
||
@pytest.mark.parametrize("dims",test_dims) | ||
def test_profile_rdm2x3_loop_manual(dims, benchmark): | ||
D,X= dims | ||
|
||
state= IPEPS({(0,0): torch.rand((2,)+(D,)*4,\ | ||
dtype=cfg.global_args.torch_dtype,device=cfg.global_args.device)-0.5}, lX=1, lY=1) | ||
env= ENV(X, state) | ||
init_random(env) | ||
|
||
benchmark.pedantic(rdm_mc.rdm2x3_loop, args=((0,0), state, env),\ | ||
iterations=1, rounds=2, warmup_rounds=1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import context | ||
import pytest | ||
import torch | ||
import config as cfg | ||
from ipeps.ipeps import IPEPS | ||
from ctm.generic.env import ENV, init_random | ||
from ctm.generic import rdm_mc | ||
|
||
test_dims=[(3,27), (3,54), (4,32), (4,64)] | ||
|
||
@pytest.mark.parametrize("dims",test_dims) | ||
@pytest.mark.parametrize("open_inds",[[2,3]]) | ||
@pytest.mark.parametrize("unroll",[True,False]) | ||
def test_profile_rdm2x3_loop_oe(dims, open_inds, unroll, benchmark): | ||
D,X= dims | ||
|
||
state= IPEPS({(0,0): torch.rand((2,)+(D,)*4,\ | ||
dtype=cfg.global_args.torch_dtype,device=cfg.global_args.device)-0.5}, lX=1, lY=1) | ||
env= ENV(X, state) | ||
init_random(env) | ||
|
||
print(f"{dims} {unroll}") | ||
benchmark.pedantic(rdm_mc.rdm2x3_loop_oe, args=((0,0), state, env, open_inds, unroll),\ | ||
iterations=1, rounds=2, warmup_rounds=1) | ||
|
||
@pytest.mark.parametrize("dims",test_dims) | ||
@pytest.mark.parametrize("open_inds",[[2,3]]) | ||
@pytest.mark.parametrize("unroll",[True,False]) | ||
def test_profile_rdm2x3_loop_oe_semimanual(dims, open_inds, unroll, benchmark): | ||
D,X= dims | ||
|
||
state= IPEPS({(0,0): torch.rand((2,)+(D,)*4,\ | ||
dtype=cfg.global_args.torch_dtype,device=cfg.global_args.device)-0.5}, lX=1, lY=1) | ||
env= ENV(X, state) | ||
init_random(env) | ||
|
||
print(f"{dims} {unroll}") | ||
benchmark.pedantic(rdm_mc.rdm2x3_loop_oe_semimanual, args=((0,0), state, env, open_inds, unroll),\ | ||
iterations=1, rounds=2, warmup_rounds=1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import context | ||
import pytest | ||
import torch | ||
import functools | ||
from time import perf_counter | ||
import config as cfg | ||
from ipeps.ipeps import IPEPS | ||
from ctm.generic.env import ENV, init_random | ||
from ctm.generic import rdm_mc | ||
|
||
import logging | ||
logging.basicConfig(filename=f"{__file__}.log", filemode='w', level=logging.INFO) | ||
|
||
test_dims=[(3,27), (3,54), (4,32), (4,64)] | ||
|
||
def optional_cuda_measure(tag): | ||
def _inner_optional_cuda_measure(f): | ||
@functools.wraps(f) | ||
def _wrap(*args,**kwargs): | ||
if not cfg.global_args.device=='cpu': torch.cuda.synchronize() | ||
t0= perf_counter() | ||
res= f(*args,**kwargs) | ||
if not cfg.global_args.device=='cpu': torch.cuda.synchronize() | ||
t1= perf_counter() | ||
logging.info(f"{tag} {t1-t0} [s]") | ||
return res | ||
return _wrap | ||
return _inner_optional_cuda_measure | ||
|
||
@pytest.mark.parametrize("dims",test_dims) | ||
@pytest.mark.parametrize("open_inds",[[1,2,3,4]]) | ||
@pytest.mark.parametrize("unroll",[True,False]) | ||
def test_profile_rdm2x3_loop_oe(dims, open_inds, unroll, benchmark): | ||
D,X= dims | ||
|
||
state= IPEPS({(0,0): torch.rand((2,)+(D,)*4,\ | ||
dtype=cfg.global_args.torch_dtype,device=cfg.global_args.device)-0.5}, lX=1, lY=1) | ||
env= ENV(X, state) | ||
init_random(env) | ||
|
||
@optional_cuda_measure(f"rdm2x3_loop_oe{dims} {open_inds} {unroll}") | ||
def test_f(): | ||
rdm_mc.rdm2x3_loop_oe((0,0), state, env, open_inds, unroll) | ||
|
||
print(f"{dims} {unroll}") | ||
benchmark.pedantic(test_f, args=(),\ | ||
iterations=1, rounds=2, warmup_rounds=1) | ||
|
||
@pytest.mark.parametrize("dims",test_dims) | ||
@pytest.mark.parametrize("open_inds",[[1,2,3,4]]) | ||
@pytest.mark.parametrize("unroll",[True,False]) | ||
def test_profile_rdm2x3_loop_oe_semimanual(dims, open_inds, unroll, benchmark): | ||
D,X= dims | ||
|
||
state= IPEPS({(0,0): torch.rand((2,)+(D,)*4,\ | ||
dtype=cfg.global_args.torch_dtype,device=cfg.global_args.device)-0.5}, lX=1, lY=1) | ||
env= ENV(X, state) | ||
init_random(env) | ||
|
||
@optional_cuda_measure(f"rdm2x3_loop_oe_semimanual{dims} {open_inds} {unroll}") | ||
def test_f(): | ||
rdm_mc.rdm2x3_loop_oe_semimanual((0,0), state, env, open_inds, unroll) | ||
|
||
print(f"{dims} {unroll}") | ||
benchmark.pedantic(test_f, args=(),\ | ||
iterations=1, rounds=2, warmup_rounds=1) | ||
|
||
|
||
@pytest.mark.parametrize("dims",test_dims) | ||
def test_profile_rdm2x3_loop_trglringex_manual(dims, benchmark): | ||
D,X= dims | ||
|
||
state= IPEPS({(0,0): torch.rand((2,)+(D,)*4,\ | ||
dtype=cfg.global_args.torch_dtype,device=cfg.global_args.device)-0.5}, lX=1, lY=1) | ||
env= ENV(X, state) | ||
init_random(env) | ||
|
||
@optional_cuda_measure(f"rdm2x3_loop_trglringex_manual_{dims}") | ||
def test_f(): | ||
rdm_mc.rdm2x3_loop_trglringex_manual((0,0), state, env) | ||
|
||
|
||
benchmark.pedantic(test_f, args=(),\ | ||
iterations=1, rounds=2, warmup_rounds=1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.