Skip to content

PulseTarget protocol and reference implementation#12096

Closed
nkanazawa1989 wants to merge 5 commits into
Qiskit:feature/pulse-irfrom
nkanazawa1989:feature/pulse-target
Closed

PulseTarget protocol and reference implementation#12096
nkanazawa1989 wants to merge 5 commits into
Qiskit:feature/pulse-irfrom
nkanazawa1989:feature/pulse-target

Conversation

@nkanazawa1989
Copy link
Copy Markdown
Contributor

Summary

This PR adds Qiskit Target model for pulse domain, PulseTarget, and its reference implementation QiskitPulseTarget.

Details and comments

Currently PulseTarget only defines APIs that map Qiskit pulse model to hardware resources. This could be extended to include more information, such as generic parametric pulse schema, available frequency range of frames, and supported instruction types. But these are as-needed basis. Vendor can also define own Target class based on the protocol, that provides necessary information for vendor specific compiler passes. Qiskit implementation is bare minimum to support builtin pulse compiler passes in Qiskit.

@nkanazawa1989 nkanazawa1989 added mod: pulse Related to the Pulse module experimental labels Mar 28, 2024
@nkanazawa1989 nkanazawa1989 requested a review from TsafrirA March 28, 2024 11:14
@nkanazawa1989 nkanazawa1989 requested review from a team, eggerdj and wshanks as code owners March 28, 2024 11:14
@qiskit-bot
Copy link
Copy Markdown
Collaborator

One or more of the the following people are requested to review this:

  • @Qiskit/terra-core
  • @nkanazawa1989

Copy link
Copy Markdown
Contributor

@wshanks wshanks left a comment

Choose a reason for hiding this comment

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

This seems reasonable for reporting port logical functions (qubit, coupler) and standard frames. We might not want to limit the total number of frames per port.

I also wonder if we should think a little bit about how port-specific hardware constraints would be reported and see if we would change anything about the structure before accepting this.

Comment thread test/python/pulse/_dummy_targets.py
Comment thread qiskit/pulse/compiler/target.py Outdated
self,
qubit_frames: dict[int, str] | None = None,
meas_frames: dict[int, str] | None = None,
qubit_ports: dict[int, str] | None = None,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would accept meas_ports as well to be more generic.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, that makes sense. PR is updated but in more general fashion.

Comment thread test/python/pulse/test_target.py Outdated
2: "OnlyPort",
},
coupler_ports={
(0, 1): "PortA",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For non-directed couplers, would you put both directions here?

"This hardware doesn't provide any frame for "
f"MeasurementFrame of index {frame.index}."
) from ex
raise TypeError(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I see how the framework here allows for the pulse compiler to map Qubit and Coupler logical elements and QubitFrame and MeasurementFrame frames to hardware port and frame identifiers. What about defining additional logical elements or frames? This framewrok lists the port and frame identifiers, but how should the user set up the mapping? Does the user use the indentifiers from PulseTarget to create Port and GenericFrame instances with those identifiers as names to create MixedFrames and then the compiler will translate those directly without look up with the PulseTarget methods? Or should this method also have a clause for GenericFrame that returns frame.name, and should get_port_identifier similarly return port.name for a Port input?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I updated the model in 214185d. GenericFrame and Port are also considered. Since end-user cannot define ports, there is validation for port UID inside target. On the other hand, there is no UID validation for frame since I assume they can use arbitrary name. Of course there is limitation in number of available hardware resources, but this is something compiler pass must validate.

Copy link
Copy Markdown
Contributor

@wshanks wshanks left a comment

Choose a reason for hiding this comment

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

I like the direction of the changes. I still wonder about the balance between matching the model and keeping the hardware model generic.

Comment thread qiskit/pulse/compiler/target.py
Comment thread qiskit/pulse/compiler/target.py Outdated
available for this port to form a mixed frame.

tx_ports: A list of dictionary representing a spec of transmission ports.
The spec dictionary must contain "qubits", "op_type", "num_frames",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe this should be a class/protocol? I don't want to make it hard to extend the structure but it would be good to capture required fields for developers to reference.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good suggestion. It's turned into dataclass.

Comment thread qiskit/pulse/compiler/target.py Outdated
try:
return self._qubit_ports[port.qubit_index]
except KeyError as ex:
return self._get_port_common(signal_entry, "generic")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I wonder if _get_port_common should be a public interface, maybe with a default value for op_type? It seems awkward to use a special method for measure ports and another for everything else. Also, it feels like a language mismatch to label the ports "generic" and "measure" while the frames are "Qubit", "Measure" and "Generic" -- for one qubits are "generic" but for the other they are distinct from "Generic". Maybe the qubit port op types should be "control" and "measure" or something like that?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is reasonable suggestion. Two methods are merged into a single method get_port_identifier which is aligned with frame query get_frame_identifier.

@1ucian0
Copy link
Copy Markdown
Member

1ucian0 commented Sep 19, 2025

After Qiskit/RFCs#73 closing this PR.

@1ucian0 1ucian0 closed this Sep 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod: pulse Related to the Pulse module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants