microsoft / iqsharp

Microsoft's IQ# Server.
https://docs.microsoft.com/quantum
MIT License
127 stars 58 forks source link

Lambdas lifted by Q# compiler appear in output from Q# code cells #644

Open cgranade opened 2 years ago

cgranade commented 2 years ago

Describe the bug When running a Q# code cell in a Q# notebook, operations and functions lifted from lambda expressions appear in user-facing output as part of the contents of that cell.

To Reproduce

image

Expected behavior The lifted lambda operation _0f141307913a4d19bd95bb7f235180d5_ApplyWithDistributedControlled should not appear in the user-facing output.

System information

image

Additional context @samarsha: Do you know if there's any property set on the AST representation of lifted lambdas that could be used to filter them out from the IQ# kernel side? Thanks!

bamarsha commented 2 years ago

@ScottCarda-MS worked on the lambda lifting, do you know if there's a way to identify a lifted lambda?

ScottCarda-MS commented 2 years ago

The lifted lambdas are meant to not be any different from if the callables were written manually. Maybe we could add an internal attribute that we could add to all generated callables to identify them as generated?

cgranade commented 2 years ago

I think such an attribute would be really helpful for interop with Python hosts, yeah. It's a bit confusing to list automatically lifted callables next to callables that the user intended to define and make available directly to other code.