+
+
+
+
+
+
+
+
+
+
+
+
+Code using omegaconf
to handle IO.
+
+IO
+
+source
+
+class_to_str
+
+ class_to_str (cls)
+
+
+source
+
+
+load_config
+
+ load_config (file_path)
+
+
+source
+
+
+config_to_dict
+
+ config_to_dict (config)
+
+
+source
+
+
+save_dataclass_yaml
+
+ save_dataclass_yaml (data_obj, file_path)
+
+
+source
+
+
+save_dict_yaml
+
+ save_dict_yaml (dict_obj, file_path)
+
+Test
+
+
@dataclass
+class MyConfig:
+ target:str = class_to_str(OmegaConf)
+ clr_dim: int = 80
+ features: list [int ]= None
+
+ c = MyConfig()
+ c.features = [1 ,2 ,3 ]
+
+ OmegaConf.structured(c)
+
+
{'target': 'omegaconf.omegaconf.OmegaConf', 'clr_dim': 80, 'features': [1, 2, 3]}
+
+
+
+
+
+Object config load
+Mostly taken from: https://github.com/Stability-AI/stablediffusion
+
+source
+
+get_obj_from_str
+
+ get_obj_from_str (string, reload=False)
+
+
+source
+
+
+instantiate_from_config
+
+ instantiate_from_config (config)
+
+
+source
+
+
+load_model_from_config
+
+ load_model_from_config (config, ckpt, device)
+
+
+
+
+
+
+ Back to top
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/dataset/cached_qc_dataset.html b/dataset/cached_qc_dataset.html
new file mode 100644
index 0000000..bff39ed
--- /dev/null
+++ b/dataset/cached_qc_dataset.html
@@ -0,0 +1,939 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Quantum circuit dataset that caches the y
prompts using the CLIP encoder. This speeds up training significantly!
+
+source
+
+Cached_OpenClip_Dataset
+
+ Cached_OpenClip_Dataset (device:torch.device=device(type='cpu'),
+ **parameters)
+
+Adds .caching
to the Quantum circuit dataset
class.
+
+
+
+
+ Back to top
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/dataset/config_dataset.html b/dataset/config_dataset.html
new file mode 100644
index 0000000..f9c1d7e
--- /dev/null
+++ b/dataset/config_dataset.html
@@ -0,0 +1,947 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Some comonly used functions for datasets.
+
+Checking
+
+source
+
+check_duplicate_in_dataset
+
+ check_duplicate_in_dataset (x, dataset)
+
+Check if ‘x’ is in ‘dataset’
+
+source
+
+
+check_duplicates_in_dataset
+
+ check_duplicates_in_dataset (xs, dataset, return_ind=False, invert=False)
+
+Checks if xs
is are dataset
. Boolean invert
changes if we count duplicates (False) or ones that are not in dataset (True). Uses torch.vmap
which copies dataset
for every element in xs
.
+Check if this works:
+
+
xs = torch.tensor(
+ [[0.7 , 1 , 0.5 ],
+ [0.3 , 1 , 0.5 ],
+ [ 0 , 1 , 0.5 ]])
+
+ d = torch.tensor([
+ [0.11 , 1 , 0.5 ],
+ [0.70 , 1 , 0.5 ], #here a dup
+ [0.71 , 1 , 0.5 ],
+ [0.3 , 1 , 0.5 ]])
+
+ check_duplicates_in_dataset(xs, d, return_ind= True )
+
+
+
+
+
+Manipulating
+
+source
+
+shuffle_tensor_dataset
+
+ shuffle_tensor_dataset (x, y=None, *z)
+
+Assumes numpy or tensor objects with same length.
+
+source
+
+
+get_unique_elements_indices
+
+ get_unique_elements_indices (tensor)
+
+Returns indices of unique_elements in tensor
.
+
+source
+
+
+uniquify_tensor_dataset
+
+ uniquify_tensor_dataset (x, y=None, *z)
+
+x
has to be tensor, assumes numpy or tensor obj for y
and z
+
+source
+
+
+balance_tensor_dataset
+
+ balance_tensor_dataset (x, y, *z, samples:int=None,
+ make_unique:bool=True, y_uniques=None,
+ shuffle_lables:bool=True, add_balance_fn:<built-
+ infunctioncallable>=None)
+
+Assumes x
is tensor and y
is tensor or numpy.
+
+
+
+
+
+ Back to top
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/dataset/mixed_cached_qc_dataset.html b/dataset/mixed_cached_qc_dataset.html
new file mode 100644
index 0000000..00c7c41
--- /dev/null
+++ b/dataset/mixed_cached_qc_dataset.html
@@ -0,0 +1,955 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Dataset that combines and handles multiple cached datasets, e.g. for multiple qubits. Here we also handle paddings.
+
+source
+
+Mixed_Cached_OpenClip_Dataset_config
+
+ Mixed_Cached_OpenClip_Dataset_config (store_dict:dict, optimized:bool,
+ dataset_to_gpu:bool,
+ random_samples:int,
+ num_of_qubits:int, min_gates:int,
+ max_gates:int, gate_pool:list[str],
+ pad_constant:int, collate_fn:str,
+ bucket_batch_size:int,
+ num_down_scales:int)
+
+
+source
+
+
+Mixed_Cached_OpenClip_Dataset
+
+ Mixed_Cached_OpenClip_Dataset (device:torch.device=device(type='cpu'),
+ **parameters)
+
+Dataset that uses multiple cached dataset and combines them with padding, either i) Bucket or ii) Max. Also provides a corresponding collate_fn
for training.
+
+
+
+
+ Back to top
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/dataset/qc_dataset.html b/dataset/qc_dataset.html
new file mode 100644
index 0000000..4645b90
--- /dev/null
+++ b/dataset/qc_dataset.html
@@ -0,0 +1,1001 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Dataset for quantum circuits.
+
+source
+
+Qc_Config_Dataset_config
+
+ Qc_Config_Dataset_config (store_dict:dict, optimized:bool,
+ dataset_to_gpu:bool, random_samples:int,
+ num_of_qubits:int, min_gates:int,
+ max_gates:int, gate_pool:list[str])
+
+
+source
+
+
+Qc_Config_Dataset
+
+ Qc_Config_Dataset (device:torch.device=device(type='cpu'), **parameters)
+
+Dataset for quantum circuits, access gate_pool
directly and all other paras with .params_config
+
+
init = {k:None for k in Qc_Config_Dataset.req_params}
+ init["gate_pool" ] = ["qiskit.circuit.library.standard_gates.h.HGate" ,
+ "qiskit.circuit.library.standard_gates.x.CXGate" ]
+ init["store_dict" ] = {"x" :"tensor" , "y" :"tensor_list" }
+
+ a = Qc_Config_Dataset(** init)
+ a.get_config()
+
+
{'target': '__main__.Qc_Config_Dataset',
+ 'device': 'cpu',
+ 'comment': '',
+ 'save_path': None,
+ 'save_datetime': '12/06/2023 19:06:49',
+ 'params': Qc_Config_Dataset_config(store_dict={'x': 'tensor', 'y': 'tensor_list'}, optimized=None, dataset_to_gpu=None, random_samples=None, num_of_qubits=None, min_gates=None, max_gates=None, gate_pool=['qiskit.circuit.library.standard_gates.h.HGate', 'qiskit.circuit.library.standard_gates.x.CXGate'])}
+
+
+
+
+
+
+ Back to top
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/0_hello_circuit_files/figure-html/cell-17-output-1.png b/examples/0_hello_circuit_files/figure-html/cell-17-output-1.png
new file mode 100644
index 0000000000000000000000000000000000000000..b56e6e93d71e27096544c06966cfa8b6f6b6f280
GIT binary patch
literal 62636
zcmd?RXH-;Mw*^?Bh>E~90D=S+P;wBESfC