Skip to content
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

Change EmuTN default sampling rate #578

Merged
merged 6 commits into from
Sep 15, 2023

Conversation

lvignoli
Copy link
Collaborator

The default sampling rate, inherited from EmulatorConfig defaults, is 1.

If I am not mistaken, this translates to dt=1 for the EmuTN job runned by cloud services, which is not a viable value.

I open this MR not for a blind merge, but rather to make sure the above interpretation of sampling_rate for EmuTnBackend is right, and reflect on a good default value.

@awennersteen
Copy link
Member

Actually this might not be sufficient, EmuTN does not use a sampling rate but rather dt, so I think maybe this interface isn't correct. I've not really reviewed or used it so not sure.

EmuTN uses a dt value which is the time in nanoseconds of the timestep used during integration. the default value is 10, and indeed 1 is very low for most purposes. a value < 1 is also not permitted (it must be a a positive integer)

@HGSilveri
Copy link
Collaborator

There is an internal conversion from sampling_rate to dt: dt = 1/ sampling_rate. So, dt is never < 1. If having dt=10 is a better default than dt=1, then I'm okay with changing the default sampling rate to 0.1, as this PR suggests.

@lvignoli
Copy link
Collaborator Author

The default value for for dt in EmuTN (the -t flag) is 10.0, so I would say sampling_rate=0.1 is a saner default.

@HGSilveri
Copy link
Collaborator

@awennersteen Can dt assume a non-integer value?

@lvignoli
Copy link
Collaborator Author

lvignoli commented Sep 13, 2023

The docstring should be updated to reflect the fact that sampling_rate must be quite small for EmuTNBackend (<= 1e-1) to use the backend properly.

@HGSilveri
Copy link
Collaborator

The default value for for dt in EmuTN (the -t flag) is 10.0, so I would say sampling_rate=0.1 is a saner default.

My original intention with EmulatorConfig was to uniformize all the emulator configs as much as possible (with the rationale that switching the EmulatorBackend while keeping the default config should introduce as few changes as possible).

That being said, I'm not opposed to this change, I'll defer to your judgement on it.

@HGSilveri
Copy link
Collaborator

The docstring should be updated to reflect the fact that sampling_rate must be quite small for EmuTNBackend (≥ 1e-1) to use the backend properly.

Do you mean <= 1e-1? And what do you mean by "properly"?

@lvignoli
Copy link
Collaborator Author

Yes, smaller than, I edited the comment.

Properly here meaning with acceptable default runtime.

@lvignoli
Copy link
Collaborator Author

I understand the original motivation for having some homogeneity in the parameters across the backends.

But since different backends serve different purposes, one cannot expect parameters to have the same impact. So it is not a huge loss—to me, at least!

@HGSilveri
Copy link
Collaborator

Yes, smaller than, I edited the comment.

Properly here meaning with acceptable default runtime.

Ok, gotcha, feel free to add this info to the docstring.

@awennersteen
Copy link
Member

@awennersteen Can dt assume a non-integer value?
apparently yes. I was speaking out of habit way in the past when it was an integer. I just checked and we expect a float.

as Louis says setting sampling_rate so that dt=10 is much better, and most uses cases will want such a timestep. dt=1 would be quite exceptional

@HGSilveri HGSilveri added this to the v0.15 Release milestone Sep 14, 2023
@lvignoli
Copy link
Collaborator Author

@HGSilveri some test are failing about "good arguments", I am not sure how to fix them.

@HGSilveri
Copy link
Collaborator

@HGSilveri some test are failing about "good arguments", I am not sure how to fix them.

You have to change this line:

sdk_config = EmuTNConfig(dt=1.0)

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.

LGTM, thanks!

@HGSilveri
Copy link
Collaborator

Oh damn, the new matplotlib release has type hints 😨

@HGSilveri HGSilveri merged commit d9e1fd2 into pasqal-io:develop Sep 15, 2023
6 checks passed
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.

3 participants