Add TranspileLayout to the C API #14780
Open
+907
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This commit adds the TranspileLayout struct added in #14778 to the C
API. It is a straightforward addition to the API as the interface is
fairly simple. Given a pointer to a TranspileLayout the methods return
the arrays for the various views of the layout or the number of qubits
for the input and output circuits.
One small change was made to the PhysicalQubit and VirtualQubit type
definitions to use #[repr(transparent)] which in practice shouldn't
change anything, but it makes it explicit that these can be used
interchangeably with a u32. This simplifies how we can return arrays of
either type to C because it is safe to cast them as pointers to u32s.
Note that nothing in the C API is capable of generating a transpile
layout currently. The intent is for it to be part of the full
transpile() function return (see #14778). In the meantime this is
tested solely through rust tests and there aren't any tests written
in C yet. A potential follow up commit can be made to update the
standalone vf2 layout pass function to use a transpile layout inside
it's result type which would be more ergonomic than it's current
layout object in the result. But to keep this PR targeted this doesn't
update that interface and only exposes the struct to the C API.
Details and comments
This is based on #14778 and this PR will need to be rebased after #14778 merges. In the meantime you can view the content of this PR with the HEAD commit: 8efe505