Minimal codebase to optimize SNAP-displacement (SD) ansatzes for qudit state preparation.
The repository includes:
- SD ansatz implementations,
- sparse SD variants,
- Optuna-based hyperparameter search,
- noiseless and photon-loss simulations.
This project uses Python 3.10.
The recommended setup is with conda using the provided environment file:
conda env create -f environment.yml
conda activate SparseSDAnsatzThe environment includes the main packages used by the project:
- PyTorch
- NumPy
- SciPy
- pandas
- scikit-learn
- matplotlib
- Optuna
- scikit-optimize
- tqdm
- networkx
The main entry point for running an optimization is:
python run_optuna_vectorized.pyExperiment settings such as target state, dimension, number of bumper levels, and optimization parameters can be edited directly in run_optuna_vectorized.py.
.
├── environment.yml
├── README.md
├── run_optuna_vectorized.py # main script to launch Optuna experiments
├── optuna_study.py # Optuna objective and experiment setup
├── train_gradient_based.py # gradient-based training loop
├── function_generator.py # helper utilities for generated targets
├── generate_target_states.py # target-state generation / loading
│
├── quantum_circuit/
│ ├── ansatz_SD.py # SD ansatz implementation
│ ├── ansatz_SD_sparse_batch.py # sparse SD ansatzes
│ ├── qudit_gates.py # qudit operators and gate definitions
│ ├── photon_loss.py # photon-loss noise channels
│ └── fidelities_leakage.py # fidelity and leakage metrics
│
└── utils/
├── DataIO.py
├── load_save_checkpoint.py
├── parameter_encoding.py
├── parameter_encoding_unbounded.py
├── seconds_to_biggest_unit.py
└── utils_quantum.py
- Results are saved in the output folder defined by the experiment configuration.
- The example configuration in
run_optuna_vectorized.pycan be used as a starting point for new experiments.