Skip to content

Conversation

@andrea-pasquale
Copy link
Contributor

This PR adds the possibility to set the sampling rate for the emulator, which is particularly useful for running experiments that requires higher sampling rate.

@codecov
Copy link

codecov bot commented Nov 10, 2025

Codecov Report

❌ Patch coverage is 93.33333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 40.19%. Comparing base (9cc32de) to head (8ab81e5).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
src/qibolab/_core/instruments/emulator/emulator.py 92.85% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1325      +/-   ##
==========================================
+ Coverage   40.15%   40.19%   +0.03%     
==========================================
  Files         113      113              
  Lines        5531     5536       +5     
==========================================
+ Hits         2221     2225       +4     
- Misses       3310     3311       +1     
Flag Coverage Δ
unittests 40.19% <93.33%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@andrea-pasquale andrea-pasquale marked this pull request as ready for review November 10, 2025 10:39
@alecandido alecandido self-requested a review November 12, 2025 09:23
Copy link
Member

@alecandido alecandido left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor comment, but this is already good. Thanks!

class EmulatorController(Controller):
"""Emulator controller."""

sampling_rate_: float = Field(1, exclude=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you exclude for compatibility with the previous platforms? Is it required despite the default?

In case, I would just suggest not to worry too much about breaking. It is definitely better not to do it, but if that's happening rarely and in more and more isolated corners[*] it is more or less acceptable. We're not yet that stable, so it is fine to allow some wiggle room.

[*]: this not really a corner, but it would only break emulator-based platforms, at most (not even sure), and while the emulator is certainly useful, we never dedicated enough effort to claim that the overall structure is quite stable - at least, we could break something, if it's only happening seldom

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did this in order to have the property and property.setter working below. I don't know if there is another way to make it working.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see.

Rodolfo was doing the same for the Qibosoq driver, but he did not need to exclude the field

class RFSoC(Controller):
"""Instrument controlling RFSoC FPGAs."""
bounds: str = "rfsoc/bounds"
_sampling_rate: float = 10e9

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, let me try to remove it to see if everything works as expected.

Comment on lines +50 to +56
@property
def sampling_rate(self) -> float:
return self.sampling_rate_

@sampling_rate.setter
def sampling_rate(self, value: float):
self.sampling_rate_ = value
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is annoying - I need to investigate and solve this problem...

However, I was considering to completely drop the sampling_rate as an overall property. In principle, even within a controller, it may differ by physical port, or input vs output. #1292

What do you think about it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a strong preference, as long as we can set it in a more user-friendly way.

Copy link
Member

@alecandido alecandido Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is that it will end up in the parameters.json, in particular in the configs. So, it will be as much inconvenient as anything else in there :P

(at some point we could make both documentation for the parameters.json structure, which could be generated automatically through Pydantic and JSON schema-based docs frameworks, and a more user-friendly interface to generate updates - at that point, even the sampling rate will benefit of those)

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