Skip to content

Conversation

@a-corni
Copy link
Collaborator

@a-corni a-corni commented Jan 16, 2026

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

@HGSilveri
Copy link
Collaborator

I think it would be nice to showcase this in the Noise Model tutorial (and it would also give me a good example to look at 😅 )

Copy link
Collaborator

@HGSilveri HGSilveri left a 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."""
Copy link
Collaborator

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

Suggested change
"""Maps noise quantities impacting simu. with their value and units."""
"""Maps non-zero noise quantities with their value and units."""

Copy link
Collaborator

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

Comment on lines +736 to +752
_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, ")
Copy link
Collaborator

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

Suggested change
_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.

Comment on lines +731 to +734
def _repr_value_unit(value: Any, unit: str) -> str:
if unit == "":
return f"{value}"
return f"{value} {unit}"
Copy link
Collaborator

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):

Suggested change
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}"

Comment on lines +843 to +844
for rate, oper in noise_table["eff_noise"][0]:
_summary += f" - {rate} * {oper}\n"
Copy link
Collaborator

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add report generation functionality for NoiseModel

3 participants