PML-256 : hardware aware model design#275
Conversation
LF-Vigneux
left a comment
There was a problem hiding this comment.
First requested changes
| When designing models for physical hardware execution, selecting the appropriate computation space is critical. | ||
|
|
||
| * **Recommended:** Use ``ComputationSpace.unbunched`` or ``ComputationSpace.DUAL_RAIL``. | ||
| * **Avoid:** ``ComputationSpace.bunched`` and ``ComputationSpace.FOCK``. Physical photonic QPUs do not natively support bunched states or arbitrary Fock spaces due to hardware limitations. |
There was a problem hiding this comment.
You can say that the current hardware does not support the FOCK space since we do not have photon number resolving detectors. That is the main cause, you can say that it is mainly because of this and other limitations
There was a problem hiding this comment.
avoid ComputationSpace.FOCK for hardware-targeted models unless explicitly justified, that is the main claim that the ticket showed
| State Encoding | ||
| -------------- | ||
|
|
||
| Photonic QPUs do not natively perform amplitude encoding. |
There was a problem hiding this comment.
Again please detail that amplitude encoding is difficult because arbitrary dense state preparation is not hardware-realistic. The circuit can be very bug and not trivial to implement
| * ``mode_expectations`` (Average photon counts per mode) | ||
| * ``sampled counts/probabilities`` (Shot-based measurements) | ||
|
|
||
| * **Unsupported:** Raw amplitudes or ``StateVector`` outputs cannot be directly retrieved from physical hardware. |
There was a problem hiding this comment.
Indeed, we only have shots, so the amplitudes can not be retrieved but the rest can be deduced
There was a problem hiding this comment.
Just reiterate that we only have sots/samples
|
|
||
| * **Supported:** | ||
|
|
||
| * ``probabilities`` (Full probability distribution) |
There was a problem hiding this comment.
it is derived from the the counts on the hardware, not from the amplitudes.
| input_size=4, # Number of classical features | ||
| Experiment=ComputationSpace.UNBUNCHED, # UNBUNCHED or DUAL_RAIL for hardware | ||
| builder=builder, | ||
| n_photons=3, # Equivalent to input_state = [1, 1, 1, 0, 0, 0] |
There was a problem hiding this comment.
This is not True: [1,0,1,0,1,0]
| * **Component Selection:** Favor native photonic components such as Mach-Zehnder Interferometers (MZI), beam splitters, and phase shifters, as they map directly to the QPU's physical architecture. | ||
| * **Circuit Depth:** Avoid unnecessarily deep circuits. Large simulated circuits may scale poorly during hardware compilation (transpilation), leading to suboptimal or inefficient physical implementations on a constrained QPU. | ||
|
|
||
| Recommended Architecture Pattern |
There was a problem hiding this comment.
Add all the steps from the Recommended model pattern section in the ticket
There was a problem hiding this comment.
From the ticket, you are missing:
- Shot-efficiency guidance:
- Unsupported or discouraged features for the first hardware-aware guide
There was a problem hiding this comment.
Only missing shot efficiency guidance
There was a problem hiding this comment.
This is not as clear as it can get. Identify it clearly.
The page clearly separates:
hardware-oriented designs
simulation-only designs
discouraged-but-possible designs.
|
@claude review |
|
Claude finished @LF-Vigneux's task in 1m 20s —— View job Code Review: Hardware-Aware Model Design docsI reviewed the two changed files against the actual MerLin API on 🔴 Incorrect API references (will mislead users / won't run)
🟠 Content gaps (echoing the existing review thread — still open)These were flagged inline by @LF-Vigneux and are not yet addressed:
🟠 Structure / clarity
🟡 Minor (RST)
Overall: the page is a good start and the structure is sensible, but the code example and the I've only reviewed here — happy to implement any of these fixes if you reply with |
| * ``mode_expectations`` (Average photon counts per mode) | ||
| * ``sampled counts/probabilities`` (Shot-based measurements) | ||
|
|
||
| * **Unsupported:** Raw amplitudes or ``StateVector`` outputs cannot be directly retrieved from physical hardware. |
There was a problem hiding this comment.
Just reiterate that we only have sots/samples
There was a problem hiding this comment.
Only missing shot efficiency guidance
Summary
This PR allow user to have a clear documentation on how to design a hardware-aware model. this documentation is added to user guide.
Related Issue
Type of change
Proposed changes
How to test / How to run
Screenshots / Logs (optional)
Performance considerations (optional)
Documentation
Checklist
PR title includes Jira issue key (e.g., PML-126)
"Related Jira ticket" section includes the Jira issue key (no URL)
Code formatted (ruff format)
Lint passes (ruff)
Static typing passes (mypy) if applicable
Unit tests added/updated (pytest)
Tests pass locally (pytest)
Tests pass on GPU (pytest)
Test coverage not decreased significantly
Docs build locally if affected (sphinx)
With this command:
the docs are built without any warning or errors.
New public classes/methods/packages are added in the API following the methodology presented in other files.
Dependencies updated (if needed) and pinned appropriately
PR description explains what changed and how to validate it