Skip to content

QIR Profiles Selection via Project Field or EntryPoint argument #2591

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 35 commits into
base: main
Choose a base branch
from

Conversation

ScottCarda-MS
Copy link
Contributor

@ScottCarda-MS ScottCarda-MS commented Jul 14, 2025

This removes the workspace setting for the QIR profile and adds a setting for this for Q# project files instead, i.e. "targetProfile": "base". Single-file Q# files are supported by adding an argument to the @entrypoint attribute where a user will specify what profile the file is meant to compile with, i.e. @EntryPoint(Adaptive_RI), or uses Unrestricted as a default.

@ScottCarda-MS ScottCarda-MS marked this pull request as ready for review July 14, 2025 22:33
@ScottCarda-MS ScottCarda-MS changed the title Single File Profiles QIR Profiles Selection via Project Field or EntryPoint argument Jul 14, 2025
Comment on lines 56 to 57
let buildable_program = BuildableProgram::new(TargetCapabilityFlags::all(), pkg_graph, false);

Copy link
Collaborator

Choose a reason for hiding this comment

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

An enum is more desciptive and readable than passing a bool

Copy link
Collaborator

Choose a reason for hiding this comment

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

Agreed... it's a little more hoop-jumping, but something like ProjectType::SingleFile vs ProjectType::Project would make it abundantly clear what is being used here and in other places where the option is passed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, there is already a ProjectType, so another name, maybe ProjectStructure or something like that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since moving this into the packageGraphSources struct, we only ever see this Boolean accompanied by the field name has_manifest. I'm hoping that is sufficient to provide clarity and readability now.

Comment on lines 56 to 57
let buildable_program = BuildableProgram::new(TargetCapabilityFlags::all(), pkg_graph, false);

Copy link
Collaborator

Choose a reason for hiding this comment

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

Agreed... it's a little more hoop-jumping, but something like ProjectType::SingleFile vs ProjectType::Project would make it abundantly clear what is being used here and in other places where the option is passed.

Comment on lines 56 to 57
let buildable_program = BuildableProgram::new(TargetCapabilityFlags::all(), pkg_graph, false);

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, there is already a ProjectType, so another name, maybe ProjectStructure or something like that.

Copy link
Member

Choose a reason for hiding this comment

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

I can't understand why these tests had to change so much. I can't find any meaningful changes in the language service that would have made these changes necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is because before the changes, we were passing in the target profile as an extra argument to the compilation. Now target profile needs to be specified by the source code, either in the manifest or in an entrypoint argument.

);
} else {
await setTarget(targetSupportsAdaptive ? "adaptive_ri" : "base");
// Try to update the qsharp.json manifest automatically.
Copy link
Member

Choose a reason for hiding this comment

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

Was this behavior decided as part of a team discussion or something? It's weird. Can we just open the qsharp.json and let the user change the file if they want to?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was reflecting the existing behavior of that option, which updates the global profile setting. A button that says "Set the QIR profile to Base to continue" should do the actual setting, imho

Copy link
Member

@minestarks minestarks left a comment

Choose a reason for hiding this comment

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

Looks great overall. The excessive isSingleFile plumbing is the only real issue I see which should just go away if you stick it inside the appropriate struct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants