Skip to content

Commit

Permalink
Merge branch 'main' into qua
Browse files Browse the repository at this point in the history
  • Loading branch information
stavros11 committed Aug 1, 2024
2 parents d068b49 + 6961ed1 commit 8ff1ec1
Show file tree
Hide file tree
Showing 21 changed files with 300 additions and 299 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ repos:
- id: isort
args: ["--profile", "black"]
- repo: https://github.com/asottile/pyupgrade
rev: v3.16.0
rev: v3.17.0
hooks:
- id: pyupgrade
- repo: https://github.com/hadialqattan/pycln
Expand Down
96 changes: 20 additions & 76 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 26 additions & 34 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,62 +1,54 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
systems.url = "github:nix-systems/default";
devenv = {
url = "github:cachix/devenv";
inputs.nixpkgs.follows = "nixpkgs";
};
nixpkgs-python = {
url = "github:cachix/nixpkgs-python";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-parts.url = "github:hercules-ci/flake-parts";
};

outputs = {
self,
nixpkgs,
devenv,
systems,
flake-parts,
...
} @ inputs: let
forEachSystem = nixpkgs.lib.genAttrs (import systems);
in {
packages = forEachSystem (system: {
default =
nixpkgs.legacyPackages.${system}.poetry2nix.mkPoetryApplication
{
} @ inputs:
flake-parts.lib.mkFlake {inherit inputs;} {
imports = [inputs.devenv.flakeModule];
systems = ["x86_64-linux" "aarch64-darwin"];

perSystem = {pkgs, ...}: {
packages.default = pkgs.poetry2nix.mkPoetryApplication {
projectDir = self;
preferWheels = true;
};
});

devShells =
forEachSystem
(system: let
pkgs = nixpkgs.legacyPackages.${system};
in {
default = devenv.lib.mkShell {
inherit inputs pkgs;
devenv.shells.default = {config, ...}: {
packages = with pkgs; [poethepoet pre-commit stdenv.cc.cc.lib];

modules = [
{
packages = with pkgs; [pre-commit poethepoet];
env = {
QIBOLAB_PLATFORMS = (dirOf config.env.DEVENV_ROOT) + "/qibolab_platforms_qrc";
};

languages.python = {
languages = {
python = {
enable = true;
libraries = with pkgs; [zlib];
poetry = {
enable = true;
libraries = with pkgs; [zlib];
poetry = {
install = {
enable = true;
install.enable = true;
install.groups = ["dev" "test"];
allExtras = true;
groups = ["dev" "test"];
};
version = "3.11";
};
}
];
};
};
};
});
};
};
};

nixConfig = {
extra-trusted-public-keys = "devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw=";
Expand Down
1 change: 1 addition & 0 deletions runcards/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test*/
89 changes: 19 additions & 70 deletions runcards/rx_calibration.py
Original file line number Diff line number Diff line change
@@ -1,73 +1,41 @@
from pathlib import Path

from qibo.backends import construct_backend

from qibocal.auto.execute import Executor
from qibocal.auto.history import History
from qibocal.auto.output import Metadata, Output
from qibocal.cli.report import report

target = "D4"
folder = Path("test_rx_calibration")
force = True

backend = construct_backend(backend="qibolab", platform="qw11q")
platform = backend.platform
if platform is None:
raise ValueError("Qibocal requires a Qibolab platform to run.")

executor = Executor(
name="myexec", history=History(), platform=platform, targets=[target]
)

# generate output folder
path = Output.mkdir(folder, force)
executor = Executor.create(name="myexec", platform="dummy")

# generate meta
meta = Metadata.generate(path.name, backend)
output = Output(History(), meta, platform)
output.dump(path)

from myexec import drag_tuning, rabi_amplitude, ramsey

# connect and initialize platform
platform.connect()

# run
meta.start()
from myexec import close, drag_tuning, init, rabi_amplitude, ramsey

target = 0
platform = executor.platform
platform.settings.nshots = 2048
init("test_rx_calibration", force=True, targets=[target])

rabi_output = rabi_amplitude(
min_amp_factor=0.5,
max_amp_factor=1.5,
step_amp_factor=0.01,
pulse_length=platform.qubits[target].native_gates.RX.duration,
nshots=2048,
)

# update only if chi2 is satisfied
if rabi_output.results.chi2[target][0] > 2:
raise (
raise RuntimeError(
f"Rabi fit has chi2 {rabi_output.results.chi2[target][0]} greater than 2. Stopping."
)
else:
rabi_output.update_platform(platform)
rabi_output.update_platform(platform)

ramsey_output = ramsey(
delay_between_pulses_start=10,
delay_between_pulses_end=5000,
delay_between_pulses_step=100,
detuning=1_000_000,
nshots=2048,
)

if ramsey_output.results.chi2[target][0] > 2:
raise (
raise RuntimeError(
f"Ramsey fit has chi2 {ramsey_output.results.chi2[target][0]} greater than 2. Stopping."
)
elif ramsey_output.results.delta_phys[target][0] < 1e4:
if ramsey_output.results.delta_phys[target][0] < 1e4:
print(
f"Ramsey frequency not updated, correctio to small { ramsey_output.results.delta_phys[target][0]}"
f"Ramsey frequency not updated, correction too small { ramsey_output.results.delta_phys[target][0]}"
)
else:
ramsey_output.update_platform(platform)
Expand All @@ -77,52 +45,33 @@
max_amp_factor=1.5,
step_amp_factor=0.01,
pulse_length=platform.qubits[target].native_gates.RX.duration,
nshots=2048,
)


# update only if chi2 is satisfied
if rabi_output_2.results.chi2[target][0] > 2:
raise (
raise RuntimeError(
f"Rabi fit has chi2 {rabi_output_2.results.chi2[target][0]} greater than 2. Stopping."
)
else:
rabi_output_2.update_platform(platform)
rabi_output_2.update_platform(platform)

drag_output = drag_tuning(beta_start=-4, beta_end=4, beta_step=0.5)

if drag_output.results.chi2[target][0] > 2:
raise (
raise RuntimeError(
f"Drag fit has chi2 {drag_output.results.chi2[target][0]} greater than 2. Stopping."
)
else:
drag_output.update_platform(platform)
drag_output.update_platform(platform)

rabi_output_3 = rabi_amplitude(
min_amp_factor=0.5,
max_amp_factor=1.5,
step_amp_factor=0.01,
pulse_length=platform.qubits[target].native_gates.RX.duration,
nshots=2048,
)


# update only if chi2 is satisfied
if rabi_output_3.results.chi2[target][0] > 2:
raise (
raise RuntimeError(
f"Rabi fit has chi2 {rabi_output_3.results.chi2[target][0]} greater than 2. Stopping."
)
else:
rabi_output_3.update_platform(platform)

meta.end()

# stop and disconnect platform
platform.disconnect()

history = executor.history
# dump history, metadata, and updated platform
output.history = history
output.dump(path)
rabi_output_3.update_platform(platform)

report(path, history)
close()
report(executor.path, executor.history)
Loading

0 comments on commit 8ff1ec1

Please sign in to comment.