diff --git a/.gitignore b/.gitignore index 20fe29d..66d1d09 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ *.jl.mem /Manifest.toml /docs/build/ +*.log +docs/Manifest.toml diff --git a/Project.toml b/Project.toml index 33f008b..b99fb44 100644 --- a/Project.toml +++ b/Project.toml @@ -1,21 +1,32 @@ -name = "T4ATCIAlgorithms" -uuid = "afea4b4e-08e0-4d7c-9da1-dbc7777ac29f" -authors = ["Hiroshi Shinaoka and contributors"] +name = "T4AAdaptivePatchedTCI" +uuid = "36ff05ac-192f-4444-92c7-2a2992a7023b" version = "0.5.0" +authors = ["Hiroshi Shinaoka and contributors"] [deps] Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b" EllipsisNotation = "da5c29d0-fa7d-589e-88eb-ea29b0a81949" -ITensors = "9136182c-28ba-11e9-034c-db9fb085ebd5" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" +QuanticsGrids = "634c7f73-3e90-4749-a1bd-001b8efc642d" +T4APartitionedMPSs = "f7a3e09c-877e-4116-af24-45397c1413c2" T4AQuantics = "99202d80-6772-4c79-995b-f2660cf2bd6d" T4ATensorCI = "14428447-6903-48c7-83df-f2cb08af9918" TensorCrossInterpolation = "b261b2ec-6378-4871-b32e-9173bb050604" +[weakdeps] +ITensors = "9136182c-28ba-11e9-034c-db9fb085ebd5" +T4AITensorCompat = "864b39ca-388c-4f43-a593-a1076cf4b253" + +[extensions] +T4AAdaptivePatchedTCIITensorExt = ["ITensors", "T4AITensorCompat"] + [compat] EllipsisNotation = "1" OrderedCollections = "1" +QuanticsGrids = "0.6.0" +T4AITensorCompat = "0.6.0" +T4APartitionedMPSs = "0.7" T4AQuantics = "0.5" T4ATensorCI = "0.10" julia = "1.10" @@ -23,6 +34,7 @@ julia = "1.10" [extras] Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" HubbardAtoms = "4f3da25b-ea28-4d4f-a81f-380d3f5e56a6" +ITensors = "9136182c-28ba-11e9-034c-db9fb085ebd5" JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b" QuanticsGrids = "634c7f73-3e90-4749-a1bd-001b8efc642d" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" @@ -31,4 +43,4 @@ T4AITensorCompat = "864b39ca-388c-4f43-a593-a1076cf4b253" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["Aqua", "JET", "Test", "Random", "QuanticsGrids", "SparseIR", "HubbardAtoms", "T4AITensorCompat"] +test = ["Aqua", "JET", "Test", "Random", "QuanticsGrids", "SparseIR", "HubbardAtoms", "T4AITensorCompat", "ITensors"] diff --git a/README.md b/README.md index f25bc10..a58ba39 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# T4ATCIAlgorithms +# T4AAdaptivePatchedTCI -[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://tensor4all.github.io/T4ATCIAlgorithms.jl/dev) -[![CI](https://github.com/tensor4all/T4ATCIAlgorithms.jl/actions/workflows/CI.yml/badge.svg)](https://github.com/tensor4all/T4ATCIAlgorithms.jl/actions/workflows/CI.yml) +[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://tensor4all.github.io/T4AAdaptivePatchedTCI.jl/dev) +[![CI](https://github.com/tensor4all/T4AAdaptivePatchedTCI.jl/actions/workflows/CI.yml/badge.svg)](https://github.com/tensor4all/T4AAdaptivePatchedTCI.jl/actions/workflows/CI.yml) diff --git a/benchmark/matrxmul.jl b/benchmark/matrxmul.jl index 5208083..def0420 100644 --- a/benchmark/matrxmul.jl +++ b/benchmark/matrxmul.jl @@ -1,5 +1,5 @@ import T4ATensorCI as TCI -import T4ATCIAlgorithms as TCIA +import T4AAdaptivePatchedTCI as TCIA using BenchmarkTools using Random diff --git a/docs/Manifest.toml b/docs/Manifest.toml new file mode 100644 index 0000000..74df444 --- /dev/null +++ b/docs/Manifest.toml @@ -0,0 +1,1039 @@ +# This file is machine-generated - editing it directly is not advised + +julia_version = "1.12.1" +manifest_format = "2.0" +project_hash = "9c8cd014a10f27cfe5b4fd3241061a6668fe808b" + +[[deps.ANSIColoredPrinters]] +git-tree-sha1 = "574baf8110975760d391c710b6341da1afa48d8c" +uuid = "a4c015fc-c6ff-483c-b24f-f7ea428134e9" +version = "0.0.1" + +[[deps.AbstractTrees]] +git-tree-sha1 = "2d9c9a55f9c93e8887ad391fbae72f8ef55e1177" +uuid = "1520ce14-60c1-5f80-bbc7-55ef81b5835c" +version = "0.4.5" + +[[deps.Accessors]] +deps = ["CompositionsBase", "ConstructionBase", "Dates", "InverseFunctions", "MacroTools"] +git-tree-sha1 = "3b86719127f50670efe356bc11073d84b4ed7a5d" +uuid = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697" +version = "0.1.42" + + [deps.Accessors.extensions] + AxisKeysExt = "AxisKeys" + IntervalSetsExt = "IntervalSets" + LinearAlgebraExt = "LinearAlgebra" + StaticArraysExt = "StaticArrays" + StructArraysExt = "StructArrays" + TestExt = "Test" + UnitfulExt = "Unitful" + + [deps.Accessors.weakdeps] + AxisKeys = "94b1ba4f-4ee9-5380-92f1-94cde586c3c5" + IntervalSets = "8197267c-284f-5f27-9208-e0e47529a953" + LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" + StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" + StructArrays = "09ab397b-f2b6-538f-b94a-2f83cf4a842a" + Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" + Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" + +[[deps.Adapt]] +deps = ["LinearAlgebra", "Requires"] +git-tree-sha1 = "7e35fca2bdfba44d797c53dfe63a51fabf39bfc0" +uuid = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" +version = "4.4.0" +weakdeps = ["SparseArrays", "StaticArrays"] + + [deps.Adapt.extensions] + AdaptSparseArraysExt = "SparseArrays" + AdaptStaticArraysExt = "StaticArrays" + +[[deps.ArgCheck]] +git-tree-sha1 = "f9e9a66c9b7be1ad7372bbd9b062d9230c30c5ce" +uuid = "dce04be8-c92d-5529-be00-80e4d2c0e197" +version = "2.5.0" + +[[deps.ArgTools]] +uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f" +version = "1.1.2" + +[[deps.ArrayInterface]] +deps = ["Adapt", "LinearAlgebra"] +git-tree-sha1 = "d81ae5489e13bc03567d4fbbb06c546a5e53c857" +uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" +version = "7.22.0" + + [deps.ArrayInterface.extensions] + ArrayInterfaceBandedMatricesExt = "BandedMatrices" + ArrayInterfaceBlockBandedMatricesExt = "BlockBandedMatrices" + ArrayInterfaceCUDAExt = "CUDA" + ArrayInterfaceCUDSSExt = ["CUDSS", "CUDA"] + ArrayInterfaceChainRulesCoreExt = "ChainRulesCore" + ArrayInterfaceChainRulesExt = "ChainRules" + ArrayInterfaceGPUArraysCoreExt = "GPUArraysCore" + ArrayInterfaceMetalExt = "Metal" + ArrayInterfaceReverseDiffExt = "ReverseDiff" + ArrayInterfaceSparseArraysExt = "SparseArrays" + ArrayInterfaceStaticArraysCoreExt = "StaticArraysCore" + ArrayInterfaceTrackerExt = "Tracker" + + [deps.ArrayInterface.weakdeps] + BandedMatrices = "aae01518-5342-5314-be14-df237901396f" + BlockBandedMatrices = "ffab5731-97b5-5995-9138-79e8c1846df0" + CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" + CUDSS = "45b445bb-4962-46a0-9369-b4df9d0f772e" + ChainRules = "082447d4-558c-5d27-93f4-14fc19e9eca2" + ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" + GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527" + Metal = "dde4c033-4e86-420c-a63e-0dd931031962" + ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267" + SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" + StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c" + Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c" + +[[deps.ArrayLayouts]] +deps = ["FillArrays", "LinearAlgebra", "StaticArrays"] +git-tree-sha1 = "122a06c8266e00035bfa572887ab52c344526eb4" +uuid = "4c555306-a7a7-4459-81d9-ec55ddd5c99a" +version = "1.12.1" +weakdeps = ["SparseArrays"] + + [deps.ArrayLayouts.extensions] + ArrayLayoutsSparseArraysExt = "SparseArrays" + +[[deps.Artifacts]] +uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" +version = "1.11.0" + +[[deps.BangBang]] +deps = ["Accessors", "ConstructionBase", "InitialValues", "LinearAlgebra"] +git-tree-sha1 = "a49f9342fc60c2a2aaa4e0934f06755464fcf438" +uuid = "198e06fe-97b7-11e9-32a5-e1d131e6ad66" +version = "0.4.6" + + [deps.BangBang.extensions] + BangBangChainRulesCoreExt = "ChainRulesCore" + BangBangDataFramesExt = "DataFrames" + BangBangStaticArraysExt = "StaticArrays" + BangBangStructArraysExt = "StructArrays" + BangBangTablesExt = "Tables" + BangBangTypedTablesExt = "TypedTables" + + [deps.BangBang.weakdeps] + ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" + DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" + StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" + StructArrays = "09ab397b-f2b6-538f-b94a-2f83cf4a842a" + Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" + TypedTables = "9d95f2ec-7b3d-5a63-8d20-e2491e220bb9" + +[[deps.Base64]] +uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" +version = "1.11.0" + +[[deps.Baselet]] +git-tree-sha1 = "aebf55e6d7795e02ca500a689d326ac979aaf89e" +uuid = "9718e550-a3fa-408a-8086-8db961cd8217" +version = "0.1.1" + +[[deps.Bessels]] +git-tree-sha1 = "4435559dc39793d53a9e3d278e185e920b4619ef" +uuid = "0e736298-9ec6-45e8-9647-e4fc86a2fe38" +version = "0.2.8" + +[[deps.BitIntegers]] +deps = ["Random"] +git-tree-sha1 = "f98cfeaba814d9746617822032d50a31c9926604" +uuid = "c3b6d118-76ef-56ca-8cc7-ebb389d030a1" +version = "0.3.5" + +[[deps.BlockArrays]] +deps = ["ArrayLayouts", "FillArrays", "LinearAlgebra"] +git-tree-sha1 = "d06da0a776248b2cb4d8d3c3dd37222183d303eb" +uuid = "8e7c35d0-a365-5155-bbbb-fb81a777f24e" +version = "1.9.2" + + [deps.BlockArrays.extensions] + BlockArraysAdaptExt = "Adapt" + BlockArraysBandedMatricesExt = "BandedMatrices" + + [deps.BlockArrays.weakdeps] + Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" + BandedMatrices = "aae01518-5342-5314-be14-df237901396f" + +[[deps.ChainRulesCore]] +deps = ["Compat", "LinearAlgebra"] +git-tree-sha1 = "e4c6a16e77171a5f5e25e9646617ab1c276c5607" +uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" +version = "1.26.0" +weakdeps = ["SparseArrays"] + + [deps.ChainRulesCore.extensions] + ChainRulesCoreSparseArraysExt = "SparseArrays" + +[[deps.CodecZlib]] +deps = ["TranscodingStreams", "Zlib_jll"] +git-tree-sha1 = "962834c22b66e32aa10f7611c08c8ca4e20749a9" +uuid = "944b1d66-785c-5afd-91f1-9de20f533193" +version = "0.7.8" + +[[deps.CommonWorldInvalidations]] +git-tree-sha1 = "ae52d1c52048455e85a387fbee9be553ec2b68d0" +uuid = "f70d9fcc-98c5-4d4a-abd7-e4cdeebd8ca8" +version = "1.0.0" + +[[deps.Compat]] +deps = ["TOML", "UUIDs"] +git-tree-sha1 = "9d8a54ce4b17aa5bdce0ea5c34bc5e7c340d16ad" +uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" +version = "4.18.1" +weakdeps = ["Dates", "LinearAlgebra"] + + [deps.Compat.extensions] + CompatLinearAlgebraExt = "LinearAlgebra" + +[[deps.CompilerSupportLibraries_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae" +version = "1.3.0+1" + +[[deps.CompositionsBase]] +git-tree-sha1 = "802bb88cd69dfd1509f6670416bd4434015693ad" +uuid = "a33af91c-f02d-484b-be07-31d278c5ca2b" +version = "0.1.2" +weakdeps = ["InverseFunctions"] + + [deps.CompositionsBase.extensions] + CompositionsBaseInverseFunctionsExt = "InverseFunctions" + +[[deps.ConstructionBase]] +git-tree-sha1 = "b4b092499347b18a015186eae3042f72267106cb" +uuid = "187b0558-2788-49d3-abe0-74a17ed4e7c9" +version = "1.6.0" + + [deps.ConstructionBase.extensions] + ConstructionBaseIntervalSetsExt = "IntervalSets" + ConstructionBaseLinearAlgebraExt = "LinearAlgebra" + ConstructionBaseStaticArraysExt = "StaticArrays" + + [deps.ConstructionBase.weakdeps] + IntervalSets = "8197267c-284f-5f27-9208-e0e47529a953" + LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" + StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" + +[[deps.DataAPI]] +git-tree-sha1 = "abe83f3a2f1b857aac70ef8b269080af17764bbe" +uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a" +version = "1.16.0" + +[[deps.DataStructures]] +deps = ["OrderedCollections"] +git-tree-sha1 = "e357641bb3e0638d353c4b29ea0e40ea644066a6" +uuid = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" +version = "0.19.3" + +[[deps.DataValueInterfaces]] +git-tree-sha1 = "bfc1187b79289637fa0ef6d4436ebdfe6905cbd6" +uuid = "e2d170a0-9d28-54be-80f0-106bbe20a464" +version = "1.0.0" + +[[deps.Dates]] +deps = ["Printf"] +uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" +version = "1.11.0" + +[[deps.DefineSingletons]] +git-tree-sha1 = "0fba8b706d0178b4dc7fd44a96a92382c9065c2c" +uuid = "244e2a9f-e319-4986-a169-4d1fe445cd52" +version = "0.1.2" + +[[deps.Dictionaries]] +deps = ["Indexing", "Random", "Serialization"] +git-tree-sha1 = "a86af9c4c4f33e16a2b2ff43c2113b2f390081fa" +uuid = "85a47980-9c8c-11e8-2b9f-f7ca1fa99fb4" +version = "0.4.5" + +[[deps.Distributed]] +deps = ["Random", "Serialization", "Sockets"] +uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" +version = "1.11.0" + +[[deps.DocStringExtensions]] +git-tree-sha1 = "7442a5dfe1ebb773c29cc2962a8980f47221d76c" +uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" +version = "0.9.5" + +[[deps.Documenter]] +deps = ["ANSIColoredPrinters", "AbstractTrees", "Base64", "CodecZlib", "Dates", "DocStringExtensions", "Downloads", "Git", "IOCapture", "InteractiveUtils", "JSON", "Logging", "Markdown", "MarkdownAST", "Pkg", "PrecompileTools", "REPL", "RegistryInstances", "SHA", "TOML", "Test", "Unicode"] +git-tree-sha1 = "70c521ca3a23c576e12655d15963977c9766c26b" +uuid = "e30172f5-a6a5-5a46-863b-614d45cd2de4" +version = "1.16.0" + +[[deps.Downloads]] +deps = ["ArgTools", "FileWatching", "LibCURL", "NetworkOptions"] +uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6" +version = "1.6.0" + +[[deps.EllipsisNotation]] +deps = ["StaticArrayInterface"] +git-tree-sha1 = "3507300d4343e8e4ad080ad24e335274c2e297a9" +uuid = "da5c29d0-fa7d-589e-88eb-ea29b0a81949" +version = "1.8.0" + +[[deps.Expat_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "27af30de8b5445644e8ffe3bcb0d72049c089cf1" +uuid = "2e619515-83b5-522b-bb60-26c02a35a201" +version = "2.7.3+0" + +[[deps.ExprTools]] +git-tree-sha1 = "27415f162e6028e81c72b82ef756bf321213b6ec" +uuid = "e2ba6199-217a-4e67-a87a-7c52f15ade04" +version = "0.1.10" + +[[deps.ExternalDocstrings]] +git-tree-sha1 = "1224740fc4d07c989949e1c1b508ebd49a65a5f6" +uuid = "e189563c-0753-4f5e-ad5c-be4293c83fb4" +version = "0.1.1" + +[[deps.FileWatching]] +uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" +version = "1.11.0" + +[[deps.FillArrays]] +deps = ["LinearAlgebra"] +git-tree-sha1 = "5bfcd42851cf2f1b303f51525a54dc5e98d408a3" +uuid = "1a297f60-69ca-5386-bcde-b61e274b549b" +version = "1.15.0" + + [deps.FillArrays.extensions] + FillArraysPDMatsExt = "PDMats" + FillArraysSparseArraysExt = "SparseArrays" + FillArraysStatisticsExt = "Statistics" + + [deps.FillArrays.weakdeps] + PDMats = "90014a1f-27ba-587c-ab20-58faa44d9150" + SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" + Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" + +[[deps.Folds]] +deps = ["Accessors", "BangBang", "Baselet", "DefineSingletons", "Distributed", "ExternalDocstrings", "InitialValues", "MicroCollections", "Referenceables", "Requires", "Test", "ThreadedScans", "Transducers"] +git-tree-sha1 = "7eb4bc88d8295e387a667fd43d67c157ddee76cf" +uuid = "41a02a25-b8f0-4f67-bc48-60067656b558" +version = "0.2.10" + + [deps.Folds.extensions] + FoldsOnlineStatsBaseExt = "OnlineStatsBase" + + [deps.Folds.weakdeps] + OnlineStatsBase = "925886fa-5bf2-5e8e-b522-a9147a512338" + +[[deps.Functors]] +deps = ["Compat", "ConstructionBase", "LinearAlgebra", "Random"] +git-tree-sha1 = "60a0339f28a233601cb74468032b5c302d5067de" +uuid = "d9f16b24-f501-4c13-a1f2-28368ffc5196" +version = "0.5.2" + +[[deps.Future]] +deps = ["Random"] +uuid = "9fa8497b-333b-5362-9e8d-4d0656e87820" +version = "1.11.0" + +[[deps.GenericLinearAlgebra]] +deps = ["LinearAlgebra", "Printf", "Random", "libblastrampoline_jll"] +git-tree-sha1 = "fc6236b7fbc40bc283e0dc5a84ead1169a6d7dda" +uuid = "14197337-ba66-59df-a3e3-ca00e7dcff7a" +version = "0.3.19" + +[[deps.Git]] +deps = ["Git_LFS_jll", "Git_jll", "JLLWrappers", "OpenSSH_jll"] +git-tree-sha1 = "824a1890086880696fc908fe12a17bcf61738bd8" +uuid = "d7ba0133-e1db-5d97-8f8c-041e4b3a1eb2" +version = "1.5.0" + +[[deps.Git_LFS_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "bb8471f313ed941f299aa53d32a94ab3bee08844" +uuid = "020c3dae-16b3-5ae5-87b3-4cb189e250b2" +version = "3.7.0+0" + +[[deps.Git_jll]] +deps = ["Artifacts", "Expat_jll", "JLLWrappers", "LibCURL_jll", "Libdl", "Libiconv_jll", "OpenSSL_jll", "PCRE2_jll", "Zlib_jll"] +git-tree-sha1 = "b6a684587ebe896d9f68ae777f648205940f0f70" +uuid = "f8c6e375-362e-5223-8a59-34ff63f689eb" +version = "2.51.3+0" + +[[deps.HalfIntegers]] +git-tree-sha1 = "9c3149243abb5bc0bad0431d6c4fcac0f4443c7c" +uuid = "f0d1745a-41c9-11e9-1dd9-e5d34d218721" +version = "1.6.0" + +[[deps.IOCapture]] +deps = ["Logging", "Random"] +git-tree-sha1 = "0ee181ec08df7d7c911901ea38baf16f755114dc" +uuid = "b5f81e59-6552-4d32-b1f0-c071b021bf89" +version = "1.0.0" + +[[deps.ITensorMPS]] +deps = ["Adapt", "Compat", "ITensors", "IsApprox", "KrylovKit", "LinearAlgebra", "NDTensors", "Printf", "Random", "SerializedElementArrays", "TupleTools"] +git-tree-sha1 = "a45a71b629707b5a1f39cd225d1618a7376e1e88" +uuid = "0d1a4710-d33b-49a5-8f18-73bdf49b47e2" +version = "0.3.25" + + [deps.ITensorMPS.extensions] + ITensorMPSChainRulesCoreExt = "ChainRulesCore" + ITensorMPSHDF5Ext = "HDF5" + ITensorMPSObserversExt = "Observers" + ITensorMPSPackageCompilerExt = "PackageCompiler" + ITensorMPSZygoteRulesExt = ["ChainRulesCore", "ZygoteRules"] + + [deps.ITensorMPS.weakdeps] + ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" + HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f" + Observers = "338f10d5-c7f1-4033-a7d1-f9dec39bcaa0" + PackageCompiler = "9b87118b-4619-50d2-8e1e-99f35a4d4d9d" + ZygoteRules = "700de1a5-db45-46bc-99cf-38207098b444" + +[[deps.ITensors]] +deps = ["Adapt", "BitIntegers", "ChainRulesCore", "Compat", "Dictionaries", "DocStringExtensions", "Functors", "IsApprox", "LinearAlgebra", "NDTensors", "Pkg", "Printf", "Random", "Requires", "SerializedElementArrays", "SimpleTraits", "SparseArrays", "StaticArrays", "Strided", "TimerOutputs", "TupleTools", "Zeros"] +git-tree-sha1 = "8a4012a491ec92fa840ee119e258358b605a831e" +uuid = "9136182c-28ba-11e9-034c-db9fb085ebd5" +version = "0.9.15" + + [deps.ITensors.extensions] + ITensorsHDF5Ext = "HDF5" + ITensorsTensorOperationsExt = "TensorOperations" + ITensorsVectorInterfaceExt = "VectorInterface" + ITensorsZygoteRulesExt = "ZygoteRules" + + [deps.ITensors.weakdeps] + HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f" + TensorOperations = "6aa20fa7-93e2-5fca-9bc0-fbd0db3c71a2" + VectorInterface = "409d34a3-91d5-4945-b6ec-7529ddf182d8" + ZygoteRules = "700de1a5-db45-46bc-99cf-38207098b444" + +[[deps.IfElse]] +git-tree-sha1 = "debdd00ffef04665ccbb3e150747a77560e8fad1" +uuid = "615f187c-cbe4-4ef1-ba3b-2fcf58d6d173" +version = "0.1.1" + +[[deps.Indexing]] +git-tree-sha1 = "ce1566720fd6b19ff3411404d4b977acd4814f9f" +uuid = "313cdc1a-70c2-5d6a-ae34-0150d3930a38" +version = "1.1.1" + +[[deps.InitialValues]] +git-tree-sha1 = "4da0f88e9a39111c2fa3add390ab15f3a44f3ca3" +uuid = "22cec73e-a1b8-11e9-2c92-598750a2cf9c" +version = "0.3.1" + +[[deps.InlineStrings]] +git-tree-sha1 = "8f3d257792a522b4601c24a577954b0a8cd7334d" +uuid = "842dd82b-1e85-43dc-bf29-5d0ee9dffc48" +version = "1.4.5" + + [deps.InlineStrings.extensions] + ArrowTypesExt = "ArrowTypes" + ParsersExt = "Parsers" + + [deps.InlineStrings.weakdeps] + ArrowTypes = "31f734f8-188a-4ce0-8406-c8a06bd891cd" + Parsers = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" + +[[deps.InteractiveUtils]] +deps = ["Markdown"] +uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" +version = "1.11.0" + +[[deps.InverseFunctions]] +git-tree-sha1 = "a779299d77cd080bf77b97535acecd73e1c5e5cb" +uuid = "3587e190-3f89-42d0-90ee-14403ec27112" +version = "0.1.17" +weakdeps = ["Dates", "Test"] + + [deps.InverseFunctions.extensions] + InverseFunctionsDatesExt = "Dates" + InverseFunctionsTestExt = "Test" + +[[deps.IsApprox]] +deps = ["Dictionaries", "LinearAlgebra", "PrecompileTools"] +git-tree-sha1 = "597fa86ccb967c315dae711a83a234b28c0c6852" +uuid = "28f27b66-4bd8-47e7-9110-e2746eb8bed7" +version = "2.0.0" + +[[deps.IteratorInterfaceExtensions]] +git-tree-sha1 = "a3f24677c21f5bbe9d2a714f95dcd58337fb2856" +uuid = "82899510-4779-5014-852e-03e436cf321d" +version = "1.0.0" + +[[deps.JLLWrappers]] +deps = ["Artifacts", "Preferences"] +git-tree-sha1 = "0533e564aae234aff59ab625543145446d8b6ec2" +uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210" +version = "1.7.1" + +[[deps.JSON]] +deps = ["Dates", "Logging", "Parsers", "PrecompileTools", "StructUtils", "UUIDs", "Unicode"] +git-tree-sha1 = "5b6bb73f555bc753a6153deec3717b8904f5551c" +uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" +version = "1.3.0" + + [deps.JSON.extensions] + JSONArrowExt = ["ArrowTypes"] + + [deps.JSON.weakdeps] + ArrowTypes = "31f734f8-188a-4ce0-8406-c8a06bd891cd" + +[[deps.JuliaSyntaxHighlighting]] +deps = ["StyledStrings"] +uuid = "ac6e5ff7-fb65-4e79-a425-ec3bc9c03011" +version = "1.12.0" + +[[deps.KrylovKit]] +deps = ["LinearAlgebra", "PackageExtensionCompat", "Printf", "Random", "VectorInterface"] +git-tree-sha1 = "6dcba71deb016d646f1c1bcfcaacc764a198b8e6" +uuid = "0b1a1467-8014-51b9-945f-bf0ae24f4b77" +version = "0.10.2" +weakdeps = ["ChainRulesCore"] + + [deps.KrylovKit.extensions] + KrylovKitChainRulesCoreExt = "ChainRulesCore" + +[[deps.LazilyInitializedFields]] +git-tree-sha1 = "0f2da712350b020bc3957f269c9caad516383ee0" +uuid = "0e77f7df-68c5-4e49-93ce-4cd80f5598bf" +version = "1.3.0" + +[[deps.LibCURL]] +deps = ["LibCURL_jll", "MozillaCACerts_jll"] +uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21" +version = "0.6.4" + +[[deps.LibCURL_jll]] +deps = ["Artifacts", "LibSSH2_jll", "Libdl", "OpenSSL_jll", "Zlib_jll", "nghttp2_jll"] +uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0" +version = "8.11.1+1" + +[[deps.LibGit2]] +deps = ["LibGit2_jll", "NetworkOptions", "Printf", "SHA"] +uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" +version = "1.11.0" + +[[deps.LibGit2_jll]] +deps = ["Artifacts", "LibSSH2_jll", "Libdl", "OpenSSL_jll"] +uuid = "e37daf67-58a4-590a-8e99-b0245dd2ffc5" +version = "1.9.0+0" + +[[deps.LibSSH2_jll]] +deps = ["Artifacts", "Libdl", "OpenSSL_jll"] +uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8" +version = "1.11.3+1" + +[[deps.Libdl]] +uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" +version = "1.11.0" + +[[deps.Libiconv_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "be484f5c92fad0bd8acfef35fe017900b0b73809" +uuid = "94ce4f54-9a6c-5748-9c1c-f9c7231a4531" +version = "1.18.0+0" + +[[deps.LinearAlgebra]] +deps = ["Libdl", "OpenBLAS_jll", "libblastrampoline_jll"] +uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +version = "1.12.0" + +[[deps.Logging]] +uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" +version = "1.11.0" + +[[deps.MacroTools]] +git-tree-sha1 = "1e0228a030642014fe5cfe68c2c0a818f9e3f522" +uuid = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09" +version = "0.5.16" + +[[deps.Markdown]] +deps = ["Base64", "JuliaSyntaxHighlighting", "StyledStrings"] +uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" +version = "1.11.0" + +[[deps.MarkdownAST]] +deps = ["AbstractTrees", "Markdown"] +git-tree-sha1 = "465a70f0fc7d443a00dcdc3267a497397b8a3899" +uuid = "d0879d2d-cac2-40c8-9cee-1863dc0c7391" +version = "0.1.2" + +[[deps.MicroCollections]] +deps = ["Accessors", "BangBang", "InitialValues"] +git-tree-sha1 = "44d32db644e84c75dab479f1bc15ee76a1a3618f" +uuid = "128add7d-3638-4c79-886c-908ea0c25c34" +version = "0.2.0" + +[[deps.MozillaCACerts_jll]] +uuid = "14a3606d-f60d-562e-9121-12d972cd8159" +version = "2025.5.20" + +[[deps.MultiFloats]] +deps = ["LinearAlgebra", "Printf", "Random", "SIMD"] +git-tree-sha1 = "39ffa6286f40544ecea725d8031c615e79d88d45" +uuid = "bdf0d083-296b-4888-a5b6-7498122e68a5" +version = "2.3.0" + +[[deps.NDTensors]] +deps = ["Accessors", "Adapt", "ArrayLayouts", "BlockArrays", "Compat", "Dictionaries", "EllipsisNotation", "FillArrays", "Folds", "Functors", "HalfIntegers", "InlineStrings", "LinearAlgebra", "MacroTools", "Random", "SimpleTraits", "SparseArrays", "SplitApplyCombine", "StaticArrays", "Strided", "StridedViews", "TimerOutputs", "TupleTools", "VectorInterface"] +git-tree-sha1 = "52c24862d467d8240ae605dda25cf41a4255638d" +uuid = "23ae76d9-e61a-49c4-8f12-3f1a16adf9cf" +version = "0.4.16" + + [deps.NDTensors.extensions] + NDTensorsAMDGPUExt = ["AMDGPU", "GPUArraysCore"] + NDTensorsCUDAExt = ["CUDA", "GPUArraysCore"] + NDTensorsGPUArraysCoreExt = "GPUArraysCore" + NDTensorsHDF5Ext = "HDF5" + NDTensorsJLArraysExt = ["GPUArraysCore", "JLArrays"] + NDTensorsMappedArraysExt = ["MappedArrays"] + NDTensorsMetalExt = ["GPUArraysCore", "Metal"] + NDTensorsOctavianExt = "Octavian" + NDTensorsTBLISExt = "TBLIS" + NDTensorscuTENSORExt = "cuTENSOR" + + [deps.NDTensors.weakdeps] + AMDGPU = "21141c5a-9bdb-4563-92ae-f87d6854732e" + CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" + GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527" + HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f" + JLArrays = "27aeb0d3-9eb9-45fb-866b-73c2ecf80fcb" + MappedArrays = "dbb5928d-eab1-5f90-85c2-b9b0edb7c900" + Metal = "dde4c033-4e86-420c-a63e-0dd931031962" + Octavian = "6fd5a793-0b7e-452c-907f-f8bfe9c57db4" + TBLIS = "48530278-0828-4a49-9772-0f3830dfa1e9" + cuTENSOR = "011b41b2-24ef-40a8-b3eb-fa098493e9e1" + +[[deps.NetworkOptions]] +uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908" +version = "1.3.0" + +[[deps.OpenBLAS_jll]] +deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"] +uuid = "4536629a-c528-5b80-bd46-f80d51c5b363" +version = "0.3.29+0" + +[[deps.OpenSSH_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "OpenSSL_jll", "Zlib_jll"] +git-tree-sha1 = "301412a644646fdc0ad67d0a87487466b491e53d" +uuid = "9bd350c2-7e96-507f-8002-3f2e150b4e1b" +version = "10.2.1+0" + +[[deps.OpenSSL_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "458c3c95-2e84-50aa-8efc-19380b2a3a95" +version = "3.5.1+0" + +[[deps.OrderedCollections]] +git-tree-sha1 = "05868e21324cede2207c6f0f466b4bfef6d5e7ee" +uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" +version = "1.8.1" + +[[deps.PCRE2_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "efcefdf7-47ab-520b-bdef-62a2eaa19f15" +version = "10.44.0+1" + +[[deps.PackageExtensionCompat]] +git-tree-sha1 = "fb28e33b8a95c4cee25ce296c817d89cc2e53518" +uuid = "65ce6f38-6b18-4e1d-a461-8949797d7930" +version = "1.0.2" +weakdeps = ["Requires", "TOML"] + +[[deps.Parsers]] +deps = ["Dates", "PrecompileTools", "UUIDs"] +git-tree-sha1 = "7d2f8f21da5db6a806faf7b9b292296da42b2810" +uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" +version = "2.8.3" + +[[deps.Pkg]] +deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "Random", "SHA", "TOML", "Tar", "UUIDs", "p7zip_jll"] +uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" +version = "1.12.0" +weakdeps = ["REPL"] + + [deps.Pkg.extensions] + REPLExt = "REPL" + +[[deps.PrecompileTools]] +deps = ["Preferences"] +git-tree-sha1 = "07a921781cab75691315adc645096ed5e370cb77" +uuid = "aea7be01-6a6a-4083-8856-8a6e6704d82a" +version = "1.3.3" + +[[deps.Preferences]] +deps = ["TOML"] +git-tree-sha1 = "0f27480397253da18fe2c12a4ba4eb9eb208bf3d" +uuid = "21216c6a-2e73-6563-6e65-726566657250" +version = "1.5.0" + +[[deps.Printf]] +deps = ["Unicode"] +uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" +version = "1.11.0" + +[[deps.QuadGK]] +deps = ["DataStructures", "LinearAlgebra"] +git-tree-sha1 = "9da16da70037ba9d701192e27befedefb91ec284" +uuid = "1fd47b50-473d-5c70-9696-f719f8f3bcdc" +version = "2.11.2" + + [deps.QuadGK.extensions] + QuadGKEnzymeExt = "Enzyme" + + [deps.QuadGK.weakdeps] + Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9" + +[[deps.QuanticsGrids]] +deps = ["LinearAlgebra"] +git-tree-sha1 = "0c5dbd9716d5a5a0c4f5579e78b26b7bda6160d2" +uuid = "634c7f73-3e90-4749-a1bd-001b8efc642d" +version = "0.6.0" + +[[deps.QuanticsTCI]] +deps = ["BitIntegers", "LinearAlgebra", "QuanticsGrids", "TensorCrossInterpolation"] +git-tree-sha1 = "512a9f72a7422da484f88624aafbd268afd9b027" +uuid = "b11687fd-3a1c-4c41-97d0-998ab401d50e" +version = "0.7.2" + +[[deps.REPL]] +deps = ["InteractiveUtils", "JuliaSyntaxHighlighting", "Markdown", "Sockets", "StyledStrings", "Unicode"] +uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" +version = "1.11.0" + +[[deps.Random]] +deps = ["SHA"] +uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" +version = "1.11.0" + +[[deps.Referenceables]] +deps = ["Adapt"] +git-tree-sha1 = "02d31ad62838181c1a3a5fd23a1ce5914a643601" +uuid = "42d2dcc6-99eb-4e98-b66c-637b7d73030e" +version = "0.1.3" + +[[deps.RegistryInstances]] +deps = ["LazilyInitializedFields", "Pkg", "TOML", "Tar"] +git-tree-sha1 = "ffd19052caf598b8653b99404058fce14828be51" +uuid = "2792f1a3-b283-48e8-9a74-f99dce5104f3" +version = "0.1.0" + +[[deps.Requires]] +deps = ["UUIDs"] +git-tree-sha1 = "62389eeff14780bfe55195b7204c0d8738436d64" +uuid = "ae029012-a4dd-5104-9daa-d747884805df" +version = "1.3.1" + +[[deps.SHA]] +uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" +version = "0.7.0" + +[[deps.SIMD]] +deps = ["PrecompileTools"] +git-tree-sha1 = "e24dc23107d426a096d3eae6c165b921e74c18e4" +uuid = "fdea26ae-647d-5447-a871-4b548cad5224" +version = "3.7.2" + +[[deps.SciMLPublic]] +git-tree-sha1 = "ed647f161e8b3f2973f24979ec074e8d084f1bee" +uuid = "431bcebd-1456-4ced-9d72-93c2757fff0b" +version = "1.0.0" + +[[deps.Serialization]] +uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" +version = "1.11.0" + +[[deps.SerializedElementArrays]] +deps = ["Serialization"] +git-tree-sha1 = "8e73e49eaebf73486446a3c1eede403bff259826" +uuid = "d3ce8812-9567-47e9-a7b5-65a6d70a3065" +version = "0.1.0" + +[[deps.Setfield]] +deps = ["ConstructionBase", "Future", "MacroTools", "StaticArraysCore"] +git-tree-sha1 = "c5391c6ace3bc430ca630251d02ea9687169ca68" +uuid = "efcf1570-3423-57d1-acb7-fd33fddbac46" +version = "1.1.2" + +[[deps.SimpleTraits]] +deps = ["InteractiveUtils", "MacroTools"] +git-tree-sha1 = "be8eeac05ec97d379347584fa9fe2f5f76795bcb" +uuid = "699a6c99-e7fa-54fc-8d76-47d257e15c1d" +version = "0.9.5" + +[[deps.Sockets]] +uuid = "6462fe0b-24de-5631-8697-dd941f90decc" +version = "1.11.0" + +[[deps.SparseArrays]] +deps = ["Libdl", "LinearAlgebra", "Random", "Serialization", "SuiteSparse_jll"] +uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" +version = "1.12.0" + +[[deps.SparseIR]] +deps = ["Bessels", "GenericLinearAlgebra", "LinearAlgebra", "MultiFloats", "PrecompileTools", "QuadGK"] +git-tree-sha1 = "175036112d3e0ff85e967ae1919b33fefa0cb637" +uuid = "4fe2279e-80f0-4adb-8463-ee114ff56b7d" +version = "1.1.4" + +[[deps.SplitApplyCombine]] +deps = ["Dictionaries", "Indexing"] +git-tree-sha1 = "c06d695d51cfb2187e6848e98d6252df9101c588" +uuid = "03a91e81-4c3e-53e1-a0a4-9c0c8f19dd66" +version = "1.2.3" + +[[deps.SplittablesBase]] +deps = ["Setfield", "Test"] +git-tree-sha1 = "e08a62abc517eb79667d0a29dc08a3b589516bb5" +uuid = "171d559e-b47b-412a-8079-5efa626c420e" +version = "0.1.15" + +[[deps.Static]] +deps = ["CommonWorldInvalidations", "IfElse", "PrecompileTools", "SciMLPublic"] +git-tree-sha1 = "49440414711eddc7227724ae6e570c7d5559a086" +uuid = "aedffcd0-7271-4cad-89d0-dc628f76c6d3" +version = "1.3.1" + +[[deps.StaticArrayInterface]] +deps = ["ArrayInterface", "Compat", "IfElse", "LinearAlgebra", "PrecompileTools", "Static"] +git-tree-sha1 = "96381d50f1ce85f2663584c8e886a6ca97e60554" +uuid = "0d7ed370-da01-4f52-bd93-41d350b8b718" +version = "1.8.0" + + [deps.StaticArrayInterface.extensions] + StaticArrayInterfaceOffsetArraysExt = "OffsetArrays" + StaticArrayInterfaceStaticArraysExt = "StaticArrays" + + [deps.StaticArrayInterface.weakdeps] + OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881" + StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" + +[[deps.StaticArrays]] +deps = ["LinearAlgebra", "PrecompileTools", "Random", "StaticArraysCore"] +git-tree-sha1 = "b8693004b385c842357406e3af647701fe783f98" +uuid = "90137ffa-7385-5640-81b9-e52037218182" +version = "1.9.15" + + [deps.StaticArrays.extensions] + StaticArraysChainRulesCoreExt = "ChainRulesCore" + StaticArraysStatisticsExt = "Statistics" + + [deps.StaticArrays.weakdeps] + ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" + Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" + +[[deps.StaticArraysCore]] +git-tree-sha1 = "6ab403037779dae8c514bad259f32a447262455a" +uuid = "1e83bf80-4336-4d27-bf5d-d5a4f845583c" +version = "1.4.4" + +[[deps.Strided]] +deps = ["LinearAlgebra", "StridedViews", "TupleTools"] +git-tree-sha1 = "c2e72c33ac8871d104901db736aecb36b223f10c" +uuid = "5e0ebb24-38b0-5f93-81fe-25c709ecae67" +version = "2.3.2" + +[[deps.StridedViews]] +deps = ["LinearAlgebra", "PackageExtensionCompat"] +git-tree-sha1 = "425158c52aa58d42593be6861befadf8b2541e9b" +uuid = "4db3bf67-4bd7-4b4e-b153-31dc3fb37143" +version = "0.4.1" + + [deps.StridedViews.extensions] + StridedViewsCUDAExt = "CUDA" + StridedViewsPtrArraysExt = "PtrArrays" + + [deps.StridedViews.weakdeps] + CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" + PtrArrays = "43287f4e-b6f4-7ad1-bb20-aadabca52c3d" + +[[deps.StructUtils]] +deps = ["Dates", "UUIDs"] +git-tree-sha1 = "79529b493a44927dd5b13dde1c7ce957c2d049e4" +uuid = "ec057cc2-7a8d-4b58-b3b3-92acb9f63b42" +version = "2.6.0" + + [deps.StructUtils.extensions] + StructUtilsMeasurementsExt = ["Measurements"] + StructUtilsTablesExt = ["Tables"] + + [deps.StructUtils.weakdeps] + Measurements = "eff96d63-e80a-5855-80a2-b1b0885c5ab7" + Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" + +[[deps.StyledStrings]] +uuid = "f489334b-da3d-4c2e-b8f0-e476e12c162b" +version = "1.11.0" + +[[deps.SuiteSparse_jll]] +deps = ["Artifacts", "Libdl", "libblastrampoline_jll"] +uuid = "bea87d4a-7f5b-5778-9afe-8cc45184846c" +version = "7.8.3+2" + +[[deps.T4AAdaptivePatchedTCI]] +deps = ["Distributed", "EllipsisNotation", "ITensors", "LinearAlgebra", "OrderedCollections", "QuanticsGrids", "T4AITensorCompat", "T4APartitionedMPSs", "T4AQuantics", "T4ATensorCI", "TensorCrossInterpolation"] +path = ".." +uuid = "36ff05ac-192f-4444-92c7-2a2992a7023b" +version = "0.5.0" + +[[deps.T4AITensorCompat]] +deps = ["ITensorMPS", "ITensors", "LinearAlgebra", "Random"] +git-tree-sha1 = "d4675d3498b844ab47e27ad0562c6befff088011" +uuid = "864b39ca-388c-4f43-a593-a1076cf4b253" +version = "0.6.0" + +[[deps.T4APartitionedMPSs]] +deps = ["Distributed", "EllipsisNotation", "ITensors", "LinearAlgebra", "OrderedCollections", "T4AITensorCompat"] +git-tree-sha1 = "8a8782e01f38123b3064de99987c82b558b43698" +uuid = "f7a3e09c-877e-4116-af24-45397c1413c2" +version = "0.7.3" + +[[deps.T4AQuantics]] +deps = ["EllipsisNotation", "ITensors", "LinearAlgebra", "QuanticsTCI", "SparseArrays", "SparseIR", "StaticArrays", "T4AITensorCompat", "T4APartitionedMPSs", "TensorCrossInterpolation"] +git-tree-sha1 = "40c63cba52ad1e70020bea9d02bb9c047f78724a" +uuid = "99202d80-6772-4c79-995b-f2660cf2bd6d" +version = "0.5.0" + +[[deps.T4ATensorCI]] +deps = ["BitIntegers", "EllipsisNotation", "LinearAlgebra", "QuadGK", "Random"] +git-tree-sha1 = "6a7004766b7f63ed4ccc9081b640bc560cc4e054" +uuid = "14428447-6903-48c7-83df-f2cb08af9918" +version = "0.10.0" +weakdeps = ["ITensorMPS", "ITensors"] + + [deps.T4ATensorCI.extensions] + TCIITensorConversion = ["ITensors", "ITensorMPS"] + +[[deps.TOML]] +deps = ["Dates"] +uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76" +version = "1.0.3" + +[[deps.TableTraits]] +deps = ["IteratorInterfaceExtensions"] +git-tree-sha1 = "c06b2f539df1c6efa794486abfb6ed2022561a39" +uuid = "3783bdb8-4a98-5b6b-af9a-565f29a5fe9c" +version = "1.0.1" + +[[deps.Tables]] +deps = ["DataAPI", "DataValueInterfaces", "IteratorInterfaceExtensions", "OrderedCollections", "TableTraits"] +git-tree-sha1 = "f2c1efbc8f3a609aadf318094f8fc5204bdaf344" +uuid = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" +version = "1.12.1" + +[[deps.Tar]] +deps = ["ArgTools", "SHA"] +uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e" +version = "1.10.0" + +[[deps.TensorCrossInterpolation]] +deps = ["BitIntegers", "EllipsisNotation", "LinearAlgebra", "QuadGK", "Random"] +git-tree-sha1 = "7d2b129394b1f92f01f02c35deadf1f96a7e85af" +uuid = "b261b2ec-6378-4871-b32e-9173bb050604" +version = "0.9.18" +weakdeps = ["ITensorMPS", "ITensors"] + + [deps.TensorCrossInterpolation.extensions] + TCIITensorConversion = ["ITensors", "ITensorMPS"] + +[[deps.Test]] +deps = ["InteractiveUtils", "Logging", "Random", "Serialization"] +uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" +version = "1.11.0" + +[[deps.ThreadedScans]] +deps = ["ArgCheck"] +git-tree-sha1 = "ca1ba3000289eacba571aaa4efcefb642e7a1de6" +uuid = "24d252fe-5d94-4a69-83ea-56a14333d47a" +version = "0.1.0" + +[[deps.TimerOutputs]] +deps = ["ExprTools", "Printf"] +git-tree-sha1 = "3748bd928e68c7c346b52125cf41fff0de6937d0" +uuid = "a759f4b9-e2f1-59dc-863e-4aeb61b1ea8f" +version = "0.5.29" + + [deps.TimerOutputs.extensions] + FlameGraphsExt = "FlameGraphs" + + [deps.TimerOutputs.weakdeps] + FlameGraphs = "08572546-2f56-4bcf-ba4e-bab62c3a3f89" + +[[deps.TranscodingStreams]] +git-tree-sha1 = "0c45878dcfdcfa8480052b6ab162cdd138781742" +uuid = "3bb67fe8-82b1-5028-8e26-92a6c54297fa" +version = "0.11.3" + +[[deps.Transducers]] +deps = ["Accessors", "ArgCheck", "BangBang", "Baselet", "CompositionsBase", "ConstructionBase", "DefineSingletons", "Distributed", "InitialValues", "Logging", "Markdown", "MicroCollections", "SplittablesBase", "Tables"] +git-tree-sha1 = "4aa1fdf6c1da74661f6f5d3edfd96648321dade9" +uuid = "28d57a85-8fef-5791-bfe6-a80928e7c999" +version = "0.4.85" + + [deps.Transducers.extensions] + TransducersAdaptExt = "Adapt" + TransducersBlockArraysExt = "BlockArrays" + TransducersDataFramesExt = "DataFrames" + TransducersLazyArraysExt = "LazyArrays" + TransducersOnlineStatsBaseExt = "OnlineStatsBase" + TransducersReferenceablesExt = "Referenceables" + + [deps.Transducers.weakdeps] + Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" + BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e" + DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" + LazyArrays = "5078a376-72f3-5289-bfd5-ec5146d43c02" + OnlineStatsBase = "925886fa-5bf2-5e8e-b522-a9147a512338" + Referenceables = "42d2dcc6-99eb-4e98-b66c-637b7d73030e" + +[[deps.TupleTools]] +git-tree-sha1 = "41e43b9dc950775eac654b9f845c839cd2f1821e" +uuid = "9d95972d-f1c8-5527-a6e0-b4b365fa01f6" +version = "1.6.0" + +[[deps.UUIDs]] +deps = ["Random", "SHA"] +uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" +version = "1.11.0" + +[[deps.Unicode]] +uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" +version = "1.11.0" + +[[deps.VectorInterface]] +deps = ["LinearAlgebra"] +git-tree-sha1 = "9166406dedd38c111a6574e9814be83d267f8aec" +uuid = "409d34a3-91d5-4945-b6ec-7529ddf182d8" +version = "0.5.0" + +[[deps.Zeros]] +git-tree-sha1 = "60135f9a7bbcc3758ab7025f439f30067bdb9d5a" +uuid = "bd1ec220-6eb4-527a-9b49-e79c3db6233b" +version = "0.4.0" + +[[deps.Zlib_jll]] +deps = ["Libdl"] +uuid = "83775a58-1f1d-513f-b197-d71354ab007a" +version = "1.3.1+2" + +[[deps.libblastrampoline_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "8e850b90-86db-534c-a0d3-1478176c7d93" +version = "5.15.0+0" + +[[deps.nghttp2_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" +version = "1.64.0+1" + +[[deps.p7zip_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" +version = "17.5.0+2" diff --git a/docs/Project.toml b/docs/Project.toml index d9e7ba8..f25dff1 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -1,3 +1,3 @@ [deps] Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" -T4ATCIAlgorithms = "afea4b4e-08e0-4d7c-9da1-dbc7777ac29f" +T4AAdaptivePatchedTCI = "36ff05ac-192f-4444-92c7-2a2992a7023b" diff --git a/docs/make.jl b/docs/make.jl index e9f6cd3..33c4191 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -1,18 +1,20 @@ -using T4ATCIAlgorithms +using T4AAdaptivePatchedTCI using Documenter -DocMeta.setdocmeta!(T4ATCIAlgorithms, :DocTestSetup, :(using T4ATCIAlgorithms); recursive=true) +DocMeta.setdocmeta!( + T4AAdaptivePatchedTCI, :DocTestSetup, :(using T4AAdaptivePatchedTCI); recursive=true +) makedocs(; - modules=[T4ATCIAlgorithms], + modules=[T4AAdaptivePatchedTCI], authors="Hiroshi Shinaoka and contributors", - sitename="T4ATCIAlgorithms.jl", + sitename="T4AAdaptivePatchedTCI.jl", format=Documenter.HTML(; - canonical="https://github.com/tensor4all/T4ATCIAlgorithms.jl", + canonical="https://github.com/tensor4all/T4AAdaptivePatchedTCI.jl", edit_link="main", assets=String[], ), pages=["Home" => "index.md"], ) -deploydocs(; repo="github.com/tensor4all/T4ATCIAlgorithms.jl.git", devbranch="main") +deploydocs(; repo="github.com/tensor4all/T4AAdaptivePatchedTCI.jl.git", devbranch="main") diff --git a/docs/src/index.md b/docs/src/index.md index abf5f6f..f3f92e7 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -1,14 +1,14 @@ ```@meta -CurrentModule = T4ATCIAlgorithms +CurrentModule = T4AAdaptivePatchedTCI ``` -# T4ATCIAlgorithms +# T4AAdaptivePatchedTCI -Documentation for [T4ATCIAlgorithms](https://github.com/tensor4all/T4ATCIAlgorithms.jl). +Documentation for [T4AAdaptivePatchedTCI](https://github.com/tensor4all/T4AAdaptivePatchedTCI.jl). ```@index ``` ```@autodocs -Modules = [T4ATCIAlgorithms] +Modules = [T4AAdaptivePatchedTCI] ``` diff --git a/ext/T4AAdaptivePatchedTCIITensorExt/T4AAdaptivePatchedTCIITensorExt.jl b/ext/T4AAdaptivePatchedTCIITensorExt/T4AAdaptivePatchedTCIITensorExt.jl new file mode 100644 index 0000000..a3faa22 --- /dev/null +++ b/ext/T4AAdaptivePatchedTCIITensorExt/T4AAdaptivePatchedTCIITensorExt.jl @@ -0,0 +1,14 @@ +module T4AAdaptivePatchedTCIITensorExt + +using T4AAdaptivePatchedTCI: T4AAdaptivePatchedTCI +import T4AAdaptivePatchedTCI: + Projector, ProjTensorTrain, ProjTTContainer, MultiIndex, MMultiIndex, multii +import T4APartitionedMPSs: SubDomainMPS, PartitionedMPS, Projector as PartitionedProjector +import T4AITensorCompat: TensorTrain as ITensorTensorTrain, MPS, siteinds, linkinds +import T4ATensorCI as TCI +using ITensors + +# Include the ITensor compatibility code +include(joinpath(@__DIR__, "itensor.jl")) + +end diff --git a/ext/T4AAdaptivePatchedTCIITensorExt/itensor.jl b/ext/T4AAdaptivePatchedTCIITensorExt/itensor.jl new file mode 100644 index 0000000..d911fbf --- /dev/null +++ b/ext/T4AAdaptivePatchedTCIITensorExt/itensor.jl @@ -0,0 +1,288 @@ +# Conversion function from ProjTensorTrain to SubDomainMPS +function SubDomainMPS(::Type{T}, projtt::ProjTensorTrain{T}, sites) where {T} + # Convert ProjTensorTrain to TensorTrain (T4AITensorCompat) + tt_itensor = _convert_TCI_TensorTrain_to_ITensorTensorTrain(projtt.data, sites, T) + # Convert T4AAdaptivePatchedTCI.Projector to T4APartitionedMPSs.Projector + partitioned_projector = _convert_projector(projtt.projector, sites) + # Create SubDomainMPS + return SubDomainMPS(tt_itensor, partitioned_projector) +end + +# Convert T4AAdaptivePatchedTCI.Projector to T4APartitionedMPSs.Projector +function _convert_projector(proj::Projector, sites::AbstractVector{<:AbstractVector}) + proj_dict = Dict{Index,Int}() + for (site_idx, site_vec) in enumerate(sites) + for (leg_idx, index) in enumerate(site_vec) + proj_val = proj.data[site_idx][leg_idx] + if proj_val > 0 + proj_dict[index] = proj_val + end + end + end + return PartitionedProjector(proj_dict) +end + +# Helper function to convert TCI.TensorTrain to T4AITensorCompat.TensorTrain +function _convert_TCI_TensorTrain_to_ITensorTensorTrain( + tt_tci::TCI.TensorTrain{T,3}, sites::AbstractVector{<:AbstractVector}, ::Type{T} +) where {T} + N = length(tt_tci) + length(sites) == N || + error("Length mismatch: sites ($(length(sites))) != TensorTrain ($N)") + + # Create link indices + linkdims = TCI.linkdims(tt_tci) + links = [Index(ld, "Link,l=$l") for (l, ld) in enumerate(linkdims)] + + # Convert each tensor core to ITensor + tensors = ITensor[] + for n in 1:N + core = tt_tci[n] + if n == 1 + # First tensor: (1, physical..., link[1]) + tensor = ITensor(core, sites[n]..., links[1]) + elseif n == N + # Last tensor: (link[end], physical...) + tensor = ITensor(core, links[end], sites[n]...) + else + # Middle tensors: (link[n-1], physical..., link[n]) + tensor = ITensor(core, links[n - 1], sites[n]..., links[n]) + end + push!(tensors, tensor) + end + + return ITensorTensorTrain(tensors) +end + +# Conversion Functions +# MPS(subdmps::SubDomainMPS) is already defined in T4APartitionedMPSs +# subdmps.data is already T4AITensorCompat.TensorTrain = MPS + +function ProjTensorTrain{T}(subdmps::SubDomainMPS) where {T} + # Convert SubDomainMPS.data (TensorTrain from T4AITensorCompat) to TCI.TensorTrain + tt_tci = _convert_ITensorTensorTrain_to_TCI_TensorTrain(subdmps.data, T) + # Convert T4APartitionedMPSs.Projector to T4AAdaptivePatchedTCI.Projector + # This requires sites information, which we can get from siteinds + sites = siteinds(subdmps) + proj = _convert_partitioned_projector_to_projector(subdmps.projector, sites) + return ProjTensorTrain{T}(tt_tci, proj) +end + +# Convert T4APartitionedMPSs.Projector to T4AAdaptivePatchedTCI.Projector +function _convert_partitioned_projector_to_projector( + part_proj::PartitionedProjector, sites::AbstractVector{<:AbstractVector} +) + data = Vector{Vector{Int}}() + sitedims = Vector{Vector{Int}}() + for site_vec in sites + proj_vec = Int[] + dim_vec = Int[] + for index in site_vec + push!(dim_vec, dim(index)) + proj_val = get(part_proj.data, index, 0) + push!(proj_vec, proj_val) + end + push!(data, proj_vec) + push!(sitedims, dim_vec) + end + return Projector(data, sitedims) +end + +function ProjTTContainer{T}(partmps::PartitionedMPS) where {T} + projtt_vec = ProjTensorTrain{T}[] + for subdmps in values(partmps.data) + push!(projtt_vec, ProjTensorTrain{T}(subdmps)) + end + return ProjTTContainer(projtt_vec) +end + +# Helper function to convert T4AITensorCompat.TensorTrain to TCI.TensorTrain +function _convert_ITensorTensorTrain_to_TCI_TensorTrain( + tt_itensor::ITensorTensorTrain, ::Type{T} +) where {T} + # Extract sites and convert ITensors to arrays + sites = siteinds(tt_itensor) + tensors = Array{T,3}[] + links = linkinds(tt_itensor) + + for (n, tensor) in enumerate(tt_itensor) + site_inds = sites[n] + # Convert ITensor to array + if n == 1 + inds_list = vcat(site_inds, [links[1]]) + arr = Array(tensor, inds_list...) + push!(tensors, reshape(arr, 1, :, last(size(arr)))) + elseif n == length(tt_itensor) + inds_list = vcat([links[end]], site_inds) + arr = Array(tensor, inds_list...) + push!(tensors, reshape(arr, first(size(arr)), :, 1)) + else + inds_list = vcat([links[n - 1]], site_inds, [links[n]]) + arr = Array(tensor, inds_list...) + push!(tensors, reshape(arr, first(size(arr)), :, last(size(arr)))) + end + end + + return TCI.TensorTrain{T,3}(tensors) +end + +# Utility Functions +function permutesiteinds(Ψ::MPS, sites::AbstractVector{<:AbstractVector}) + links = linkinds(Ψ) + tensors = Vector{ITensor}(undef, length(Ψ)) + tensors[1] = permute(Ψ[1], vcat(sites[1], links[1])) + for n in 2:(length(Ψ) - 1) + tensors[n] = permute(Ψ[n], vcat(links[n - 1], sites[n], links[n])) + end + tensors[end] = permute(Ψ[end], vcat(links[end], sites[end])) + return MPS(tensors) # T4AITensorCompat.MPS = TensorTrain +end + +function project(tensor::ITensor, projsiteinds::Dict{K,Int}) where {K} + slice = Union{Int,Colon}[ + idx ∈ keys(projsiteinds) ? projsiteinds[idx] : Colon() for idx in inds(tensor) + ] + data_org = Array(tensor, inds(tensor)...) + data_trim = zero(data_org) + data_trim[slice...] .= data_org[slice...] + return ITensor(data_trim, inds(tensor)...) +end + +function project(oldprojector::Projector, sites, projsiteinds::Dict{Index{T},Int}) where {T} + newprojdata = deepcopy(oldprojector.data) + for (siteind, projind) in projsiteinds + pos = find_nested_index(sites, siteind) + if pos === nothing + error("Site index not found: $siteind") + end + newprojdata[pos[1]][pos[2]] = projind + end + return Projector(newprojdata, oldprojector.sitedims) +end + +function project(subdmps::SubDomainMPS, projsiteinds::Dict{Index{T},Int}) where {T} + # Convert Dict to T4APartitionedMPSs.Projector + projector_data = Dict{Index,Int}(projsiteinds) + new_projector = PartitionedProjector(projector_data) + # Use SubDomainMPS project method (from T4APartitionedMPSs) + result = T4APartitionedMPSs.project(subdmps, new_projector) + if result === nothing + error("Projection resulted in nothing - projectors may not overlap") + end + return result +end + +function asTT3(::Type{T}, Ψ::MPS, sites; permdims=true)::TensorTrain{T,3} where {T} + Ψ2 = permdims ? permutesiteinds(Ψ, sites) : Ψ + tensors = Array{T,3}[] + links = linkinds(Ψ2) + push!(tensors, reshape(Array(Ψ2[1], sites[1]..., links[1]), 1, :, dim(links[1]))) + for n in 2:(length(Ψ2) - 1) + push!( + tensors, + reshape( + Array(Ψ2[n], links[n - 1], sites[n]..., links[n]), + dim(links[n - 1]), + :, + dim(links[n]), + ), + ) + end + push!( + tensors, reshape(Array(Ψ2[end], links[end], sites[end]...), dim(links[end]), :, 1) + ) + return TensorTrain{T,3}(tensors) +end + +function _check_projector_compatibility(projector::Projector, subdmps::SubDomainMPS) + # SubDomainMPS already checks compatibility in constructor + # This is a compatibility function for the old API + return true +end + +function find_nested_index(data::Vector{Vector{T}}, target::T) where {T} + for (i, subvector) in enumerate(data) + j = findfirst(x -> x == target, subvector) + if j !== nothing + return (i, j) + end + end + return nothing # Not found +end + +# T4AQuantics extension functions are already defined in T4APartitionedMPSs and T4AQuantics +# No need to redefine them - they should work automatically + +# Miscellaneous Functions +# Base.show, ITensors.prime, Base.isapprox are already defined in T4APartitionedMPSs +# We can add type aliases for backward compatibility if needed + +function ITensors.prime(Ψ::PartitionedMPS, args...; kwargs...) + return T4APartitionedMPSs.prime(Ψ, args...; kwargs...) +end + +# Base.isapprox for SubDomainMPS is already defined in T4APartitionedMPSs + +# Make PartitionedMPS work as ProjectableEvaluator for evaluation +# Support both MultiIndex (Vector{Int}) and MMultiIndex (Vector{Vector{Int}}) +function (obj::PartitionedMPS)(multiidx::MultiIndex) + # Convert MultiIndex to MMultiIndex + sitedims_ = sitedims(obj) + mmultiidx = multii(sitedims_, multiidx) + return obj(mmultiidx) +end + +function (obj::PartitionedMPS)(mmultiidx::MMultiIndex) + # Sum over all SubDomainMPS in the PartitionedMPS + # Each SubDomainMPS corresponds to a different projector + if isempty(obj.data) + error("Cannot evaluate empty PartitionedMPS") + end + # Get element type from first tensor in first SubDomainMPS + first_subdmps = first(values(obj.data)) + first_tensor = first(first_subdmps.data) + # Get element type from ITensor's storage + T = eltype(ITensors.storage(first_tensor)) + result = zero(T) + for subdmps in values(obj.data) + # Convert SubDomainMPS to ProjTensorTrain for evaluation + # ProjTensorTrain{T}(subdmps) already gets sites from siteinds(subdmps) + ptt = ProjTensorTrain{T}(subdmps) + result += ptt(mmultiidx) + end + return result +end + +# Add fulltensor method for PartitionedMPS +function fulltensor(obj::PartitionedMPS; fused::Bool=false) + # Sum over all SubDomainMPS in the PartitionedMPS + if isempty(obj.data) + error("Cannot compute fulltensor for empty PartitionedMPS") + end + result = nothing + # Get element type from first tensor in first SubDomainMPS + first_subdmps = first(values(obj.data)) + first_tensor = first(first_subdmps.data) + # Get element type from ITensor's storage + T = eltype(ITensors.storage(first_tensor)) + for subdmps in values(obj.data) + ptt = ProjTensorTrain{T}(subdmps) + if result === nothing + result = fulltensor(ptt; fused=fused) + else + result .+= fulltensor(ptt; fused=fused) + end + end + return result +end + +# Add sitedims property access for PartitionedMPS (needed for ProjectableEvaluator compatibility) +function sitedims(obj::PartitionedMPS) + if isempty(obj.data) + error("Cannot get sitedims for empty PartitionedMPS") + end + # Get sitedims from first SubDomainMPS + first_subdmps = first(values(obj.data)) + sites = siteinds(first_subdmps) + return [collect(dim.(s)) for s in sites] +end diff --git a/src/T4ATCIAlgorithms.jl b/src/T4AAdaptivePatchedTCI.jl similarity index 67% rename from src/T4ATCIAlgorithms.jl rename to src/T4AAdaptivePatchedTCI.jl index e4ce357..11b6065 100644 --- a/src/T4ATCIAlgorithms.jl +++ b/src/T4AAdaptivePatchedTCI.jl @@ -1,10 +1,10 @@ -module T4ATCIAlgorithms +module T4AAdaptivePatchedTCI import T4ATensorCI as TCI -import T4ATensorCI: - TensorTrain, evaluate, TTCache, MultiIndex, LocalIndex, TensorCI2 +import T4ATensorCI: TensorTrain, evaluate, TTCache, MultiIndex, LocalIndex, TensorCI2 +import T4APartitionedMPSs: SubDomainMPS, PartitionedMPS, Projector as PartitionedProjector +using T4APartitionedMPSs: T4APartitionedMPSs -using ITensors using T4AQuantics using OrderedCollections: OrderedDict, OrderedSet @@ -21,11 +21,9 @@ include("blockstructure.jl") include("projectable_evaluator.jl") include("projtensortrain.jl") include("container.jl") -include("mul.jl") include("distribute.jl") include("tree.jl") include("patching.jl") include("crossinterpolate.jl") -include("adaptivematmul.jl") end diff --git a/src/TCIAlgorithms.jl b/src/TCIAlgorithms.jl deleted file mode 100644 index 34a7585..0000000 --- a/src/TCIAlgorithms.jl +++ /dev/null @@ -1,40 +0,0 @@ -module TCIAlgorithms - -import T4ATensorCI as TCI -import T4ATensorCI: - TensorTrain, evaluate, TTCache, MultiIndex, LocalIndex, TensorCI2 - -using TCIITensorConversion -using ITensors -using ITensorMPS: ITensorMPS -using ITensorMPS: MPO, MPS, linkdims, linkinds -using Quantics - -using OrderedCollections: OrderedDict, OrderedSet -using Distributed -using EllipsisNotation -using TCIITensorConversion -import LinearAlgebra as LA - -import FastMPOContractions as FMPOC - -const MMultiIndex = Vector{Vector{Int}} -const TensorTrainState{T} = TensorTrain{T,3} where {T} - -include("util.jl") -include("projector.jl") -include("blockstructure.jl") -include("projectable_evaluator.jl") -include("projtensortrain.jl") -include("container.jl") -include("mul.jl") -include("distribute.jl") -include("tree.jl") -include("patching.jl") -include("crossinterpolate.jl") -include("adaptivematmul.jl") - -# ITensor interface -include("itensor.jl") - -end diff --git a/src/adaptivematmul.jl b/src/adaptivematmul.jl deleted file mode 100644 index 536ef81..0000000 --- a/src/adaptivematmul.jl +++ /dev/null @@ -1,141 +0,0 @@ -function adaptivematmul( - a::ProjTTContainer{T}, - b::ProjTTContainer{T}, - pordering::PatchOrdering; - tolerance=1e-14, - maxbonddim=typemax(Int), -) where {T} - NT = Union{ProjTensorTrain{T},LazyMatrixMul{T}} - - root = create_node(NT, Int[]) - for x in a, y in b # FIXME: Naive loop over O(N^2) pairs - xy = lazymatmul(x, y) - if xy !== nothing - add!(root, xy, pordering) - end - end - - println("number of nodes: ", length(all_nodes(root))) - - # Perform lazy matrix multiplications - _performmul!(root, pordering; tolerance=tolerance, maxbonddim=maxbonddim) - println("[DEBUG] _performmul! done") - - allpatches = reduce(append!, [node.value for node in all_nodes(root)]) - - root_tt = create_node(ProjTensorTrain{T}, Int[]) - for x in allpatches - add!(root_tt, x, pordering) - end - - return ProjTTContainer{T}(_mergesmallpatches(root_tt; tolerance, maxbonddim)) -end - -""" -Perform matrix multiplication of two tensor trains and if the bond dimension is too large, project the result to a lower bond dimension. -We repeat this process until the bond dimension is small enough or no way to project more. -""" -function _performmul!( - root::TreeNode{Union{ProjTensorTrain{T},LazyMatrixMul{T}}}, - pordering::PatchOrdering; - tolerance=1e-14, - maxbonddim=typemax(Int), -) where {T} - # Check if lazy matrix multiplications can be performed - L = length(pordering) - i = 1 - while true - println("[DEBUG] _performmul! iteration $i, number of nodes: ", length(all_nodes(root))) - updated = false - for node in all_nodes(root) - for v in node.value - if !(v isa LazyMatrixMul{T}) - continue - end - updated = true - vresult = approxtt(v; maxbonddim=maxbonddim, tolerance=tolerance) - if maximum(TCI.linkdims(vresult.data)) < maxbonddim || - length(node.path) == L - # Bond dimension is small enough or no way to project more! - @assert delete_value!(node, node.path, v) !== nothing - add_value!(node, node.path, vresult) - else - @assert delete_value!(node, node.path, v) !== nothing - for proj in makechildproj(v.projector, pordering) - v_ = project(v, proj) - add_value!(node, createpath(proj, pordering), v_) - end - end - end - end - if !updated - break - end - end - for node in all_nodes(root) - for v in node.value - v isa ProjTensorTrain{T} || error("Something went wrong!") - end - end - return root -end - -function _mergesmallpatches( - node::TreeNode{ProjTensorTrain{T}}; tolerance=1e-14, maxbonddim=typemax(Int) -)::Vector{ProjTensorTrain{T}} where {T} - # The following implementation is based on - # recursive merging of patches, which is not efficient for paralellization. - tt_child::Vector{ProjTensorTrain{T}} = reduce( - append!, - (_mergesmallpatches(c; tolerance, maxbonddim) for c in values(node.children)); - init=ProjTensorTrain{T}[], - ) - - all_values = vcat(tt_child, node.value) - for x in all_values - if maximum(TCI.linkdims(x.data)) > maxbonddim - TCI.compress!(x.data; tolerance=0.0, maxbonddim=maxbonddim) - end - end - - if length(all_values) == 1 - return all_values - end - - sum_value = reduce((x, y) -> add(x, y; tolerance, maxbonddim), all_values) - - if maximum(TCI.linkdims(sum_value.data)) == maxbonddim - # Unsafe to merge - return all_values - else - # Safe to merge - return [sum_value] - end -end - -""" -Perform matrix multiplication of two tensor trains and project the result to a block structure. -""" -function matmul( - a::ProjTTContainer{T}, - b::ProjTTContainer{T}, - bs::BlockStructure; - tolerance=1e-14, - maxbonddim=typemax(Int), -) where {T} - tts = [zeroprojtt(T, prj) for prj in bs] - for x in a, y in b # FIXME: Naive loop over O(N^2) pairs - xy = lazymatmul(x, y) - if xy === nothing - continue - end - for (ib, p) in enumerate(bs.blocks) - if hasoverlap(xy.projector, p) - tt_ = approxtt(project(xy, p); maxbonddim=maxbonddim, tolerance=tolerance) - tts[ib] = add(tts[ib], tt_; tolerance, maxbonddim) - end - end - end - - return ProjTTContainer(tts) -end diff --git a/src/crossinterpolate.jl b/src/crossinterpolate.jl index 3c4f578..96d6fcb 100644 --- a/src/crossinterpolate.jl +++ b/src/crossinterpolate.jl @@ -329,12 +329,12 @@ end function adaptiveinterpolate( creator::TCI2PatchCreator{T}, pordering::PatchOrdering; verbosity=0 -)::ProjTTContainer{T} where {T} +)::Vector{ProjTensorTrain{T}} where {T} queue = TaskQueue{TCI2PatchCreator{T},ProjTensorTrain{T}}([creator]) results = loop( queue, x -> __taskfunc(x, pordering; verbosity=verbosity); verbosity=verbosity ) - return ProjTTContainer(results) + return collect(results) end function adaptiveinterpolate( @@ -345,7 +345,7 @@ function adaptiveinterpolate( tolerance=1e-8, initialpivots=MultiIndex[], # Make it to Vector{MMultiIndex}? recyclepivots=false, -)::ProjTTContainer{T} where {T} +)::Vector{ProjTensorTrain{T}} where {T} creator = TCI2PatchCreator( T, f, @@ -357,6 +357,5 @@ function adaptiveinterpolate( initialpivots=initialpivots, recyclepivots=recyclepivots, ) - tmp = adaptiveinterpolate(creator, pordering; verbosity) - return reshape(tmp, f.sitedims) + return adaptiveinterpolate(creator, pordering; verbosity) end diff --git a/src/itensor.jl b/src/itensor.jl deleted file mode 100644 index 2b558fb..0000000 --- a/src/itensor.jl +++ /dev/null @@ -1,339 +0,0 @@ -# Struct Definitions -struct ProjMPS - data::MPS - sites::Vector{Vector{Index}} - projector::Projector - - function ProjMPS( - data::MPS, sites::AbstractVector{<:AbstractVector}, projector::Projector - ) - _check_projector_compatibility(projector, data, sites) || error( - "Incompatible projector and data. Even small numerical noise can cause this error.", - ) - return new(permutesiteinds(data, sites), sites, projector) - end -end - -struct ProjMPSContainer - data::Vector{ProjMPS} - sites::Vector{Vector{Index}} - projector::Projector - - function ProjMPSContainer(data::AbstractVector{ProjMPS}) - for n in 2:length(data) - data[n].sites == data[1].sites || - error("Sitedims mismatch $(data[n].sites) != $(data[1].sites)") - end - projector = reduce(|, x.projector for x in data) - return new(data, data[1].sites, projector) - end -end - -# Constructor Functions -function ProjMPS(Ψ::MPS, sites::AbstractVector{<:AbstractVector}) - sitedims = [collect(dim.(s)) for s in sites] - globalprojector = Projector([fill(0, length(s)) for s in sitedims], sitedims) - return ProjMPS(Ψ, sites, globalprojector) -end - -function ProjMPSContainer(::Type{T}, projttcont::ProjTTContainer{T}, sites) where {T} - return ProjMPSContainer([ProjMPS(T, patch, sites) for patch in projttcont.data]) -end - -# Conversion Functions -ITensorMPS.MPS(projΨ::ProjMPS) = projΨ.data - -function ProjTensorTrain{T}(projΨ::ProjMPS) where {T} - return ProjTensorTrain{T}( - asTT3(T, projΨ.data, projΨ.sites; permdims=false), projΨ.projector - ) -end - -function ProjMPS(::Type{T}, projtt::ProjTensorTrain{T}, sites) where {T} - links = [Index(ld, "Link,l=$l") for (l, ld) in enumerate(TCI.linkdims(projtt.data))] - - tensors = ITensor[] - sitedims = [collect(dim.(s)) for s in sites] - linkdims = dim.(links) - - push!( - tensors, - ITensor( - reshape(projtt.data[1], 1, prod(sitedims[1]), linkdims[1]), - sites[1]..., - links[1], - ), - ) - - for n in 2:(length(projtt.data) - 1) - push!( - tensors, - ITensor( - reshape(projtt.data[n], linkdims[n - 1], prod(sitedims[n]), linkdims[n]), - links[n - 1], - sites[n]..., - links[n], - ), - ) - end - - push!( - tensors, - ITensor( - reshape(projtt.data[end], linkdims[end], prod(sitedims[end])), - links[end], - sites[end]..., - ), - ) - - return ProjMPS(MPS(tensors), sites, projtt.projector) -end - -function ProjTTContainer{T}(projmpss::ProjMPSContainer) where {T} - return ProjTTContainer([ProjTensorTrain{T}(projmps) for projmps in projmpss.data]) -end - -# Utility Functions -function permutesiteinds(Ψ::MPS, sites::AbstractVector{<:AbstractVector}) - links = linkinds(Ψ) - tensors = Vector{ITensor}(undef, length(Ψ)) - tensors[1] = permute(Ψ[1], vcat(sites[1], links[1])) - for n in 2:(length(Ψ) - 1) - tensors[n] = permute(Ψ[n], vcat(links[n - 1], sites[n], links[n])) - end - tensors[end] = permute(Ψ[end], vcat(links[end], sites[end])) - return MPS(tensors) -end - -function project(tensor::ITensor, projsiteinds::Dict{K,Int}) where {K} - slice = Union{Int,Colon}[ - idx ∈ keys(projsiteinds) ? projsiteinds[idx] : Colon() for idx in inds(tensor) - ] - data_org = Array(tensor, inds(tensor)...) - data_trim = zero(data_org) - data_trim[slice...] .= data_org[slice...] - return ITensor(data_trim, inds(tensor)...) -end - -function project(oldprojector::Projector, sites, projsiteinds::Dict{Index{T},Int}) where {T} - newprojdata = deepcopy(oldprojector.data) - for (siteind, projind) in projsiteinds - pos = find_nested_index(sites, siteind) - if pos === nothing - error("Site index not found: $siteind") - end - newprojdata[pos[1]][pos[2]] = projind - end - return Projector(newprojdata, oldprojector.sitedims) -end - -function project(projΨ::ProjMPS, projsiteinds::Dict{Index{T},Int}) where {T} - return ProjMPS( - MPS([project(projΨ.data[n], projsiteinds) for n in 1:length(projΨ.data)]), - projΨ.sites, - project(projΨ.projector, projΨ.sites, projsiteinds), - ) -end - -function asTT3(::Type{T}, Ψ::MPS, sites; permdims=true)::TensorTrain{T,3} where {T} - Ψ2 = permdims ? _permdims(Ψ, sites) : Ψ - tensors = Array{T,3}[] - links = linkinds(Ψ2) - push!(tensors, reshape(Array(Ψ2[1], sites[1]..., links[1]), 1, :, dim(links[1]))) - for n in 2:(length(Ψ2) - 1) - push!( - tensors, - reshape( - Array(Ψ2[n], links[n - 1], sites[n]..., links[n]), - dim(links[n - 1]), - :, - dim(links[n]), - ), - ) - end - push!( - tensors, reshape(Array(Ψ2[end], links[end], sites[end]...), dim(links[end]), :, 1) - ) - return TensorTrain{T,3}(tensors) -end - -function _check_projector_compatibility( - projector::Projector, Ψ::MPS, sites::AbstractVector{<:AbstractVector} -) - links = linkinds(Ψ) - sitedims = [collect(dim.(s)) for s in sites] - - sitetensors = [] - push!( - sitetensors, - reshape( - Array(Ψ[1], [sites[1]..., links[1]]), [1, prod(sitedims[1]), dim(links[1])]... - ), - ) - for n in 2:(length(Ψ) - 1) - push!( - sitetensors, - reshape( - Array(Ψ[n], [links[n - 1], sites[n]..., links[n]]), - dim(links[n - 1]), - prod(sitedims[n]), - dim(links[n]), - ), - ) - end - push!( - sitetensors, - reshape( - Array(Ψ[end], [links[end], sites[end]...]), - dim(links[end]), - prod(sitedims[end]), - 1, - ), - ) - - return reduce( - &, - _check_projector_compatibility(projector[n], sitedims[n], sitetensors[n]) for - n in 1:length(Ψ) - ) -end - -function find_nested_index(data::Vector{Vector{T}}, target::T) where {T} - for (i, subvector) in enumerate(data) - j = findfirst(x -> x == target, subvector) - if j !== nothing - return (i, j) - end - end - return nothing # Not found -end - -# Quantics Functions -function T4AQuantics.makesitediagonal(projmps::ProjMPS, site::Index) - mps_diagonal = T4AQuantics.makesitediagonal(MPS(projmps), site) - sites_diagonal = ITensors.SiteTypes.siteinds(all, mps_diagonal) - projmps_diagonal = ProjMPS(mps_diagonal, sites_diagonal) - - prjsiteinds = Dict{Index{Int},Int}() - for (p, s) in zip(projmps.projector, projmps.sites) - for (p_, s_) in zip(p, s) - iszero(p_) && continue - prjsiteinds[s_] = p_ - if s_ == site - prjsiteinds[s_'] = p_ - end - end - end - - return project(projmps_diagonal, prjsiteinds) -end - -function T4AQuantics.makesitediagonal(projmps::ProjMPS, tag::String) - mps_diagonal = T4AQuantics.makesitediagonal(MPS(projmps), tag) - sites_diagonal = ITensors.SiteTypes.siteinds(all, mps_diagonal) - projmps_diagonal = ProjMPS(mps_diagonal, sites_diagonal) - - target_positions = T4AQuantics.findallsiteinds_by_tag( - ITensors.SiteTypes.siteinds(MPS(projmps)); tag=tag - ) - prjsiteinds = Dict{Index{Int},Int}() - for (p, s) in zip(projmps.projector, projmps.sites) - for (p_, s_) in zip(p, s) - iszero(p_) && continue - prjsiteinds[s_] = p_ - if s_ ∈ target_positions - prjsiteinds[s_'] = p_ - end - end - end - - return project(projmps_diagonal, prjsiteinds) -end - -function T4AQuantics.makesitediagonal(projmpss::ProjMPSContainer, sites) - return ProjMPSContainer([ - T4AQuantics.makesitediagonal(projmps, sites) for projmps in projmpss.data - ]) -end - -function T4AQuantics.extractdiagonal(projmps::ProjMPS, tag::String) - mps_diagonal = T4AQuantics.extractdiagonal(MPS(projmps), tag) - sites_diagonal = ITensors.SiteTypes.siteinds(all, mps_diagonal) - projmps_diagonal = ProjMPS(mps_diagonal, sites_diagonal) - sites_diagonal_set = Set(Iterators.flatten(sites_diagonal)) - - prjsiteinds = Dict{Index{Int},Int}() - for (p, s) in zip(projmps.projector, projmps.sites) - for (p_, s_) in zip(p, s) - !iszero(p_) || continue - s_ ∈ sites_diagonal_set || continue - prjsiteinds[s_] = p_ - end - end - - return project(projmps_diagonal, prjsiteinds) -end - -function T4AQuantics.extractdiagonal(projmpss::ProjMPSContainer, sites) - return ProjMPSContainer([ - T4AQuantics.extractdiagonal(projmps, sites) for projmps in projmpss.data - ]) -end - -function T4AQuantics.rearrange_siteinds(projmps::ProjMPS, sites) - mps_rearranged = T4AQuantics.rearrange_siteinds(MPS(projmps), sites) - projmps_rearranged = ProjMPS(mps_rearranged, sites) - prjsiteinds = Dict{Index{Int},Int}() - for (p, s) in zip(projmps.projector, projmps.sites) - for (p_, s_) in zip(p, s) - if p_ != 0 - prjsiteinds[s_] = p_ - end - end - end - return project(projmps_rearranged, prjsiteinds) -end - -function T4AQuantics.rearrange_siteinds(projmpss::ProjMPSContainer, sites) - return ProjMPSContainer([ - T4AQuantics.rearrange_siteinds(projmps, sites) for projmps in projmpss.data - ]) -end - -# Miscellaneous Functions -function Base.show(io::IO, obj::ProjMPS) - return print(io, "ProjMPS projected on $(obj.projector.data)") -end - -function ITensors.prime(Ψ::ProjMPS, args...; kwargs...) - return ProjMPS( - prime(MPS(Ψ), args...; kwargs...), prime.(Ψ.sites, args...; kwargs...), Ψ.projector - ) -end - -function ITensors.prime(Ψ::ProjMPSContainer, args...; kwargs...) - return ProjMPSContainer([prime(projmps, args...; kwargs...) for projmps in Ψ.data]) -end - -Base.isapprox(x::ProjMPS, y::ProjMPS; kwargs...) = Base.isapprox(x.data, y.data, kwargs...) - -# Random MPO Functions (commented out) -#== -function _random_mpo( - rng::AbstractRNG, sites::AbstractVector{<:AbstractVector{Index{T}}}; m::Int=1 -) where {T} - sites_ = collect(Iterators.flatten(sites)) - Ψ = random_mps(rng, sites_, m) - tensors = ITensor[] - pos = 1 - for i in 1:length(sites) - push!(tensors, prod(Ψ[pos:(pos + length(sites[i]) - 1)])) - pos += length(sites[i]) - end - return MPS(tensors) -end - -function _random_mpo(sites::AbstractVector{<:AbstractVector{Index{T}}}; m::Int=1) where {T} - return _random_mpo(Random.default_rng(), sites; m=m) -end -==# diff --git a/src/mul.jl b/src/mul.jl deleted file mode 100644 index 02f19d1..0000000 --- a/src/mul.jl +++ /dev/null @@ -1,154 +0,0 @@ -""" -Lazy evaluation for matrix multiplication of two TTOs - -This is for the lazy evaluation of the matrix multiplication of two TTOs. -If underlying data needs to be changed by projection, it will be copied. - -TODO: make immutable -""" -mutable struct LazyMatrixMul{T} <: ProjectableEvaluator{T} - coeff::T - contraction::TCI.Contraction{T} - projector::Projector - sitedims::Vector{Vector{Int}} - a::ProjTensorTrain{T} - b::ProjTensorTrain{T} -end - -function LazyMatrixMul{T}( - a::ProjTensorTrain{T}, b::ProjTensorTrain{T}; coeff=one(T) -) where {T} - # This restriction is due to simulicity and to be removed. - all(length.(a.sitedims) .== 2) || error("The number of site indices must be 2") - all(length.(b.sitedims) .== 2) || error("The number of site indices must be 2") - sitedims_ab = [[x[1], y[2]] for (x, y) in zip(a.sitedims, b.sitedims)] - a_tt = TensorTrain{T,4}(a.data, a.sitedims) - b_tt = TensorTrain{T,4}(b.data, b.sitedims) - contraction = TCI.Contraction(a_tt, b_tt) - projector = Projector( - [[x[1], y[2]] for (x, y) in zip(a.projector, b.projector)], sitedims_ab - ) - return LazyMatrixMul{T}(coeff, contraction, projector, sitedims_ab, a, b) -end - -function LazyMatrixMul(a::ProjTensorTrain{T}, b::ProjTensorTrain{T}; coeff=one(1)) where {T} - return LazyMatrixMul{T}(a, b; coeff=coeff) -end - -Base.length(obj::LazyMatrixMul) = length(obj.projector) - -function project( - obj::LazyMatrixMul{T}, prj::Projector; kwargs... -)::LazyMatrixMul{T} where {T} - projector_a_new = Projector( - [[x[1], y[2]] for (x, y) in zip(prj, obj.a.projector)], obj.a.sitedims - ) - projector_b_new = Projector( - [[x[1], y[2]] for (x, y) in zip(obj.b.projector, prj)], obj.b.sitedims - ) - newa = project(obj.a, projector_a_new; kwargs...) - newb = project(obj.b, projector_b_new; kwargs...) - return LazyMatrixMul{T}(newa, newb; coeff=obj.coeff) -end - -function lazymatmul( - a::ProjTensorTrain{T}, b::ProjTensorTrain{T}; coeff=one(T) -)::Union{LazyMatrixMul{T},Nothing} where {T} - if !hasoverlap((x[2] for x in a.projector), (x[1] for x in b.projector)) - return nothing - end - return LazyMatrixMul(a, b; coeff=coeff) -end - -#TODO: Implement function LazyMatrixMul(contr::TCI.Contraction{T}) - -#= function LazyMatrixMul(a::ProjTensorTrain, b::ProjTensorTrain) - return LazyMatrixMul(TCI.Contraction(a, b)) -end =# - -# multi-site-index evaluation -function (obj::LazyMatrixMul{T})(indexset::MMultiIndex)::T where {T} - return obj.contraction(lineari(obj.sitedims, indexset)) -end - -# multi-site-index evaluation -function batchevaluateprj( - obj::LazyMatrixMul{T}, - leftindexset::AbstractVector{MMultiIndex}, - rightmmultiidxset::AbstractVector{MMultiIndex}, - ::Val{M}, -)::Array{T,M + 2} where {T,M} - #if !all([all(p .== 0) for p in obj.projector.data]) - #@show obj.projector.data - #end - M >= 0 || error("The order of the result must be non-negative") - if length(leftindexset) * length(rightmmultiidxset) == 0 - return Array{T,M + 2}(undef, ntuple(i -> 0, M + 2)...) - end - NL = length(leftindexset[1]) - NR = length(rightmmultiidxset[1]) - L = length(obj) - leftindexset_ = [lineari(obj.sitedims[1:NL], x) for x in leftindexset] - rightindexset_ = [ - lineari(obj.sitedims[(end - NR + 1):end], x) for x in rightmmultiidxset - ] - projector = Vector{Int}[ - isprojectedat(obj.projector, n) ? obj.projector[n] : [0, 0] for - n in (NL + 1):(L - NR) - ] - returnshape = [ - isprojectedat(obj.projector, n) ? 1 : prod(obj.sitedims[n]) for - n in (NL + 1):(L - NR) - ] - res = TCI.batchevaluate( - obj.contraction, leftindexset_, rightindexset_, Val(M), projector - ) - return reshape(res, length(leftindexset), returnshape..., length(rightmmultiidxset)) -end - -function lazymatmul( - a::ProjTTContainer{T}, b::ProjTTContainer{T} -)::ProjContainer{T,LazyMatrixMul{T}} where {T} - muls = LazyMatrixMul{T}[] - for l in a, r in b - p = lazymatmul(l, r) - if p !== nothing - push!(muls, p) - end - end - return ProjContainer{T,LazyMatrixMul{T}}(muls) -end - -function approxtt( - obj::LazyMatrixMul{T}; maxbonddim=typemax(Int), tolerance=1e-14, kwargs... -)::Union{ProjTensorTrain{T},Nothing} where {T} - sites_a_dangling = [ - Index(ld[1], "ell=$ell, a_dangling") for (ell, ld) in enumerate(obj.a.sitedims) - ] - sites_ab_shared = [ - Index(ld[2], "ell=$ell, ab_shared") for (ell, ld) in enumerate(obj.a.sitedims) - ] - sites_b_dangling = [ - Index(ld[2], "ell=$ell, b_dangling") for (ell, ld) in enumerate(obj.b.sitedims) - ] - sites_a = collect(collect(x) for x in zip(sites_a_dangling, sites_ab_shared)) - sites_b = collect(collect(x) for x in zip(sites_ab_shared, sites_b_dangling)) - sites_ab = collect(collect(x) for x in zip(sites_a_dangling, sites_b_dangling)) - - a_tto = TensorTrain{T,4}(obj.a.data, obj.a.sitedims) - b_tto = TensorTrain{T,4}(obj.b.data, obj.b.sitedims) - - # Contract two TT-operators using T4ATensorCI - # Choose zipup (SVD-based) for predictable truncation - ab_tto = TCI.contract( - a_tto, b_tto; algorithm=:zipup, tolerance=tolerance, maxbonddim=maxbonddim - ) - # Apply scalar coefficient - ab_tto = ab_tto * obj.coeff - - return project(ProjTensorTrain(ab_tto), obj.projector) -end - -function isapproxttavailable(obj::LazyMatrixMul) - return true -end diff --git a/test/_test_util.jl b/test/_test_util.jl new file mode 100644 index 0000000..9ecef87 --- /dev/null +++ b/test/_test_util.jl @@ -0,0 +1,33 @@ +using Test +import T4AAdaptivePatchedTCI as TCIA + +function _test_projection(obj::TCIA.ProjectableEvaluator, prj) + pobj = TCIA.project(obj, prj) + + # Within the projection + pobj_full = TCIA.fulltensor(pobj; fused=false) + obj_full = TCIA.fulltensor(obj; fused=false) + + # Projection + mask = [x == 0 ? Colon() : x for x in Iterators.flatten(prj.data)] + @test pobj_full[mask...] ≈ obj_full[mask...] + + let + tmp = deepcopy(pobj_full) + tmp[mask...] .= 0.0 + @test all(tmp .== 0.0) + end + + #indexset1 = [[1, 1], [1, 1], [1, 1], [1, 1]] + #@test indexset1 <= pobj.projector + #@test obj(indexset1) == pobj(indexset1) # exact equality + + # Outside the partition + #indexset2 = [[2, 1], [1, 1], [1, 1], [1, 1]] + #@test pobj(indexset2) == 0.0 + + ## Evaluation at a single linear indexset + #indexset3 = [[1, 1], [1, 1], [1, 1], [2, 1]] + #indexset3_li = [1, 1, 1, 2] + #@test pobj(indexset3) == pobj(indexset3_li) +end diff --git a/test/_util.jl b/test/_util.jl index c8fca99..30abcba 100644 --- a/test/_util.jl +++ b/test/_util.jl @@ -1,52 +1,20 @@ using ITensors -using Test using Random -using T4AITensorCompat: random_mps, random_mpo, MPO -import T4ATCIAlgorithms as TCIA - -function _test_projection(obj::TCIA.ProjectableEvaluator, prj) - pobj = TCIA.project(obj, prj) - - # Within the projection - pobj_full = TCIA.fulltensor(pobj; fused=false) - obj_full = TCIA.fulltensor(obj; fused=false) - - # Projection - mask = [x == 0 ? Colon() : x for x in Iterators.flatten(prj.data)] - @test pobj_full[mask...] ≈ obj_full[mask...] - - let - tmp = deepcopy(pobj_full) - tmp[mask...] .= 0.0 - @test all(tmp .== 0.0) - end - - #indexset1 = [[1, 1], [1, 1], [1, 1], [1, 1]] - #@test indexset1 <= pobj.projector - #@test obj(indexset1) == pobj(indexset1) # exact equality - - # Outside the partition - #indexset2 = [[2, 1], [1, 1], [1, 1], [1, 1]] - #@test pobj(indexset2) == 0.0 - - ## Evaluation at a single linear indexset - #indexset3 = [[1, 1], [1, 1], [1, 1], [2, 1]] - #indexset3_li = [1, 1, 1, 2] - #@test pobj(indexset3) == pobj(indexset3_li) -end +using T4AITensorCompat: TensorTrain +import ITensors: random_itensor function _random_mpo( rng::AbstractRNG, sites::AbstractVector{<:AbstractVector{Index{T}}}; m::Int=1 ) where {T} - sites_ = collect(Iterators.flatten(sites)) - Ψ = random_mps(rng, sites_; linkdims=m) - tensors = ITensor[] - pos = 1 - for i in 1:length(sites) - push!(tensors, prod(Ψ[pos:(pos + length(sites[i]) - 1)])) - pos += length(sites[i]) + N = length(sites) + links = [Index(m, "Link,n=$n") for n in 1:(N - 1)] + tensors = Vector{ITensor}(undef, N) + tensors[1] = random_itensor(rng, sites[1]..., links[1]) + tensors[N] = random_itensor(rng, links[N - 1], sites[N]...) + for n in 2:(N - 1) + tensors[n] = random_itensor(rng, links[n - 1], sites[n]..., links[n]) end - return MPO(tensors) + return TensorTrain(tensors) end function _random_mpo(sites::AbstractVector{<:AbstractVector{Index{T}}}; m::Int=1) where {T} diff --git a/test/adaptivematmul_tests.jl b/test/adaptivematmul_tests.jl deleted file mode 100644 index 70eb5e0..0000000 --- a/test/adaptivematmul_tests.jl +++ /dev/null @@ -1,439 +0,0 @@ -using Test -using Random - -import QuanticsGrids as QG -using T4ATensorCI -import T4ATensorCI as TCI -import T4ATCIAlgorithms as TCIA -using HubbardAtoms -using SparseIR - -import T4ATCIAlgorithms: - create_node, - add!, - find_node, - all_nodes, - delete!, - ProjTensorTrain, - Projector, - project, - ProjTTContainer, - adaptivematmul, - BlockStructure, - matmul - -@testset "adaptivematmul" begin - @testset "adpativematmul" begin - Random.seed!(1234) - T = Float64 - N = 3 - bonddims = [1, 10, 10, 1] - @assert length(bonddims) == N + 1 - - sitedimsa = [[2, 2] for _ in 1:N] - sitedimsb = [[2, 3] for _ in 1:N] - sitedimsab = [[2, 3] for _ in 1:N] - - a = ProjTensorTrain( - TCI.TensorTrain([ - rand(bonddims[n], sitedimsa[n]..., bonddims[n + 1]) for n in 1:N - ]), - ) - b = ProjTensorTrain( - TCI.TensorTrain([ - rand(bonddims[n], sitedimsb[n]..., bonddims[n + 1]) for n in 1:N - ]), - ) - - pa = ProjTTContainer([ - project(a, p) for p in [ - TCIA.Projector([[1, 1], [0, 0], [0, 0]], sitedimsa), - TCIA.Projector([[2, 2], [0, 0], [0, 0]], sitedimsa), - ] - ]) - - pb = ProjTTContainer([ - project(b, p) for p in [ - TCIA.Projector([[1, 1], [0, 0], [0, 0]], sitedimsb), - TCIA.Projector([[2, 2], [0, 0], [0, 0]], sitedimsb), - ] - ]) - - pordering = TCIA.PatchOrdering(collect(1:N)) - - ab = adaptivematmul(pa, pb, pordering; maxbonddim=4) - - amat = reshape(permutedims(TCIA.fulltensor(pa), (1, 3, 5, 2, 4, 6)), 2^3, 2^3) - bmat = reshape(permutedims(TCIA.fulltensor(pb), (1, 3, 5, 2, 4, 6)), 2^3, 3^3) - - abmat = reshape(permutedims(TCIA.fulltensor(ab), (1, 3, 5, 2, 4, 6)), 2^3, 3^3) - @test abmat ≈ amat * bmat - end - - @testset "mergesmalpacthes" begin - Random.seed!(1234) - T = Float64 - N = 4 - χ = 10 - bonddims = [1, fill(χ, N - 1)..., 1] - tolerance = 1e-8 - @assert length(bonddims) == N + 1 - - sitedims = [[2, 2] for _ in 1:N] - - a = ProjTensorTrain( - TCI.TensorTrain([ - randn(bonddims[n], sitedims[n]..., bonddims[n + 1]) for n in 1:N - ]), - ) - - projectors = Projector[] - rest = [[0, 0] for _ in 1:(N - 2)] - for i1 in 1:2, j1 in 1:2, i2 in 1:2, j2 in 1:2 - push!( - projectors, - TCIA.Projector([[i1, j1], [i2, j2], deepcopy(rest)...], sitedims), - ) - end - - pa = ProjTTContainer([ - project(a, p; compression=true, tolerance=tolerance, maxbonddim=1) for - p in projectors - ]) - - @test length(pa.data) == 16 - - pordering = TCIA.PatchOrdering(collect(1:N)) - root = TCIA.create_node(ProjTensorTrain{T}, Int[]) - for x in pa - TCIA.add!(root, x, pordering) - end - - maxbonddim = 10 - results = TCIA._mergesmallpatches(root; tolerance, maxbonddim=maxbonddim) - - @test 1 < length(results) < 16 # This is not an actual test, just a sanity check - - ref = TCIA.fulltensor(pa) - reconst = TCIA.fulltensor(TCIA.ProjTTContainer(results)) - - @test ref ≈ reconst - end - - @testset "matmul with blocks" begin - T = Float64 - sitedims = [[2, 2], [2, 2], [2, 2]] - N = length(sitedims) - bonddims = [1, 3, 3, 1] - - _random_tt() = TCI.TensorTrain([ - rand(bonddims[n], sitedims[n]..., bonddims[n + 1]) for n in 1:N - ]) - _random_tt(bs::BlockStructure) = - [project(ProjTensorTrain(_random_tt()), p) for p in bs] - - bs = TCIA.BlockStructure( - vec([TCIA.Projector([[i, j], [0, 0], [0, 0]], sitedims) for i in 1:2, j in 1:2]) - ) - - a = ProjTTContainer(_random_tt(bs)) - b = ProjTTContainer(_random_tt(bs)) - ab = TCIA.matmul(a, b, bs) - - ab_ref = TCI.contract_naive( - TCI.TensorTrain{T,4}(TCIA.approxtt(a).data, sitedims), - TCI.TensorTrain{T,4}(TCIA.approxtt(b).data, sitedims), - ) - @test TCIA.fulltensor(TCIA.approxtt(ab)) ≈ TCIA.fulltensor(ProjTensorTrain(ab_ref)) - end - - @testset "2d Gaussians" begin - Random.seed!(1234) - gaussian(x, y) = exp(-0.5 * (x^2 + y^2)) - R = 20 - xmax = 10.0 - grid = QG.DiscretizedGrid{2}(R, (-xmax, -xmax), (xmax, xmax)) - grid1 = QG.DiscretizedGrid{1}(R, -xmax, xmax) - localdims = fill(4, R) - sitedims = [[2, 2] for _ in 1:R] - qf = x -> gaussian(QG.quantics_to_origcoord(grid, x)...) - pordering = TCIA.PatchOrdering(collect(1:R)) - - expttpatches = reshape( - TCIA.adaptiveinterpolate( - TCIA.makeprojectable(Float64, qf, localdims), - pordering; - verbosity=0, - maxbonddim=30, - ), - sitedims, - ) - - product = TCIA.adaptivematmul(expttpatches, expttpatches, pordering; maxbonddim=50) - - nested_quantics(x, y) = [ - collect(p) for p in - zip(QG.origcoord_to_quantics(grid1, x), QG.origcoord_to_quantics(grid1, y)) - ] - - points = [(rand() * 10 - 5, rand() * 10 - 5) for i in 1:100] - expproduct(x, y) = sqrt(π) * exp(-0.5 * (x^2 + y^2)) - - @test isapprox( - [expproduct(p...) for p in points], - (2xmax / 2^R) .* [product(nested_quantics(p...)) for p in points], #(2xmax/2^R) = Δx, Δy - atol=1e-3, - ) - end - - @testset "polynomial integral" begin - Random.seed!(1234) - # \int_0^1 dz f1(x,z)*f2(z,y) - f1(x, y) = x * y - f2(x, y) = (x * y)^2 - R = 20 - grid = QG.DiscretizedGrid{2}(R, (0, 0), (1, 1)) - grid1 = QG.DiscretizedGrid{1}(R, 0, 1) - localdims = fill(4, R) - sitedims = [[2, 2] for _ in 1:R] - qf1 = x -> f1(QG.quantics_to_origcoord(grid, x)...) - qf2 = x -> f2(QG.quantics_to_origcoord(grid, x)...) - - pordering = TCIA.PatchOrdering(collect(1:R)) - - tt_f1 = reshape( - TCIA.adaptiveinterpolate( - TCIA.makeprojectable(Float64, qf1, localdims), pordering; verbosity=0 - ), - sitedims, - ) - - tt_f2 = reshape( - TCIA.adaptiveinterpolate( - TCIA.makeprojectable(Float64, qf2, localdims), pordering; verbosity=0 - ), - sitedims, - ) - - tt_f1_patches = reshape( - TCIA.adaptiveinterpolate( - TCIA.makeprojectable(Float64, qf1, localdims), - pordering; - verbosity=0, - maxbonddim=8, - ), - sitedims, - ) - - tt_f2_patches = reshape( - TCIA.adaptiveinterpolate( - TCIA.makeprojectable(Float64, qf2, localdims), - pordering; - verbosity=0, - maxbonddim=8, - ), - sitedims, - ) - - product_without_patches = TCIA.adaptivematmul(tt_f1, tt_f2, pordering) - product = TCIA.adaptivematmul( - tt_f1_patches, tt_f2_patches, pordering; maxbonddim=20 - ) - - nested_quantics(x, y) = [ - collect(p) for p in - zip(QG.origcoord_to_quantics(grid1, x), QG.origcoord_to_quantics(grid1, y)) - ] - - points = [(rand(), rand()) for i in 1:100] - exact_product(x, y) = x * y^2 / 4 #integrated (xy)*(yz)^2 dz from 0 to 1 - - #test without patches - @test isapprox( - [exact_product(p...) for p in points], - (1 / 2^R) .* [product_without_patches(nested_quantics(p...)) for p in points], - atol=1e-4, - ) - - #test with patches - @test isapprox( - [exact_product(p...) for p in points], - (1 / 2^R) .* [product(nested_quantics(p...)) for p in points], - atol=1e-4, - ) - end - - @testset "diagonal matrices" begin - Random.seed!(1234) - f1(x, y) = ==(x, y) * x^2 # diagonal matrix with x^2 in diagonal - f2(x, y) = ==(x, y) * (x^3) # diagonal matrix with x^3 in diagonal - R = 5 - grid = QG.InherentDiscreteGrid{2}(R, (0, 0); step=(1, 1)) # from 0 to 2^R-1 = 31 - grid1 = QG.InherentDiscreteGrid{1}(R, 0; step=1) - localdims = fill(4, R) - sitedims = [[2, 2] for _ in 1:R] - qf1 = x -> f1(QG.quantics_to_origcoord(grid, x)...) - qf2 = x -> f2(QG.quantics_to_origcoord(grid, x)...) - initialpivots = [QG.origcoord_to_quantics(grid, (2^R - 1, 2^R - 1))] #largest element - pordering = TCIA.PatchOrdering(collect(1:R)) - - tt_f1 = reshape( - TCIA.adaptiveinterpolate( - TCIA.makeprojectable(Float64, qf1, localdims), - pordering; - initialpivots=initialpivots, - verbosity=0, - ), - sitedims, - ) - - tt_f2 = reshape( - TCIA.adaptiveinterpolate( - TCIA.makeprojectable(Float64, qf2, localdims), - pordering; - initialpivots=initialpivots, - verbosity=0, - ), - sitedims, - ) - - tt_f1_projected = TCIA.ProjTTContainer([ - TCIA.project(tt_f1[1], p) for p in [ - TCIA.Projector([[1, 1], [0, 0], [0, 0], [0, 0], [0, 0]], sitedims), - TCIA.Projector([[2, 2], [0, 0], [0, 0], [0, 0], [0, 0]], sitedims), - ] - ]) - - tt_f2_projected = TCIA.ProjTTContainer([ - TCIA.project(tt_f2[1], p) for p in [ - TCIA.Projector([[1, 1], [0, 0], [0, 0], [0, 0], [0, 0]], sitedims), - TCIA.Projector([[2, 2], [0, 0], [0, 0], [0, 0], [0, 0]], sitedims), - ] - ]) - - product = TCIA.adaptivematmul( - tt_f1_projected, tt_f2_projected, pordering; maxbonddim=5 - ) - product_without_patches = TCIA.adaptivematmul( - tt_f1_projected, tt_f2_projected, pordering; maxbonddim=10 - ) - - nested_quantics(x, y) = [ - collect(p) for p in - zip(QG.origcoord_to_quantics(grid1, x), QG.origcoord_to_quantics(grid1, y)) - ] - - C = zeros(2^R, 2^R) .+ 0.0 - for i in 0:(2^R - 1) - C[i + 1, i + 1] = i^5 - end - - product_matrix = zeros(2^R, 2^R) .+ 0.0 - product_matrix_without_patches = zeros(2^R, 2^R) .+ 0.0 - for i in 0:(2^R - 1), j in 0:(2^R - 1) - product_matrix[i + 1, j + 1] = product(nested_quantics(i, j)) - product_matrix_without_patches[i + 1, j + 1] = product_without_patches( - nested_quantics(i, j) - ) - end - - @test maximum(abs.(product_matrix .- C)) < 1e-5 - @test maximum(abs.(product_matrix_without_patches .- C)) < 1e-5 - end - - @testset "Bethe-Salpeter equation" begin - U = 1.6 - beta = 2.3 - model = HubbardAtom(U, beta) - ch_d = DensityChannel() - ch_m = MagneticChannel() - ch_t = TripletChannel() - ch_s = SingletChannel() - m = BosonicFreq(10) - - R = 7 - maxbonddim = 50 - N = 2^R - halfN = 2^(R - 1) - grid = QG.InherentDiscreteGrid{2}( - R, (-halfN, -halfN); step=(1, 1), unfoldingscheme=:fused - ) - localdims = fill(4, R) - sitedims = [[2, 2] for _ in 1:R] - pordering = TCIA.PatchOrdering(collect(1:R)) - - for ch in CHANNELS - - ######################### quantics functions ############################ - # absorb 1/β^2 into chi0 function!!!!! - function fq_chi0(x, y) - return 1 / beta^2 * - chi0(ch, model, (FermionicFreq(2x + 1), FermionicFreq(2y + 1), m)) - end - fI_chi0 = QG.quanticsfunction(ComplexF64, grid, fq_chi0) - - function fq_full(x, y) - return full_vertex( - ch, model, (FermionicFreq(2x + 1), FermionicFreq(2y + 1), m) - ) - end - fI_full = QG.quanticsfunction(ComplexF64, grid, fq_full) - - function fq_gamma(x, y) - return gamma(ch, model, (FermionicFreq(2x + 1), FermionicFreq(2y + 1), m)) - end - fI_gamma = QG.quanticsfunction(ComplexF64, grid, fq_gamma) - ######################################################################### - - initialpivots = [QG.origcoord_to_quantics(grid, (0, 0))] # approx center of grid - - chi0_patches = reshape( - TCIA.adaptiveinterpolate( - TCIA.makeprojectable(Float64, fI_chi0, localdims), - pordering; - verbosity=0, - maxbonddim, - initialpivots, - ), - sitedims, - ) - full_patches = reshape( - TCIA.adaptiveinterpolate( - TCIA.makeprojectable(Float64, fI_full, localdims), - pordering; - verbosity=0, - maxbonddim, - initialpivots, - ), - sitedims, - ) - gamma_patches = reshape( - TCIA.adaptiveinterpolate( - TCIA.makeprojectable(Float64, fI_gamma, localdims), - pordering; - verbosity=0, - maxbonddim, - initialpivots, - ), - sitedims, - ) - - # multiplication Φ = Γ X₀ F - chi0_full = TCIA.adaptivematmul( - chi0_patches, full_patches, pordering; maxbonddim - ) - phi_bse = TCIA.adaptivematmul(gamma_patches, chi0_full, pordering; maxbonddim) - - # normal multiplication for comparison - box = [(x, y) for x in (-halfN):(halfN - 1), y in (-halfN):(halfN - 1)] - chi0_exact = map(splat(fq_chi0), box) - full_exact = map(splat(fq_full), box) - gamma_exact = map(splat(fq_gamma), box) - phi_normalmul = gamma_exact * chi0_exact * full_exact - - phi_adaptivemul = [phi_bse(QG.origcoord_to_quantics(grid, p)) for p in box] - - @test isapprox(phi_normalmul, phi_adaptivemul; rtol=1e-5) - end - end -end diff --git a/test/blockstructure_tests.jl b/test/blockstructure_tests.jl index cd61f81..62e622d 100644 --- a/test/blockstructure_tests.jl +++ b/test/blockstructure_tests.jl @@ -1,6 +1,6 @@ using Test import T4ATensorCI as TCI -import T4ATCIAlgorithms as TCIA +import T4AAdaptivePatchedTCI as TCIA @testset "BlockStructure" begin @testset "constructor" begin diff --git a/test/bse3d_tests.jl b/test/bse3d_tests.jl deleted file mode 100644 index c9ea328..0000000 --- a/test/bse3d_tests.jl +++ /dev/null @@ -1,154 +0,0 @@ -import QuanticsGrids as QG -using T4ATensorCI -import T4ATCIAlgorithms as TCIA -using HubbardAtoms -using SparseIR -using Quantics -using ITensors - -@testset "BSE in 3D" begin - U = 1.6 - beta = 2.3 - model = HubbardAtom(U, beta) - R = 4 - N = 2^R - maxbonddim = 40 - grid = QG.InherentDiscreteGrid{3}( - R, (-N + 1, -N + 1, -N); step=2, unfoldingscheme=:fused - ) - - base = 2 - sitesk = [Index(base, "k=$n") for n in 1:R] # ν - sitesk´ = prime.(sitesk) # ν´ - sitesq = [Index(base, "q=$n") for n in 1:R] # ω - sites = collect(collect.(zip(sitesk, sitesk´, sitesq))) - function makeverts(ch) - function fq_full(x, y, z) - return full_vertex( - ch, model, (FermionicFreq(x), FermionicFreq(y), BosonicFreq(z)) - ) - end - fI_full = QG.quanticsfunction(ComplexF64, grid, fq_full) - - # we absorb 1/β^2 into the chi0 function - function fq_chi0(x, y, z) - return 1 / beta^2 * - chi0(ch, model, (FermionicFreq(x), FermionicFreq(y), BosonicFreq(z))) - end - fI_chi0 = QG.quanticsfunction(ComplexF64, grid, fq_chi0) - - function fq_gamma(x, y, z) - return gamma(ch, model, (FermionicFreq(x), FermionicFreq(y), BosonicFreq(z))) - end - fI_gamma = QG.quanticsfunction(ComplexF64, grid, fq_gamma) - - return fq_full, fq_chi0, fq_gamma, fI_full, fI_chi0, fI_gamma - end - function interpolateverts(fI_chi0, fI_full, fI_gamma) - localdims = dim.(sites) - sitedims = [dim.(s) for s in sites] - pordering = TCIA.PatchOrdering(collect(1:R)) - initialpivots = [QG.origcoord_to_quantics(grid, 0)] # approx center of grid - - full_patches = reshape( - TCIA.adaptiveinterpolate( - TCIA.makeprojectable(Float64, fI_full, localdims), - pordering; - verbosity=0, - maxbonddim, - initialpivots, - ), - sitedims, - ) - chi0_patches = reshape( - TCIA.adaptiveinterpolate( - TCIA.makeprojectable(Float64, fI_chi0, localdims), - pordering; - verbosity=0, - maxbonddim, - initialpivots, - ), - sitedims, - ) - gamma_patches = reshape( - TCIA.adaptiveinterpolate( - TCIA.makeprojectable(Float64, fI_gamma, localdims), - pordering; - verbosity=0, - maxbonddim, - initialpivots, - ), - sitedims, - ) - - return full_patches, chi0_patches, gamma_patches - end - function makevertsdiagonal(full_patches, chi0_patches, gamma_patches) - siteskk´_vec = [[x, y] for (x, y) in zip(sitesk, sitesk´)] - sitesq_vec = [[z] for z in sitesq] - sites_separateq = [x for pair in zip(siteskk´_vec, sitesq_vec) for x in pair] - - full_mps = TCIA.ProjMPSContainer(Float64, full_patches, sites) - full_kk´_q = Quantics.rearrange_siteinds(full_mps, sites_separateq) - full_kk´_qq´ = Quantics.makesitediagonal(full_kk´_q, "q") - full_ptt = TCIA.ProjTTContainer{Float64}(full_kk´_qq´) - - chi0_mps = TCIA.ProjMPSContainer(Float64, chi0_patches, sites) - chi0_kk´_q = Quantics.rearrange_siteinds(chi0_mps, sites_separateq) - chi0_kk´_qq´ = Quantics.makesitediagonal(chi0_kk´_q, "q") - chi0_kk´_q´q´´ = prime(chi0_kk´_qq´) - chi0_ptt = TCIA.ProjTTContainer{Float64}(chi0_kk´_q´q´´) - - gamma_mps = TCIA.ProjMPSContainer(Float64, gamma_patches, sites) - gamma_kk´_q = Quantics.rearrange_siteinds(gamma_mps, sites_separateq) - gamma_kk´_qq´ = Quantics.makesitediagonal(gamma_kk´_q, "q") - gamma_kk´_q´´q´´´ = prime(gamma_kk´_qq´, 2) - gamma_ptt = TCIA.ProjTTContainer{Float64}(gamma_kk´_q´´q´´´) - - diagonal_sites = full_kk´_qq´.sites - - return full_ptt, chi0_ptt, gamma_ptt, diagonal_sites - end - function calculatebse(full_ptt, chi0_ptt, gamma_ptt, diagonal_sites) - pordering = TCIA.PatchOrdering(collect(1:(2R))) - - chi0_gamma_ptt = TCIA.adaptivematmul(chi0_ptt, gamma_ptt, pordering; maxbonddim) - phi_bse_diagonal = TCIA.adaptivematmul( - full_ptt, chi0_gamma_ptt, pordering; maxbonddim - ) - phi_bse_diagonal_projmps = TCIA.ProjMPSContainer( - Float64, phi_bse_diagonal, diagonal_sites - ) - phi_bse_projmps_kk´_q = Quantics.extractdiagonal(phi_bse_diagonal_projmps, "q") - phi_bse_projmps_kk´q = Quantics.rearrange_siteinds(phi_bse_projmps_kk´_q, sites) - phi_bse = TCIA.ProjTTContainer{Float64}(phi_bse_projmps_kk´q) - - return phi_bse - end - function comparereference(phi_bse, fq_full, fq_chi0, fq_gamma) - # normal multiplication for comparison - box = [ - (x, y, z) for x in range(-N + 1; step=2, length=N), - y in range(-N + 1; step=2, length=N), z in range(-N; step=2, length=N) - ] - chi0_exact = map(splat(fq_chi0), box) - full_exact = map(splat(fq_full), box) - gamma_exact = map(splat(fq_gamma), box) - phi_normalmul = stack( - gamma_exact[:, :, i] * chi0_exact[:, :, i] * full_exact[:, :, i] for i in 1:N - ) - - phi_adaptivemul = [phi_bse(QG.origcoord_to_quantics(grid, p)) for p in box] - - return norm(phi_normalmul - phi_adaptivemul) / norm(phi_normalmul) - end - ch = DensityChannel() - fq_full, fq_chi0, fq_gamma, fI_full, fI_chi0, fI_gamma = makeverts(ch) - full_patches, chi0_patches, gamma_patches = interpolateverts(fI_chi0, fI_full, fI_gamma) - full_ptt, chi0_ptt, gamma_ptt, diagonal_sites = makevertsdiagonal( - full_patches, chi0_patches, gamma_patches - ) - phi_bse = calculatebse(full_ptt, chi0_ptt, gamma_ptt, diagonal_sites) - error = comparereference(phi_bse, fq_full, fq_chi0, fq_gamma) - @test error < 7e-4 -end diff --git a/test/codequality_tests.jl b/test/codequality_tests.jl index d700e41..7af5e24 100644 --- a/test/codequality_tests.jl +++ b/test/codequality_tests.jl @@ -1,14 +1,14 @@ using Test using Aqua using JET -using T4ATCIAlgorithms +using T4AAdaptivePatchedTCI @testset "Aqua.jl" begin - Aqua.test_all(T4ATCIAlgorithms; deps_compat=false) + Aqua.test_all(T4AAdaptivePatchedTCI; deps_compat=false) end #= @testset "JET.jl" begin - JET.test_package(T4ATCIAlgorithms; target_defined_modules=true) + JET.test_package(T4AAdaptivePatchedTCI; target_defined_modules=true) end =# diff --git a/test/container_tests.jl b/test/container_tests.jl index 44d65d2..3cffae3 100644 --- a/test/container_tests.jl +++ b/test/container_tests.jl @@ -1,8 +1,8 @@ using Test import T4ATensorCI as TCI -import T4ATCIAlgorithms as TCIA +import T4AAdaptivePatchedTCI as TCIA -import T4ATCIAlgorithms: Projector +import T4AAdaptivePatchedTCI: Projector @testset "ProjContainer" begin @testset "ProjTTContainer" begin diff --git a/test/crossinterpolate_lazyeval_tests.jl b/test/crossinterpolate_lazyeval_tests.jl deleted file mode 100644 index df91e72..0000000 --- a/test/crossinterpolate_lazyeval_tests.jl +++ /dev/null @@ -1,63 +0,0 @@ -using Distributed -using Test -using Random - -@everywhere using T4ATensorCI -@everywhere import T4ATensorCI as TCI -@everywhere import T4ATCIAlgorithms as TCIA -@everywhere import QuanticsGrids: - DiscretizedGrid, quantics_to_origcoord, origcoord_to_quantics -@everywhere import QuanticsGrids as QG - -@testset "crossinterpolate_lazyeval" begin - @testset "2D Gaussian * 2D Gaussian" begin - Random.seed!(1234) - - R = 20 - xmax = 10.0 - grid = DiscretizedGrid{2}(R, (-xmax, -xmax), (xmax, xmax)) - grid1 = DiscretizedGrid{1}(R, -xmax, xmax) - localdims = fill(4, R) - sitedims = [[2, 2] for _ in 1:R] - qf = x -> gaussian(quantics_to_origcoord(grid, x)...) - tol = 1e-7 - - pordering = TCIA.PatchOrdering(collect(1:R)) - exptt = reshape( - TCIA.adaptiveinterpolate( - TCIA.makeprojectable(Float64, qf, localdims), pordering; verbosity=0 - ), - sitedims, - ) - - nested_quantics(x, y) = [ - collect(p) for - p in zip(origcoord_to_quantics(grid1, x), origcoord_to_quantics(grid1, y)) - ] - - points = [(rand() * 10 - 5, rand() * 10 - 5) for i in 1:100] - @test isapprox( - [exptt(nested_quantics(p...)) for p in points], - [qf(QG.origcoord_to_quantics(grid, p)) for p in points]; - atol=1e-5, - ) - - # Test lazy evaluation - exp2(x, y) = sqrt(π) * exp(-0.5 * (x^2 + y^2)) - exp2lazy = TCIA.lazymatmul(exptt, exptt) - - @test isapprox( - [exp2(p...) for p in points], - (2xmax / 2^R) .* [exp2lazy(nested_quantics(p...)) for p in points], - atol=1e-4, - ) - - exp2tt = TCIA.adaptiveinterpolate(exp2lazy, pordering; verbosity=0, maxbonddim=100) - - @test isapprox( - [exp2(p...) for p in points], - (2xmax / 2^R) .* [exp2tt(nested_quantics(p...)) for p in points], - atol=1e-4, - ) - end -end diff --git a/test/crossinterpolate_tests.jl b/test/crossinterpolate_tests.jl index b93fdc9..78063de 100644 --- a/test/crossinterpolate_tests.jl +++ b/test/crossinterpolate_tests.jl @@ -1,10 +1,11 @@ using Distributed using Test using Random +using LinearAlgebra @everywhere using T4ATensorCI @everywhere import T4ATensorCI as TCI -@everywhere import T4ATCIAlgorithms as TCIA +@everywhere import T4AAdaptivePatchedTCI as TCIA @everywhere import QuanticsGrids: DiscretizedGrid, quantics_to_origcoord, origcoord_to_quantics @everywhere import QuanticsGrids as QG @@ -89,7 +90,8 @@ using Random ntry=10, ) - obj = TCIA.adaptiveinterpolate(creator, pordering; verbosity=0) + results = TCIA.adaptiveinterpolate(creator, pordering; verbosity=0) + obj = TCIA.ProjTTContainer(results) points = [(rand() * 10 - 5, rand() * 10 - 5) for i in 1:100] @@ -116,7 +118,8 @@ using Random Float64, qf, localdims; maxbonddim=10, tolerance=tol, verbosity=0, ntry=10 ) - obj = TCIA.adaptiveinterpolate(creator, pordering; verbosity=0) + results = TCIA.adaptiveinterpolate(creator, pordering; verbosity=0) + obj = TCIA.ProjTTContainer(results) qidx = fill(1, R) @test obj([[q] for q in qidx]) == 0.0 @@ -140,7 +143,8 @@ using Random ptt = TCIA.project(TCIA.ProjTensorTrain(tt), p) - obj = TCIA.adaptiveinterpolate(ptt; verbosity=0, maxbonddim=5) + results = TCIA.adaptiveinterpolate(ptt; verbosity=0, maxbonddim=5) + obj = TCIA.ProjTTContainer(results) @test vec(TCIA.fulltensor(obj)) ≈ vec(TCIA.fulltensor(ptt)) end @@ -175,7 +179,8 @@ using Random verbosity=0, ntry=10, ) - obj = TCIA.adaptiveinterpolate(creator, pordering; verbosity=0) + results = TCIA.adaptiveinterpolate(creator, pordering; verbosity=0) + obj = TCIA.ProjTTContainer(results) points = [(rand() * 2 * pi - pi, rand() * 2 * pi - pi) for i in 1:1000] diff --git a/test/distribute_tests.jl b/test/distribute_tests.jl index c5121fc..aef32d9 100644 --- a/test/distribute_tests.jl +++ b/test/distribute_tests.jl @@ -6,7 +6,7 @@ addprocs(max(0, MAX_WORKERS - nworkers())) @everywhere begin import T4ATensorCI as TCI - import T4ATCIAlgorithms as TCIA + import T4AAdaptivePatchedTCI as TCIA function workerfunc(n) if n > 0 diff --git a/test/itensor_compat_tests.jl b/test/itensor_compat_tests.jl deleted file mode 100644 index a0da537..0000000 --- a/test/itensor_compat_tests.jl +++ /dev/null @@ -1,38 +0,0 @@ -using Test -using ITensors -using T4AITensorCompat - -@testset "itensor_compat" begin - @testset "random_mpo basic properties" begin - N = 3 - sitesx = [Index(2, "x=$n") for n in 1:N] - sitesy = [Index(2, "y=$n") for n in 1:N] - sites = collect(collect.(zip(sitesx, sitesy))) - - mpo = T4AITensorCompat.random_mpo(sites) - @test length(mpo) == N - - # Check site indices structure - ssites = T4AITensorCompat.siteinds(mpo) - @test length(ssites) == N - @test all(length(ssites[n]) == 2 for n in 1:N) - @test all(dim.(ssites[n]) == dim.(sites[n]) for n in 1:N) - end - - @testset "addition using compat TT" begin - N = 3 - sitesx = [Index(2, "x=$n") for n in 1:N] - sitesy = [Index(2, "y=$n") for n in 1:N] - sites = collect(collect.(zip(sitesx, sitesy))) - - A = T4AITensorCompat.random_mpo(sites) - B = T4AITensorCompat.random_mpo(sites) - C = A + B - - # Basic structural checks - @test length(C) == N - @test all(length(T4AITensorCompat.siteinds(C)[n]) == 2 for n in 1:N) - end -end - - diff --git a/test/itensor_tests.jl b/test/itensor_tests.jl index 0d4b47b..ccfb5cd 100644 --- a/test/itensor_tests.jl +++ b/test/itensor_tests.jl @@ -1,24 +1,27 @@ using Test import T4ATensorCI as TCI -import TCIAlgorithms as TCIA -using Quantics +import T4AAdaptivePatchedTCI as TCIA +using T4AQuantics +import T4APartitionedMPSs: siteinds, SubDomainMPS, project as project_subdmps +import T4AITensorCompat: MPS -import TCIAlgorithms: Projector, project, ProjTensorTrain, LazyMatrixMul, makeprojectable +import T4AAdaptivePatchedTCI: Projector, project, ProjTensorTrain, makeprojectable using ITensors -using ITensorMPS + +# _util.jl is already included in runtests.jl @testset "itensor" begin - @testset "ProjMPS" begin + @testset "SubDomainMPS" begin N = 3 sitesx = [Index(2, "x=$n") for n in 1:N] sitesy = [Index(2, "y=$n") for n in 1:N] sites = collect(collect.(zip(sitesx, sitesy))) - Ψ = MPS(collect(_random_mpo(sites))) - prjΨ = TCIA.ProjMPS(Ψ, sites) + Ψ = _random_mpo(sites) # MPO is TensorTrain, MPS is also TensorTrain + prjΨ = SubDomainMPS(Ψ) - prjΨ1 = project(prjΨ, Dict(sitesx[1] => 1)) - prjΨ2 = project(prjΨ, Dict(sitesx[1] => 2)) + prjΨ1 = project_subdmps(prjΨ, Dict(sitesx[1] => 1)) + prjΨ2 = project_subdmps(prjΨ, Dict(sitesx[1] => 2)) Ψreconst = MPS(prjΨ1) + MPS(prjΨ2) @@ -31,14 +34,14 @@ using ITensorMPS sitesy = [Index(2, "y=$n") for n in 1:N] sites = collect(collect.(zip(sitesx, sitesy))) sitedims = [dim.(s) for s in sites] - Ψ = MPS(collect(_random_mpo(sites))) - prjΨ = TCIA.ProjMPS(Ψ, sites) - prjΨ1 = project(prjΨ, Dict(sitesx[1] => 1)) + Ψ = _random_mpo(sites) # MPO is TensorTrain, MPS is also TensorTrain + prjΨ = SubDomainMPS(Ψ) + prjΨ1 = project_subdmps(prjΨ, Dict(sitesx[1] => 1)) prjtt1 = TCIA.ProjTensorTrain{Float64}(prjΨ1) @test prjtt1.projector == Projector([[1, 0], [0, 0]], sitedims) - prjΨ1_reconst = TCIA.ProjMPS(Float64, prjtt1, sites) + prjΨ1_reconst = SubDomainMPS(Float64, prjtt1, sites) @test prjΨ1 ≈ prjΨ1_reconst end @@ -50,10 +53,10 @@ using ITensorMPS sitesz = [Index(2, "z=$n") for n in 1:N] sites = collect(collect.(zip(sitesx, sitesy, sitesz))) - Ψ = MPS(collect(_random_mpo(sites))) + Ψ = _random_mpo(sites) # MPO is TensorTrain, MPS is also TensorTrain - prjΨ = TCIA.ProjMPS(Ψ, sites) - prjΨ1 = project(prjΨ, Dict(sitesx[1] => 1)) + prjΨ = SubDomainMPS(Ψ) + prjΨ1 = project_subdmps(prjΨ, Dict(sitesx[1] => 1)) sitesxy = collect(collect.(zip(sitesx, sitesy))) sites_rearranged = Vector{Index{Int}}[] @@ -61,10 +64,10 @@ using ITensorMPS push!(sites_rearranged, sitesxy[i]) push!(sites_rearranged, [sitesz[i]]) end - prjΨ1_rearranged = Quantics.rearrange_siteinds(prjΨ1, sites_rearranged) + prjΨ1_rearranged = T4AQuantics.rearrange_siteinds(prjΨ1, sites_rearranged) @test reduce(*, MPS(prjΨ1)) ≈ reduce(*, MPS(prjΨ1_rearranged)) - @test prjΨ1_rearranged.sites == sites_rearranged + @test siteinds(prjΨ1_rearranged) == sites_rearranged end @testset "makesitediagonal and extractdiagonal" begin @@ -77,18 +80,18 @@ using ITensorMPS sitesz_vec = [[z] for z in sitesz] sites = [x for pair in zip(sitesxy_vec, sitesz_vec) for x in pair] - Ψ = MPS(collect(_random_mpo(sites))) + Ψ = _random_mpo(sites) # MPO is TensorTrain, MPS is also TensorTrain - prjΨ = TCIA.ProjMPS(Ψ, sites) - prjΨ1 = project(prjΨ, Dict(sitesx[1] => 1)) + prjΨ = SubDomainMPS(Ψ) + prjΨ1 = project_subdmps(prjΨ, Dict(sitesx[1] => 1)) - prjΨ1_diagonalz = Quantics.makesitediagonal(prjΨ1, "y") - sites_diagonalz = Iterators.flatten(prjΨ1_diagonalz.sites) + prjΨ1_diagonalz = T4AQuantics.makesitediagonal(prjΨ1, "y") + sites_diagonalz = Iterators.flatten(siteinds(prjΨ1_diagonalz)) - psi_diag = prod(prjΨ1_diagonalz.data) - psi = prod(prjΨ1.data) + psi_diag = prod(MPS(prjΨ1_diagonalz)) + psi = prod(MPS(prjΨ1)) - @test Quantics.extractdiagonal(prjΨ1_diagonalz, "y") ≈ prjΨ1 + @test T4AQuantics.extractdiagonal(prjΨ1_diagonalz, "y") ≈ prjΨ1 for indval in eachindval(sites_diagonalz...) ind = first.(indval) diff --git a/test/mul_tests.jl b/test/mul_tests.jl deleted file mode 100644 index ec3a1a9..0000000 --- a/test/mul_tests.jl +++ /dev/null @@ -1,152 +0,0 @@ -using Test -import T4ATensorCI as TCI -import T4ATCIAlgorithms as TCIA - -import T4ATCIAlgorithms: Projector, project, ProjTensorTrain, LazyMatrixMul, makeprojectable - -@testset "mul" begin - @testset "lazymatmul" begin - T = Float64 - N = 4 - bonddims = [1, 3, 3, 3, 1] - @assert length(bonddims) == N + 1 - - sitedimsa = [[2, 2] for _ in 1:N] - sitedimsb = [[2, 3] for _ in 1:N] - sitedimsab = [[2, 3] for _ in 1:N] - - a = TCI.TensorTrain([ - rand(bonddims[n], sitedimsa[n]..., bonddims[n + 1]) for n in 1:N - ]) - b = TCI.TensorTrain([ - rand(bonddims[n], sitedimsb[n]..., bonddims[n + 1]) for n in 1:N - ]) - - projector_a = Projector([[1, 1], [0, 0], [0, 0], [0, 0]], sitedimsa) - #pa = project(ProjTensorTrain(a), projector_a) - pa = project(makeprojectable(a), projector_a) - - projector_b = Projector([[1, 2], [0, 0], [0, 0], [0, 0]], sitedimsb) - pb = project(makeprojectable(b), projector_b) - - ab = TCIA.lazymatmul(pa, pb) - - @test ab.sitedims == [[2, 3] for _ in 1:N] - - a_tt = TCI.TensorTrain{T,4}(ab.a.data, sitedimsa) - b_tt = TCI.TensorTrain{T,4}(ab.b.data, sitedimsb) - - ab_ref = TCI.contract_naive(a_tt, b_tt) - - @test TCIA.fulltensor(ab) ≈ TCIA.fulltensor(ProjTensorTrain(ab_ref)) - - # Fit algorithm - @test TCIA.fulltensor(TCIA.approxtt(ab)) ≈ TCIA.fulltensor(ProjTensorTrain(ab_ref)) - end - - @testset "projecting lazymul" begin - T = Float64 - N = 4 - bonddims = [1, 3, 3, 3, 1] - @assert length(bonddims) == N + 1 - - sitedimsa = [[2, 2] for _ in 1:N] - sitedimsb = [[2, 3] for _ in 1:N] - sitedimsab = [[2, 3] for _ in 1:N] - - a = TCI.TensorTrain([ - rand(bonddims[n], sitedimsa[n]..., bonddims[n + 1]) for n in 1:N - ]) - b = TCI.TensorTrain([ - rand(bonddims[n], sitedimsb[n]..., bonddims[n + 1]) for n in 1:N - ]) - - for p in [[[1, 1], [0, 0], [0, 0], [0, 0]], [[1, 0], [2, 0], [0, 0], [0, 0]]] - ab = TCIA.lazymatmul(makeprojectable(a), makeprojectable(b)) - _test_projection(ab, Projector(p, sitedimsab)) - end - end - - @testset "batchevaluate" begin - T = Float64 - N = 4 - bonddims = [1, 3, 3, 3, 1] - @assert length(bonddims) == N + 1 - - sitedimsa = [[2, 2] for _ in 1:N] - sitedimsb = [[2, 3] for _ in 1:N] - sitedimsab = [[2, 3] for _ in 1:N] - - a = TCI.TensorTrain([ - rand(bonddims[n], sitedimsa[n]..., bonddims[n + 1]) for n in 1:N - ]) - b = TCI.TensorTrain([ - rand(bonddims[n], sitedimsb[n]..., bonddims[n + 1]) for n in 1:N - ]) - - projector_a = Projector([[1, 1], [1, 0], [0, 0], [0, 0]], sitedimsa) - pa = project(makeprojectable(a), projector_a) - - projector_b = Projector([[1, 2], [0, 1], [0, 0], [0, 0]], sitedimsb) - pb = project(makeprojectable(b), projector_b) - - ab = TCIA.lazymatmul(pa, pb) - - leftmmultiidxset = [[[1, 2]]] - rightmmultiidxset = [[[1, 1]]] - - batchmul = TCIA.batchevaluateprj(ab, leftmmultiidxset, rightmmultiidxset, Val(2)) - - for x in 1:2, y in 1:3 - @test batchmul[1, 1, TCIA._lineari(ab.sitedims[3], [x, y]), 1] ≈ - ab([[1, 2], [1, 1], [x, y], [1, 1]]) - end - end - - @testset "containermul" begin - T = Float64 - N = 4 - bonddims = [1, 3, 3, 3, 1] - @assert length(bonddims) == N + 1 - - sitedimsa = [[2, 2] for _ in 1:N] - sitedimsb = [[2, 3] for _ in 1:N] - sitedimsab = [[2, 3] for _ in 1:N] - - pa = ProjTensorTrain{T}[] - pb = ProjTensorTrain{T}[] - ab_ref = ProjTensorTrain{T}[] - - for i in 1:4 - a = TCI.TensorTrain([ - rand(bonddims[n], sitedimsa[n]..., bonddims[n + 1]) for n in 1:N - ]) - b = TCI.TensorTrain([ - rand(bonddims[n], sitedimsb[n]..., bonddims[n + 1]) for n in 1:N - ]) - - projector_a = Projector( - [TCIA._multii(sitedimsa[1], i), [0, 0], [0, 0], [0, 0]], sitedimsa - ) - push!(pa, project(makeprojectable(a), projector_a)) - - projector_b = Projector( - [reverse(TCIA._multii(sitedimsb[1], i)), [0, 0], [0, 0], [0, 0]], sitedimsb - ) - push!(pb, project(makeprojectable(b), projector_b)) - - a_tt = TCI.TensorTrain{T,4}(pa[i].data, sitedimsa) - b_tt = TCI.TensorTrain{T,4}(pb[i].data, sitedimsb) - push!(ab_ref, ProjTensorTrain(TCI.contract_naive(a_tt, b_tt))) - end - - cont_pa = TCIA.ProjTTContainer(pa) - cont_pb = TCIA.ProjTTContainer(pb) - - cont_ab_ref = TCIA.ProjTTContainer(ab_ref) - - cont_ab = TCIA.lazymatmul(cont_pa, cont_pb) - - TCIA.fulltensor(cont_ab) ≈ TCIA.fulltensor(cont_ab_ref) - end -end diff --git a/test/patching_tests.jl b/test/patching_tests.jl index 4cc1f71..3de681f 100644 --- a/test/patching_tests.jl +++ b/test/patching_tests.jl @@ -3,7 +3,7 @@ using Random using T4ATensorCI import T4ATensorCI as TCI -import T4ATCIAlgorithms as TCIA +import T4AAdaptivePatchedTCI as TCIA @testset "patching" begin @testset "createpath" begin @@ -19,39 +19,6 @@ import T4ATCIAlgorithms as TCIA @test TCIA.createpath(TCIA.Projector([[0], [0], [1]], sitedims), po) == [1] end - @testset "tree" begin - sitedims = [[2, 2], [2, 2], [2, 2], [2, 2]] - N = length(sitedims) - bonddims = [1, 4, 4, 4, 1] - po = TCIA.PatchOrdering(collect(1:N)) - tt = TCIA.ProjTensorTrain( - TCI.TensorTrain([ - rand(bonddims[n], sitedims[n]..., bonddims[n + 1]) for n in 1:N - ]), - ) - - T = Float64 - NT = Union{TCIA.ProjTensorTrain{T},TCIA.LazyMatrixMul{T}} - - # Root node - root = TCIA.create_node(NT, Int[]) - - ptt = TCIA.project(tt, TCIA.Projector([[0, 0], [0, 0], [0, 0], [0, 0]], sitedims)) - TCIA.add!(root, ptt, po) - @test length(TCIA.find_node(root, Int[]).value) == 1 - @test TCIA.find_node(root, Int[]).value[1] == ptt - - ptt2 = TCIA.project(tt, TCIA.Projector([[0, 1], [0, 0], [0, 0], [0, 0]], sitedims)) - TCIA.add!(root, ptt2, po) - @test length(TCIA.find_node(root, Int[]).value) == 2 - @test TCIA.find_node(root, Int[]).value[2] == ptt2 - - ptt3 = TCIA.project(tt, TCIA.Projector([[1, 1], [1, 1], [0, 0], [0, 0]], sitedims)) - TCIA.add!(root, ptt3, po) - @test length(TCIA.find_node(root, [1, 1]).value) == 1 - @test TCIA.find_node(root, [1, 1]).value[1] == ptt3 - end - @testset "makechildproj" begin sitedims = [[2, 2], [2, 2], [2, 2], [2, 2]] N = length(sitedims) diff --git a/test/projectable_evaluator_tests.jl b/test/projectable_evaluator_tests.jl index 073f49e..517501a 100644 --- a/test/projectable_evaluator_tests.jl +++ b/test/projectable_evaluator_tests.jl @@ -1,8 +1,8 @@ using Test import T4ATensorCI as TCI -import T4ATCIAlgorithms as TCIA +import T4AAdaptivePatchedTCI as TCIA -import T4ATCIAlgorithms: Projector +import T4AAdaptivePatchedTCI: Projector import QuanticsGrids: DiscretizedGrid, quantics_to_origcoord, origcoord_to_quantics import QuanticsGrids as QG diff --git a/test/projector_tests.jl b/test/projector_tests.jl index a51f28c..17dd28b 100644 --- a/test/projector_tests.jl +++ b/test/projector_tests.jl @@ -1,8 +1,8 @@ using Test import T4ATensorCI as TCI -import T4ATCIAlgorithms as TCIA +import T4AAdaptivePatchedTCI as TCIA -import T4ATCIAlgorithms: Projector +import T4AAdaptivePatchedTCI: Projector @testset "Projector" begin @testset "constructor" begin diff --git a/test/projtensortrain_tests.jl b/test/projtensortrain_tests.jl index e6a0c1d..194d18d 100644 --- a/test/projtensortrain_tests.jl +++ b/test/projtensortrain_tests.jl @@ -1,8 +1,8 @@ using Test import T4ATensorCI as TCI -import T4ATCIAlgorithms as TCIA +import T4AAdaptivePatchedTCI as TCIA -import T4ATCIAlgorithms: Projector +import T4AAdaptivePatchedTCI: Projector @testset "ProjTensorTrain" begin @testset "ProjTensorTrain" begin diff --git a/test/runtests.jl b/test/runtests.jl index 3bbb65b..426621a 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,7 +1,7 @@ using Distributed -using T4ATCIAlgorithms -import T4ATCIAlgorithms as TCIA +using T4AAdaptivePatchedTCI +import T4AAdaptivePatchedTCI as TCIA using Random using Test @@ -14,7 +14,7 @@ if nworkers() < MAX_WORKERS end #include("codequality_tests.jl") -include("_util.jl") +include("_test_util.jl") include("util_tests.jl") include("projector_tests.jl") @@ -22,17 +22,18 @@ include("blockstructure_tests.jl") include("projectable_evaluator_tests.jl") include("projtensortrain_tests.jl") include("container_tests.jl") -include("mul_tests.jl") include("distribute_tests.jl") include("patching_tests.jl") include("crossinterpolate_tests.jl") include("tree_tests.jl") -# This tests runs very long time, creating many patches. -#include("adaptivematmul_tests.jl") - -# Following tests did not work with T4AITensorCompat -#include("itensor_compat_tests.jl") -#include("bse3d_tests.jl") - -#include("crossinterpolate_lazyeval_tests.jl") +# Include ITensor tests if T4AITensorCompat and ITensors are available +# Extension module will be automatically loaded when both are available +#try +using T4AITensorCompat +using ITensors +include("_util.jl") +include("itensor_tests.jl") +#catch e +#@warn "T4AITensorCompat or ITensors not available, skipping ITensor tests" exception=(e, catch_backtrace()) +##end diff --git a/test/tree_tests.jl b/test/tree_tests.jl index f7bd403..989d392 100644 --- a/test/tree_tests.jl +++ b/test/tree_tests.jl @@ -3,8 +3,8 @@ using Random using T4ATensorCI import T4ATensorCI as TCI -import T4ATCIAlgorithms as TCIA -import T4ATCIAlgorithms: +import T4AAdaptivePatchedTCI as TCIA +import T4AAdaptivePatchedTCI: create_node, add_value!, find_node, all_nodes, delete_value!, delete_node!, isleaf @testset "tree" begin diff --git a/test/util_tests.jl b/test/util_tests.jl index 2b4c240..8927116 100644 --- a/test/util_tests.jl +++ b/test/util_tests.jl @@ -1,6 +1,6 @@ using Test import T4ATensorCI as TCI -import T4ATCIAlgorithms as TCIA +import T4AAdaptivePatchedTCI as TCIA @testset "Util" begin @testset "allequal" begin diff --git a/test_output.log b/test_output.log index f3a55e1..9013fd7 100644 --- a/test_output.log +++ b/test_output.log @@ -1,217 +1,26 @@ - Testing T4ATCIAlgorithms - Status `/private/var/folders/1t/fxgqx0n17z33mplwpw4n1d8r0000gn/T/jl_VCwL1H/Project.toml` - [4c88cf16] Aqua v0.8.14 - [da5c29d0] EllipsisNotation v1.8.0 - [4f3da25b] HubbardAtoms v0.1.0 - [9136182c] ITensors v0.9.14 - [c3a54625] JET v0.11.0 - [bac558e1] OrderedCollections v1.8.1 - [634c7f73] QuanticsGrids v0.6.0 - [4fe2279e] SparseIR v1.1.4 -⌅ [864b39ca] T4AITensorCompat v0.6.0 - [99202d80] T4AQuantics v0.5.0 - [afea4b4e] T4ATCIAlgorithms v0.5.0 `~/projects/JuliaUmbrella/T4ATCIAlgorithms.jl` - [14428447] T4ATensorCI v0.10.0 `~/projects/JuliaUmbrella/T4ATensorCI.jl` - [8ba89e20] Distributed v1.11.0 - [37e2e46d] LinearAlgebra v1.12.0 - [9a3f8284] Random v1.11.0 - [8dfed614] Test v1.11.0 - Status `/private/var/folders/1t/fxgqx0n17z33mplwpw4n1d8r0000gn/T/jl_VCwL1H/Manifest.toml` - [7d9f7c33] Accessors v0.1.42 - [79e6a3ab] Adapt v4.4.0 - [4c88cf16] Aqua v0.8.14 - [dce04be8] ArgCheck v2.5.0 - [4fba245c] ArrayInterface v7.22.0 - [4c555306] ArrayLayouts v1.12.0 - [198e06fe] BangBang v0.4.6 - [9718e550] Baselet v0.1.1 - [0e736298] Bessels v0.2.8 - [c3b6d118] BitIntegers v0.3.5 - [8e7c35d0] BlockArrays v1.9.2 - [d360d2e6] ChainRulesCore v1.26.0 - [da1fd8a2] CodeTracking v2.0.2 - [f70d9fcc] CommonWorldInvalidations v1.0.0 - [34da2185] Compat v4.18.1 - [807dbc54] Compiler v0.1.1 - [a33af91c] CompositionsBase v0.1.2 - [187b0558] ConstructionBase v1.6.0 - [9a962f9c] DataAPI v1.16.0 - [864edb3b] DataStructures v0.19.3 - [e2d170a0] DataValueInterfaces v1.0.0 - [244e2a9f] DefineSingletons v0.1.2 - [85a47980] Dictionaries v0.4.5 - [ffbed154] DocStringExtensions v0.9.5 - [da5c29d0] EllipsisNotation v1.8.0 - [e2ba6199] ExprTools v0.1.10 - [e189563c] ExternalDocstrings v0.1.1 - [1a297f60] FillArrays v1.15.0 - [41a02a25] Folds v0.2.10 - [d9f16b24] Functors v0.5.2 - [14197337] GenericLinearAlgebra v0.3.19 - [f0d1745a] HalfIntegers v1.6.0 - [4f3da25b] HubbardAtoms v0.1.0 - [0d1a4710] ITensorMPS v0.3.24 - [9136182c] ITensors v0.9.14 - [615f187c] IfElse v0.1.1 - [313cdc1a] Indexing v1.1.1 - [22cec73e] InitialValues v0.3.1 - [842dd82b] InlineStrings v1.4.5 - [3587e190] InverseFunctions v0.1.17 - [28f27b66] IsApprox v2.0.0 - [82899510] IteratorInterfaceExtensions v1.0.0 - [c3a54625] JET v0.11.0 - [aa1ae85d] JuliaInterpreter v0.10.7 - [70703baa] JuliaSyntax v1.0.2 - [0b1a1467] KrylovKit v0.10.2 - [6f1432cf] LoweredCodeUtils v3.4.4 - [1914dd2f] MacroTools v0.5.16 - [128add7d] MicroCollections v0.2.0 - [bdf0d083] MultiFloats v2.3.0 - [23ae76d9] NDTensors v0.4.15 - [bac558e1] OrderedCollections v1.8.1 - [65ce6f38] PackageExtensionCompat v1.0.2 - [aea7be01] PrecompileTools v1.3.3 - [21216c6a] Preferences v1.5.0 - [1fd47b50] QuadGK v2.11.2 - [634c7f73] QuanticsGrids v0.6.0 - [b11687fd] QuanticsTCI v0.7.2 - [42d2dcc6] Referenceables v0.1.3 - [ae029012] Requires v1.3.1 - [295af30f] Revise v3.12.1 - [fdea26ae] SIMD v3.7.2 - [431bcebd] SciMLPublic v1.0.0 - [d3ce8812] SerializedElementArrays v0.1.0 - [efcf1570] Setfield v1.1.2 - [699a6c99] SimpleTraits v0.9.5 - [4fe2279e] SparseIR v1.1.4 - [03a91e81] SplitApplyCombine v1.2.3 - [171d559e] SplittablesBase v0.1.15 - [aedffcd0] Static v1.3.1 - [0d7ed370] StaticArrayInterface v1.8.0 - [90137ffa] StaticArrays v1.9.15 - [1e83bf80] StaticArraysCore v1.4.4 - [5e0ebb24] Strided v2.3.2 - [4db3bf67] StridedViews v0.4.1 -⌅ [864b39ca] T4AITensorCompat v0.6.0 - [f7a3e09c] T4APartitionedMPSs v0.7.3 - [99202d80] T4AQuantics v0.5.0 - [afea4b4e] T4ATCIAlgorithms v0.5.0 `~/projects/JuliaUmbrella/T4ATCIAlgorithms.jl` - [14428447] T4ATensorCI v0.10.0 `~/projects/JuliaUmbrella/T4ATensorCI.jl` - [3783bdb8] TableTraits v1.0.1 - [bd369af6] Tables v1.12.1 - [b261b2ec] TensorCrossInterpolation v0.9.18 - [24d252fe] ThreadedScans v0.1.0 - [a759f4b9] TimerOutputs v0.5.29 - [28d57a85] Transducers v0.4.85 - [9d95972d] TupleTools v1.6.0 - [409d34a3] VectorInterface v0.5.0 - [bd1ec220] Zeros v0.4.0 - [0dad84c5] ArgTools v1.1.2 - [56f22d72] Artifacts v1.11.0 - [2a0f44e3] Base64 v1.11.0 - [ade2ca70] Dates v1.11.0 - [8ba89e20] Distributed v1.11.0 - [f43a241f] Downloads v1.6.0 - [7b1f6079] FileWatching v1.11.0 - [9fa8497b] Future v1.11.0 - [b77e0a4c] InteractiveUtils v1.11.0 - [ac6e5ff7] JuliaSyntaxHighlighting v1.12.0 - [b27032c2] LibCURL v0.6.4 - [76f85450] LibGit2 v1.11.0 - [8f399da3] Libdl v1.11.0 - [37e2e46d] LinearAlgebra v1.12.0 - [56ddb016] Logging v1.11.0 - [d6f4376e] Markdown v1.11.0 - [ca575930] NetworkOptions v1.3.0 - [44cfe95a] Pkg v1.12.0 - [de0858da] Printf v1.11.0 - [3fa0cd96] REPL v1.11.0 - [9a3f8284] Random v1.11.0 - [ea8e919c] SHA v0.7.0 - [9e88b42a] Serialization v1.11.0 - [6462fe0b] Sockets v1.11.0 - [2f01184e] SparseArrays v1.12.0 - [f489334b] StyledStrings v1.11.0 - [fa267f1f] TOML v1.0.3 - [a4e569a6] Tar v1.10.0 - [8dfed614] Test v1.11.0 - [cf7118a7] UUIDs v1.11.0 - [4ec0a83e] Unicode v1.11.0 - [e66e0078] CompilerSupportLibraries_jll v1.3.0+1 - [deac9b47] LibCURL_jll v8.11.1+1 - [e37daf67] LibGit2_jll v1.9.0+0 - [29816b5a] LibSSH2_jll v1.11.3+1 - [14a3606d] MozillaCACerts_jll v2025.5.20 - [4536629a] OpenBLAS_jll v0.3.29+0 - [458c3c95] OpenSSL_jll v3.5.1+0 - [bea87d4a] SuiteSparse_jll v7.8.3+2 - [83775a58] Zlib_jll v1.3.1+2 - [8e850b90] libblastrampoline_jll v5.15.0+0 - [8e850ede] nghttp2_jll v1.64.0+1 - [3f19e933] p7zip_jll v17.5.0+2 - Info Packages marked with ⌅ have new versions available but compatibility constraints restrict them from upgrading. -Precompiling for configuration --code-coverage=none --color=yes --check-bounds=yes --warn-overwrite=yes --depwarn=yes --inline=yes --startup-file=no --track-allocation=none - 676.1 ms ✓ GenericLinearAlgebra - 1241.4 ms ✓ Bessels - 1100.5 ms ✓ TensorCrossInterpolation - 890.2 ms ✓ Revise → DistributedExt - 669.6 ms ✓ QuanticsTCI - 4955.5 ms ✓ StaticArrays - 714.9 ms ✓ ConstructionBase → ConstructionBaseStaticArraysExt - 756.3 ms ✓ StaticArrays → StaticArraysChainRulesCoreExt - 512.2 ms ✓ Adapt → AdaptStaticArraysExt - 601.8 ms ✓ Accessors → StaticArraysExt - 559.0 ms ✓ BangBang → BangBangStaticArraysExt - 558.6 ms ✓ StaticArrayInterface → StaticArrayInterfaceStaticArraysExt - 6973.3 ms ✓ SIMD - 7239.4 ms ✓ IsApprox - 1128.1 ms ✓ MultiFloats - 8840.5 ms ✓ ArrayLayouts - 1149.9 ms ✓ ArrayLayouts → ArrayLayoutsSparseArraysExt - 1647.3 ms ✓ BlockArrays - 1063.4 ms ✓ BlockArrays → BlockArraysAdaptExt - 1306.1 ms ✓ Transducers → TransducersBlockArraysExt - 3649.3 ms ✓ NDTensors - 4864.1 ms ✓ ITensors - 1546.6 ms ✓ ITensors → ITensorsVectorInterfaceExt - 3737.2 ms ✓ ITensorMPS - 24944.1 ms ✓ SparseIR - 2581.8 ms ✓ ITensorMPS → ITensorMPSChainRulesCoreExt - 2609.3 ms ✓ T4ATensorCI → TCIITensorConversion - 2607.8 ms ✓ TensorCrossInterpolation → TCIITensorConversion - 1380.8 ms ✓ HubbardAtoms - 2237.1 ms ✓ T4AITensorCompat - 3029.4 ms ✓ T4APartitionedMPSs - 3167.5 ms ✓ T4AQuantics - 3212.4 ms ✓ T4ATCIAlgorithms - 33 dependencies successfully precompiled in 45 seconds. 122 already precompiled. - 1 dependency had output during precompilation: -┌ T4AQuantics -│ WARNING: ignoring conflicting import of SiteTypes.siteinds into T4AQuantics -└  - Testing Running tests... -Test Summary: | Pass Total  Time -Aqua.jl |  7  7 17.2s +Precompiling packages... + 2798.8 ms ✓ T4AAdaptivePatchedTCI + 2001.9 ms ✓ T4AAdaptivePatchedTCI → T4AAdaptivePatchedTCIITensorExt + 2 dependencies successfully precompiled in 5 seconds. 142 already precompiled. Test Summary: | Pass Total Time -Util |  15  15 1.3s +Util |  15  15 0.9s Test Summary: | Pass Total Time -Projector |  24  24 0.8s +Projector |  24  24 0.5s Test Summary: | Pass Total Time BlockStructure |  3  3 0.2s Test Summary: | Pass Total Time -ProjEvaluator |  5  5 2.8s +ProjEvaluator |  5  5 1.9s Test Summary: | Pass Total Time -ProjTensorTrain |  12  12 6.5s +ProjTensorTrain |  12  12 4.4s Test Summary: | Pass Total Time -ProjContainer |  7  7 1.4s +ProjContainer |  7  7 1.2s Test Summary: | Pass Total Time -mul |  13  13 6.7s +TaskQueue |  1  1 0.2s Test Summary: | Pass Total Time -TaskQueue |  1  1 0.3s -Test Summary: | Pass Total Time -patching |  12  12 0.5s +patching |  6  6 0.1s Test Summary: | Pass Total  Time -crossinterpolate |  23  23 30.1s +crossinterpolate |  23  23 25.2s Test Summary: | Pass Total Time -tree |  16  16 0.5s -ERROR:  \ No newline at end of file +tree |  16  16 0.3s +┌ Warning: T4AITensorCompat not available, skipping ITensor tests +└ @ Main ~/projects/JuliaUmbrella/T4AAdaptivePatchedTCI.jl/test/runtests.jl:39