@@ -123,6 +123,23 @@ function dict_deserialize_tree(id::UInt, d::Dict)
123123 end
124124end
125125
126+ """
127+ save_tensor_network(tn::GenericTensorNetwork; folder::String)
128+
129+ Serialize a tensor network to disk for storage/reloading. Creates three structured files:
130+ - `code.json`: OMEinsum contraction code (tree structure and contraction order)
131+ - `fixedvertices.json`: JSON-serialized Dict of pinned vertex configurations
132+ - `problem.json`: Problem specification using ProblemReductions serialization
133+
134+ The target folder will be created recursively if it doesn't exist. Files are overwritten
135+ if they already exist. Uses JSON for human-readable serialization with type preservation.
136+
137+ The saved files can be loaded using [`load_tensor_network`](@ref).
138+
139+ # Arguments
140+ - `tn::GenericTensorNetwork`: a [`GenericTensorNetwork`](@ref) instance to serialize. Must contain valid code, problem, and fixedvertices fields.
141+ - `folder::String`: Destination directory path. Parent directories will be created as needed.
142+ """
126143function save_tensor_network (tn:: GenericTensorNetwork ; folder:: String )
127144 ! isdir (folder) && mkpath (folder)
128145
@@ -136,6 +153,21 @@ function save_tensor_network(tn::GenericTensorNetwork; folder::String)
136153 return nothing
137154end
138155
156+ """
157+ load_tensor_network(folder::String) -> GenericTensorNetwork
158+
159+ Load a tensor network from disk that was previously saved using [`save_tensor_network`](@ref).
160+ Reconstructs the network from three required files: contraction code, fixed vertices mapping, and problem specification.
161+
162+ # Arguments
163+ - `folder::String`: Path to directory containing saved network files. Must contain:
164+ - `code.json`: Contraction order/structure from OMEinsum
165+ - `fixedvertices.json`: Dictionary of pinned vertex states
166+ - `problem.json`: Problem specification and parameters
167+
168+ # Returns
169+ - `GenericTensorNetwork`: Reconstructed tensor network.
170+ """
139171function load_tensor_network (folder:: String )
140172 ! isdir (folder) && throw (SystemError (" Folder not found: $folder " ))
141173
0 commit comments