genQC logo genQC logo genQC
  • Overview
  • Get Started
  • Tutorials
  • API Reference
  • Research
  • Code Repository
  1. Utils
  2. Config loader

API Reference

  • Modules Overview
  • Release notes

  • Benchmark
    • Compilation benchmark
  • Dataset
    • Dataset balancing
    • Cached dataset
    • Quantum circuit dataset
    • Config dataset
    • Dataset helper functions
    • Mixed cached dataset
  • Inference
    • Evaluation metrics
    • Evaluation helper
    • Sampling functions
  • Models
    • Config model
    • Frozen OpenCLIP
    • Layers
    • Position encodings
    • Conditional qc-UNet
    • Encoder for unitaries
    • Clip
      • Frozen OpenCLIP
      • Unitary CLIP
    • Embedding
      • Base embedder
      • Rotational preset embedder
    • Transformers
      • Transformers and attention
      • CirDiT - Circuit Diffusion Transformer
      • Transformers
  • Pipeline
    • Callbacks
    • Compilation Diffusion Pipeline
    • Diffusion Pipeline
    • Diffusion Pipeline Special
    • Metrics
    • Multimodal Diffusion Pipeline
    • Pipeline
    • Unitary CLIP Pipeline
  • Platform
    • Circuits dataset generation functions
    • Circuits instructions
    • Simulation backend
    • Backends
      • Base backend
      • CUDA-Q circuits backend
      • Pennylane circuits backend
      • Qiskit circuits backend
    • Tokenizer
      • Base tokenizer
      • Circuits tokenizer
      • Tensor tokenizer
  • Scheduler
    • Scheduler
    • DDIM Scheduler
    • DDPM Scheduler
    • DPM Scheduler
  • Utils
    • Async functions
    • Config loader
    • Math and algorithms
    • Miscellaneous util

On this page

  • IO
    • class_to_str
    • load_config
    • config_to_dict
    • save_dataclass_yaml
    • save_dict_yaml
  • Object config load
    • get_obj_from_str
    • instantiate_from_config
    • Models
    • store_model_state_dict
    • load_model_state_dict
    • Tensors and numpy
    • store_tensor
    • load_tensor
  • Report an issue
  • View source
  1. Utils
  2. Config loader

Config loader

Functions to load and store models and datasets.

Code using omegaconf to handle IO.

IO


source

class_to_str


def class_to_str(
    cls
):

source

load_config


def load_config(
    file_path
):

source

config_to_dict


def config_to_dict(
    config
):

source

save_dataclass_yaml


def save_dataclass_yaml(
    data_obj, file_path
):

source

save_dict_yaml


def 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

Adapted from: https://github.com/Stability-AI/generative-models


source

get_obj_from_str


def get_obj_from_str(
    string, reload:bool=False, invalidate_cache:bool=True
):

source

instantiate_from_config


def instantiate_from_config(
    config
):

Models


source

store_model_state_dict


def store_model_state_dict(
    state_dict, save_path
):

source

load_model_state_dict


def load_model_state_dict(
    save_path, device
):

Tensors and numpy

torch.serialization.DEFAULT_PROTOCOL
2

source

store_tensor


def store_tensor(
    tensor, save_path, type:str='tensor'
):

source

load_tensor


def load_tensor(
    save_path, device, type:str='tensor'
):
Back to top
Async functions
Math and algorithms
 

Copyright 2025, Florian Fürrutter

  • Report an issue
  • View source