-
Notifications
You must be signed in to change notification settings - Fork 71
[FEAT] Add NoiseModel.summary() #990
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
|
I think it would be nice to showcase this in the |
HGSilveri
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please make me an example with all the noises so I can check how everything is rendering?
| ) | ||
|
|
||
| def get_noise_table(self) -> dict[str, tuple[Any, str]]: | ||
| """Maps noise quantities impacting simu. with their value and units.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could shorten this to
| """Maps noise quantities impacting simu. with their value and units.""" | |
| """Maps non-zero noise quantities with their value and units.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, a Returns section could be nice
| _summary = "Noise summary:\n" | ||
| noise_table = self.get_noise_table() | ||
| add_to_traj_summary = [] | ||
| # Follow the impact as in step-by-step tutorial | ||
| if "register_sigma_xy" in noise_table: | ||
| assert "register_sigma_z" in noise_table | ||
| # 1. Register | ||
| _summary += "- Register Position Fluctuations**:\n" | ||
| _summary += ( | ||
| " - XY-Plane Position Fluctuations: " | ||
| f"{_repr_value_unit(*noise_table['register_sigma_xy'])}\n" | ||
| ) | ||
| _summary += ( | ||
| " - Z-Axis Position Fluctuations: " | ||
| f"{_repr_value_unit(*noise_table['register_sigma_z'])}\n" | ||
| ) | ||
| add_to_traj_summary.append("register, ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here my general reccomendation would be to create list of lines that you join at the end with "\n", so you would go like this
| _summary = "Noise summary:\n" | |
| noise_table = self.get_noise_table() | |
| add_to_traj_summary = [] | |
| # Follow the impact as in step-by-step tutorial | |
| if "register_sigma_xy" in noise_table: | |
| assert "register_sigma_z" in noise_table | |
| # 1. Register | |
| _summary += "- Register Position Fluctuations**:\n" | |
| _summary += ( | |
| " - XY-Plane Position Fluctuations: " | |
| f"{_repr_value_unit(*noise_table['register_sigma_xy'])}\n" | |
| ) | |
| _summary += ( | |
| " - Z-Axis Position Fluctuations: " | |
| f"{_repr_value_unit(*noise_table['register_sigma_z'])}\n" | |
| ) | |
| add_to_traj_summary.append("register, ") | |
| _summary = ["Noise summary:"] | |
| noise_table = self.get_noise_table() | |
| add_to_traj_summary = [] | |
| # Follow the impact as in step-by-step tutorial | |
| if "register_sigma_xy" in noise_table: | |
| assert "register_sigma_z" in noise_table | |
| # 1. Register | |
| _summary += [ | |
| "- Register Position Fluctuations**:", | |
| " - XY-Plane Position Fluctuations: " | |
| f"{_repr_value_unit(*noise_table['register_sigma_xy'])}", | |
| " - Z-Axis Position Fluctuations: " | |
| f"{_repr_value_unit(*noise_table['register_sigma_z'])}", | |
| ] | |
| add_to_traj_summary.append("register, ") |
I prefer this because I find it more readable and you don't have to care about the \n everywhere.
| def _repr_value_unit(value: Any, unit: str) -> str: | ||
| if unit == "": | ||
| return f"{value}" | ||
| return f"{value} {unit}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should round floats to a few significant digits (maybe the Python default of 6 is fine):
| def _repr_value_unit(value: Any, unit: str) -> str: | |
| if unit == "": | |
| return f"{value}" | |
| return f"{value} {unit}" | |
| def _repr_value_unit(value: Any, unit: str) -> str: | |
| value_str = f"{value:g}" if isinstance(value, float) else f"{value}" | |
| if unit == "": | |
| return value_str | |
| return f"{value_str} {unit}" |
| for rate, oper in noise_table["eff_noise"][0]: | ||
| _summary += f" - {rate} * {oper}\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How well does this render?
Summarize the effect of the noises in the NoiseModel on the atoms, in order of appearance in the Sequence (Register, state initialization, amplitude, detuning, noise channels, measurement).
It's a verbose summary, as a string. I find this is the most useful to summarize the noise effects. I think we can have another issue where we provide the most noise quantities as a dictionnary (if needed).
Sums up the quantities that will be resampled when generating the trajectories at the end of the summary (signals them with *, not to confound T2 with such quantity). Didn't write NoiseModel.runs since it's now deprecated.
Fixes #966