Skip to content

Reproduction code for the paper "Optimization of Quantum-Repeater Networks using Stochastic Automatic Differentiation" by Guus Avis and Stefan Krastanov.

Notifications You must be signed in to change notification settings

GuusAvis/code_for_Optimization_of_Quantum-Repeater_Networks_using_Stochastic_Automatic_Differentiation

Repository files navigation

This folder contains the reproduction code for the paper Optimization of Quantum-Repeater Networks using Stochastic Automatic Differentiation by Guus Avis and Stefan Krastanov. More specifically, this code can be used to

  • reproduce the data used for the paper;
  • use data to reproduce the figures shown in the paper;
  • extend the results shown in the paper by changing setups and assumptions.

While some of the data produced for the figures is stored in the data folder, the complete data set needs to be downloaded separately. It can be found at DOI:10.5281/zenodo.14594606.

Installation

The reproduction code depends on two open-source packages that have been developed in the process of writing the paper. These are QuantumNetworkRecipes.jl, used here to simulate swap-ASAP repeater chains, and RepeaterPlacement.jl, used to optimize repeater locations. Both are available publicly in their own github repositories. The versions used to produce the data for the paper are 0.1.0 for both QuantumNetworkRecipes.jl and for RepeaterPlacement.jl. To avoid potential problems with these links or dependencies, we have included copies of the relevant versions of packages in this folder. As the Manifest.toml is included in this folder, all requirements can be installed simply and unambiguously. One can either run

using Pkg; Pkg.activate("."); Pkg.instantiate()

in Julia or activate the REPL, use ] to go to Pkg mode, and then do

activate .
instantiate

Furthermore, this folder contains a Julia module named AutoDiffQNets contained by the file AutoDiffQNets.jl. This module contains the code required to run the scripts that produce and process data. Each of these scripts (described below) contains an include statement in Julia pointing to the file AutoDiffQnets.jl. Make sure that the path is always correct, otherwise the scripts will not work.

Producing data

Here we describe how all the data from the paper can be reproduced. The scripts outlined below can be easily adapted to create data for different setups and assumptions.

Comparison to finite differences

Data used to compare stochastic AD to finite differences in the paper can be created, saved and immediately plotted by running the script compare_to_finitediff/compare_to_finitediff_produce_and_inspect.jl. Parameters can easily be adjusted within this script.

Optimizing bright-state parameters and sensitivity analysis

The optimization of bright-state parameters for a single-click repeater chain and the sensitivity of the resulting secret-key rate with respect to the coherence times at different nodes is performed using the scripts contained in the folder single_click_chain. Specifically, data for the asymmetric repeater chain considered in the main text is produced by running optimize_single_click_chain.jl, while data for the homogeneous chain studied in the appendix is produced using optimize_single_click_chain_symmetric.jl. The script can be given an index as parameter, choosing between four slightly different optimizations. As a first step, an optimization is performed where all the bright-state parameters are the same. This optimization is performed by simply scanning over its value and picking the best found when the index is 1 or 3, while a scan over the derivative augmented with a linear fit is used if the index is 2 or 4. Moreover, if the index is 1 or 2, the single-shot protocol is used, while if it is 3 or 4, the multi-shot protocol is used. If no index is provided, the script will run all four in parallel. Created data, in the form of .jld2 dictionaries, can be loaded using the function load_optimize_single_click_data(). The optimization results when all bright-state parameters are the same can be plotted using

show_optimization_traces(data["bsp_all_same_optimization_method"], data["bsp_trace_all_same"])

while the results when they are allowed to be different can be visualized using

show_optimization_traces(data["bsp_optimization_method"], data["bsp_trace"])

The derivatives of the optimized secret-key rate with respect to the coherence times can be found in data["coherence_time_derivatives"]. To produce data for different parameters, one can either change the parameters in the scripts or use the function optimize_single_click_chain() elsewhere.

Repeater placement

Repeater placements is optimized using the function RepeaterPlacement.simulated_annealing(). To specifically optimize repeater placement for swap-ASAP chains with the end nodes on the corners of a square, we offer two different wrappers here. The one used to produce the results in the paper is repeater_placement/optimize_repeaters_in_square.jl. This script can be called from the command line and needs relevant parameters to be passed; we refer to the file itself for more details about this interface. As we needed to solve many large optimization instances, we have performed our optimizations on a cluster running SLURM. To that end, we have written a number of SLURM wrapper scripts to interact with the optimization script. These are contained in repeater_placement/slurm/. Specifically, run_one.slurm is used to schedule a single optimization job, and run_many.sh is used to schedule a large number of them. Moreover, if a simulation fails before finishing (e.g., because it hit the wallclock), it can be resumed using repeater_placement/resume.jl, which can be used in SLURM using resume_setup.slurm and resume.slurm (both in repeater_placement/slurm/. The second interface that we offer is in the form of repeater_placement/optimize_repeater_in_square_cells.jl, which is meant to be used as an interactive notebook in, e.g., VS Code with the Julia extension. It also contains cells that help visualize optimization results.

When repeater-placement data is saved, a single subdirectory for each optimization instance is created (containing some metadata and a unique identifier). These directories contain the file trace.jld2, which contains the full optimization trace saved as a JLD2 dictionary. Further processing of the data is possible by calling the function RepeaterPlacement.process_data(), which adds a file data.csv to each of the subdirectories that represents a single-row dataframe with information about the optimization result. The function combine_data() can furthermore be used to collect all the rows together into a single dataframe, creating a file combined_data.csv. Finally, consolidate_data() can be used to further process the combined data to only include information about the best optimization result for each unique set of parameters, creating a file consolidated_data.csv. This is the file that is needed to create most of the repeater-placement figures in the paper, and a copy of the one used for the paper is included in the data folder. Figures that show specific optimization solutions require access to the raw data, which can be found in the data repository of the paper. To process, combine and consolidate raw data, the first cell of make_extra_figures.jl can be executed. Slurm versions are also included in the repeater_placement/slurm folder.

Benchmarking

To benchmark the amount of time required for repeater-chain simulations, the script benchmarking/benchmarking.jl can be used. A parameter can be passed to the script; if it is 1, data for the multi-shot protocol is generated, determining runtime for both estimating the secret-key rate and for estimating its derivative with respect to the bright-state parameter. If it is 2, data for the single-shot protocol is generated. If no parameter is is passed, data is generated for both cases in sequence. The file benchmarking/benchmarking.slurm can be used to perform the benchmarking on a SLURM cluster.

Creating figures

Figures from the paper

Almost all the figures contained in the paper can be created straightforwardly by running the Julia script make_figures.jl. Alternatively, specific figures can be created by running the file as an interactive notebook and executing only the required cells. The script will also print a lot of extra information about the data. Most (if not all) of the numbers cited in the paper are taken from this printed information. In the beginning of the script, a couple of variables are set. One of these is data_dir, which should point to a folder that contains consolidated_data.csv for the repeater-placement data and all the data related to the comparison to finite differences, to the single-click chain, and to benchmarking. By default it points to ./data, which comes with exactly this data. A second variable is repeater_placement_raw_data_dir, which is nothing by default. In order for the script to create also the figures from the paper that show solutions to the repeater-placement problem for some specific instances, thereby allowing this script to reproduce all the figures included in the paper, this variable should be set to point to a folder that contains all the raw data, i.e., the folder that contains subfolders that each contain the results of one specific repeater-placement optimization. The raw data is not included in this folder and needs to be downloaded separately, because of its size (70 GB uncompressed, 12 GB when zipped). It can be found at DOI:10.5281/zenodo.14594606.

Extra figures

Additionally, it is possible to generate figures that are not included in the paper for a more extensive inspection of the repeater-placement data. These figures can be created using make_extra_figures.jl. In the beginning of this script, the variable dir is set. This variable needs to point to the raw data (like repeater_placement_raw_data_dir in make_figures.jl) The script can either be run from terminal or as an interactive notebook. The file has cells that do the following:

  • Process and combine the raw data (the raw data that can be downloaded has already been processed; make_extra_figures.jl contains instructions for how to reprocess);
  • For each value of the scale parameter D, create a figure of the best found network utility versus the number of repeaters, in which the best secret-key rate, the minimum number of repeaters and the sufficient number of repeaters are indicated;
  • Show how the repeaters are placed for the best solution for each unique parameter value;
  • Inspect specific solutions in more detail by creating figures that show the optimization trace (both static figures and gifs of how the repeaters are displaced).

More instructions are also included in the form of comments in make_extra_figures.jl itself.

About

Reproduction code for the paper "Optimization of Quantum-Repeater Networks using Stochastic Automatic Differentiation" by Guus Avis and Stefan Krastanov.

Resources

Stars

Watchers

Forks

Packages

No packages published