Repository: Qiskit/qiskit

Issue:
No support for transpiling `Schedule`
### Environment

- **Qiskit version**: 1.1.0
- **Python version**: 3.11
- **Operating system**: macos


### What is happening?

[Documentation](https://docs.quantum.ibm.com/api/qiskit/pulse) says that is possible to run a pulse level program by calling `backend.run(transpile(pulse_prog, backend))`. However, that is not yet supported.

### How can we reproduce the issue?

Just run the example in the documentation 

```python
from qiskit import pulse, transpile
 
d0 = pulse.DriveChannel(0)
 
with pulse.build() as pulse_prog:
    pulse.play(pulse.Constant(100, 1.0), d0)

transpile(pulse_prog, backend)
```


### What should happen?

transpile successfully 

### Any suggestions?

_No response_


Discussion:
Thanks - this is a documentation mistake stemming from the removal of `execute` in Qiskit/qiskit#11565.  `Schedule`s cannot be transpiled.  There was (a _long_ time ago) support planned, but it never materialised.

That documentation originally said that `Schedule`s can be _executed_ the same as circuits, where `execute` was (for circuits) a wrapper around `backend.run` and `transpile`.  For `Schedule`, however, it never did any transpilation, it just submitted it to the backend.

If there are still pulse-enabled backends (I'm not 100% certain on the states of what's allowed for submission), then you would be able to do `backend.run(pulse_prog)`.
Thanks for the prompt reply!

I just tried `backend.run(pulse_prog)` with `ibm_kyoto` for example (`open_pulse=True`) and it fails with 

<img width="565" alt="Screenshot 2024-05-20 at 17 11 53" src="https://github.com/Qiskit/qiskit/assets/48832149/6bf45774-9c44-4cd9-b3b5-925a12930395">

I've tried the hack of adding a schedule to a custom gate with `add_calibration` and run the corresponding circuit instead. But when I try to control the measurement pulse, the job gets submitted and then fails with `Unknown Error`
> I've tried the hack of adding a schedule to a custom gate with add_calibration and run the corresponding circuit instead.

Attaching pulse schedules as gate calibrations is the only supported method of submitting pulse instructions to IBM backends now.

> when I try to control the measurement pulse, the job gets submitted and then fails with Unknown Error

It is possible to customize the measurement pulse. I have only done it by providing a pulse gate calibration for the `measure` instruction personally. If you want to share more of what you tried, we can try to debug what is happening. If you are not testing custom measurement, the easiest option is to use a pulse gate calibration for your control pulses and use the default `measure` gate.

We can also discuss in the `#open-pulse` channel in [Qiskit Slack](https://qisk.it/join-slack).
Thank you! I've put an example code of what im trying to do here Qiskit/qiskit-ibm-runtime#1693

> If you are not testing custom measurement, the easiest option is to use a pulse gate calibration for your control pulses and use the default measure gate.

I'm trying custom measurements.

How did you provide a gate calibration for the `measure` instruction?
I can try running your code and see if I understand the error. Compared to what you have there what I usually do is `ground_circuit.measure(0, 0)` and then `ground_circuit.add_calibration("measure", ...)`. I am not sure if `measure` is handled specially in the backend or just there is something else wrong with what you tried.
ofc, makes sense! I thought measure was handled differently from the rest of the gates. Will give that a try although now the queue is 9hrs xd. So if you have priority access would appreciate to hear if it worked for you 😅

Resolving patch:
diff --git a/qiskit/pulse/builder.py b/qiskit/pulse/builder.py
--- a/qiskit/pulse/builder.py
+++ b/qiskit/pulse/builder.py
@@ -74,8 +74,8 @@
 
 The builder initializes a :class:`.pulse.Schedule`, ``pulse_prog``
 and then begins to construct the program within the context. The output pulse
-schedule will survive after the context is exited and can be transpiled and executed like a
-normal Qiskit schedule using ``backend.run(transpile(pulse_prog, backend))``.
+schedule will survive after the context is exited and can be used like a
+normal Qiskit schedule.
 
 Pulse programming has a simple imperative style. This leaves the programmer
 to worry about the raw experimental physics of pulse programming and not


Test patch: