Skip to content

Commit

Permalink
Reworking the NoiseModel interface (#710)
Browse files Browse the repository at this point in the history
* First rework of the NoiseModel interface

* Fix typing

* Avoid resampling when amp_sigma=0

* Isolating code to find relevant noise parameters

* Define a custom NoiseModel.__repr__()

* Deprecating noise_types definition

* Improving adjacent UTs

* Complete NoiseModel UTs

* Update NoiseModel JSON schema

* Fix docstring indentation

* Implementing review suggestions

* Allowing temperature to be 0

* Disallow temperature to be null in JSON schema
  • Loading branch information
HGSilveri authored Jul 19, 2024
1 parent e16257a commit 1b3735d
Show file tree
Hide file tree
Showing 12 changed files with 679 additions and 269 deletions.
8 changes: 6 additions & 2 deletions pulser-core/pulser/json/abstract_repr/deserializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ def _deserialize_register3d(

def _deserialize_noise_model(noise_model_obj: dict[str, Any]) -> NoiseModel:

def convert_complex(obj: list | tuple) -> list:
def convert_complex(obj: Any) -> Any:
if isinstance(obj, (list, tuple)):
return [convert_complex(e) for e in obj]
elif isinstance(obj, dict):
Expand All @@ -423,11 +423,15 @@ def convert_complex(obj: list | tuple) -> list:
for rate, oper in noise_model_obj.pop("eff_noise"):
eff_noise_rates.append(rate)
eff_noise_opers.append(convert_complex(oper))
return pulser.NoiseModel(

noise_types = noise_model_obj.pop("noise_types")
noise_model = pulser.NoiseModel(
**noise_model_obj,
eff_noise_rates=tuple(eff_noise_rates),
eff_noise_opers=tuple(eff_noise_opers),
)
assert set(noise_model.noise_types) == set(noise_types)
return noise_model


def _deserialize_device_object(obj: dict[str, Any]) -> Device | VirtualDevice:
Expand Down
15 changes: 12 additions & 3 deletions pulser-core/pulser/json/abstract_repr/schemas/noise-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@
"type": "number"
},
"laser_waist": {
"type": "number"
"type": [
"number",
"null"
]
},
"noise_types": {
"items": {
Expand All @@ -84,10 +87,16 @@
"type": "number"
},
"runs": {
"type": "number"
"type": [
"number",
"null"
]
},
"samples_per_run": {
"type": "number"
"type": [
"number",
"null"
]
},
"state_prep_error": {
"type": "number"
Expand Down
Loading

0 comments on commit 1b3735d

Please sign in to comment.