+
+
+
+
+
+
+
+
+
+
+
+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..22c82af
--- /dev/null
+++ b/dataset/cached_qc_dataset.html
@@ -0,0 +1,753 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+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..d53cf76
--- /dev/null
+++ b/dataset/config_dataset.html
@@ -0,0 +1,761 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+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..78e85d5
--- /dev/null
+++ b/dataset/mixed_cached_qc_dataset.html
@@ -0,0 +1,769 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+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..3e6b76c
--- /dev/null
+++ b/dataset/qc_dataset.html
@@ -0,0 +1,815 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+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..5461e5e8c3a34927a04a435bf9b62a7828214771
GIT binary patch
literal 66973
zcmdSBWmJ}H*ENiw7?g;Vl!AZ)(w!