Skip to content

Copilot tools for run, estimate, circuit #2380

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

Merged
merged 26 commits into from
May 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
14ac5d6
show copilot instructions prompt at startup
minestarks May 2, 2025
16fcea5
add lear more link
minestarks May 5, 2025
5d41881
Add copilot-instructions.md for our repo
minestarks May 6, 2025
b6664c9
Merge remote-tracking branch 'origin/qsharp-copilot-instructions' int…
minestarks May 6, 2025
ed84897
add run q# tool
minestarks May 6, 2025
c93745a
update copilot instructions
minestarks May 6, 2025
03ac040
update copilot instructions
minestarks May 6, 2025
1177957
add script to extract language service tools
minestarks May 7, 2025
3d41c9c
make test-workspace multiple folders, just to be annoying
minestarks May 7, 2025
a9278bd
Merge branch 'main' of https://github.com/microsoft/qsharp into mines…
minestarks May 7, 2025
fd41d1d
clean up my helper files
minestarks May 7, 2025
57d5819
take .qs path in tool
minestarks May 7, 2025
05152cd
estimate & circuit
minestarks May 8, 2025
85a7dfc
update tool descriptions
minestarks May 8, 2025
11c7a07
update with new tools
minestarks May 13, 2025
7e85f33
Merge branch 'main' of https://github.com/microsoft/qsharp into mines…
minestarks May 14, 2025
2c58928
simplify tool definition
minestarks May 14, 2025
98608f2
fix build
minestarks May 14, 2025
b215ada
remove crud
minestarks May 14, 2025
28f882a
more crud
minestarks May 14, 2025
6506be6
fix break from merge from main
minestarks May 14, 2025
293f445
Update vscode/package.json
billti May 14, 2025
57da672
Update vscode/package.json
billti May 14, 2025
7fb7e3b
Update vscode/package.json
billti May 14, 2025
2ba8423
Merge remote-tracking branch 'origin/main' into minestarks/copilot-tools
billti May 14, 2025
95ff1c2
Fix typo
billti May 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 111 additions & 1 deletion vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@
"command": "qsharp-vscode.copilotClear",
"category": "QDK",
"title": "Clear Quantum Copilot chat",
"enablement": "!qdkCopilotIsBusy",
"enablement": "config.Q#.chat.enabled && !qdkCopilotIsBusy",
"icon": "$(clear-all)"
},
{
Expand Down Expand Up @@ -828,6 +828,116 @@
],
"additionalProperties": false
}
},
{
"name": "qsharp-run-program",
"tags": [
"azure-quantum",
"qsharp",
"qdk"
],
"toolReferenceName": "qsharpRunProgram",
"displayName": "Run Q# Program",
"modelDescription": "Executes a Q# program. The path to a .qs file must be specified in the `filePath` parameter. A quantum simulator will be run locally. Q# does not provide any CLI tools, so call this tool whenever you need to execute Q#, instead of running any CLI commands. The `shots` parameter controls the number of times to repeat the simulation. If the number of shots is greater than 1, a histogram will be generated, and the results will be displayed in a dedicated panel.",
"canBeReferencedInPrompt": true,
"icon": "./resources/file-icon-light.svg",
"inputSchema": {
"type": "object",
"properties": {
"filePath": {
"type": "string",
"description": "The absolute path to the .qs file. If this file is part of a project, the whole project will be compiled as the program. A .qs file belongs to a project if it resides anywhere under a src/ directory whose parent directory also contains a qsharp.json manifest."
},
"shots": {
"type": "number",
"description": "The number of times to run the program. Defaults to 1 if not specified.",
"default": 1
}
},
"required": [
"filePath"
],
"additionalProperties": false
}
},
{
"name": "qsharp-generate-circuit",
"tags": [
"azure-quantum",
"qsharp",
"qdk"
],
"toolReferenceName": "qsharpGenerateCircuit",
"displayName": "Generate Q# Circuit Diagram",
"modelDescription": "Generates a visual circuit diagram for a Q# program. The path to a .qs file must be specified in the `filePath` parameter. This tool will compile the Q# program and generate a quantum circuit diagram that visually represents the quantum operations in the code. If the program contains any dynamic behavior such as comparing measurement results, then the program will be executed using a quantum simulator, and the resulting circuit diagram will simply be a trace of the operations that were actually executed during simulation. The diagram will be displayed in a dedicated circuit panel.",
"canBeReferencedInPrompt": true,
"icon": "./resources/file-icon-light.svg",
"inputSchema": {
"type": "object",
"properties": {
"filePath": {
"type": "string",
"description": "The absolute path to the .qs file. If this file is part of a project, the whole project will be compiled as the program. A .qs file belongs to a project if it resides anywhere under a src/ directory whose parent directory also contains a qsharp.json manifest."
}
},
"required": [
"filePath"
],
"additionalProperties": false
}
},
{
"name": "qsharp-run-resource-estimator",
"tags": [
"azure-quantum",
"qsharp",
"qdk"
],
"toolReferenceName": "qsharpRunResourceEstimator",
"displayName": "Run Q# Resource Estimator",
"modelDescription": "Runs the quantum resource estimator on a Q# program to calculate the required physical resources. The path to a .qs file must be specified in the `filePath` parameter. This tool will analyze the Q# program and generate estimates of the quantum resources required to run the algorithm, such as the number of qubits, T gates, and other quantum operations. Results will be displayed in a dedicated resource estimator panel.",
"canBeReferencedInPrompt": true,
"icon": "./resources/file-icon-light.svg",
"inputSchema": {
"type": "object",
"properties": {
"filePath": {
"type": "string",
"description": "The absolute path to the .qs file. If this file is part of a project, the whole project will be compiled as the program. A .qs file belongs to a project if it resides anywhere under a src/ directory whose parent directory also contains a qsharp.json manifest."
},
"qubitTypes": {
"type": "array",
"description": "Array of qubit type labels to use for resource estimation. Allowed values:\n- 'qubit_gate_ns_e3': Superconducting/spin qubit with 1e-3 error rate\n- 'qubit_gate_ns_e4': Superconducting/spin qubit with 1e-4 error rate\n- 'qubit_gate_us_e3': Trapped ion qubit with 1e-3 error rate\n- 'qubit_gate_us_e4': Trapped ion qubit with 1e-4 error rate\n- 'qubit_maj_ns_e4 + surface_code': Majorana qubit with 1e-4 error rate (surface code QEC)\n- 'qubit_maj_ns_e6 + surface_code': Majorana qubit with 1e-6 error rate (surface code QEC)\n- 'qubit_maj_ns_e4 + floquet_code': Majorana qubit with 1e-4 error rate (floquet code QEC)\n- 'qubit_maj_ns_e6 + floquet_code': Majorana qubit with 1e-6 error rate (floquet code QEC)",
"items": {
"type": "string",
"enum": [
"qubit_gate_ns_e3",
"qubit_gate_ns_e4",
"qubit_gate_us_e3",
"qubit_gate_us_e4",
"qubit_maj_ns_e4 + surface_code",
"qubit_maj_ns_e6 + surface_code",
"qubit_maj_ns_e4 + floquet_code",
"qubit_maj_ns_e6 + floquet_code"
]
},
"default": [
"qubit_gate_ns_e3"
]
},
"errorBudget": {
"type": "number",
"description": "Error budget for the resource estimation. Must be a number between 0 and 1. Default is 0.001.",
"minimum": 0,
"maximum": 1,
"default": 0.001
}
},
"required": [
"filePath"
],
"additionalProperties": false
}
}
]
},
Expand Down
4 changes: 2 additions & 2 deletions vscode/src/circuit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type CircuitParams = {
/**
* Result of a circuit generation attempt.
*/
type CircuitOrError = {
export type CircuitOrError = {
simulated: boolean;
} & (
| {
Expand Down Expand Up @@ -116,7 +116,7 @@ export async function showCircuitCommand(
* that means this is a dynamic circuit. We fall back to using the
* simulator in this case ("trace" mode), which is slower.
*/
async function generateCircuit(
export async function generateCircuit(
extensionUri: Uri,
params: CircuitParams,
): Promise<CircuitOrError> {
Expand Down
7 changes: 5 additions & 2 deletions vscode/src/debugger/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ function formatComplex(real: number, imag: number) {
return `${r}${i}`;
}

export function createDebugConsoleEventTarget(out: (message: string) => void) {
const eventTarget = new QscEventTarget(false);
export function createDebugConsoleEventTarget(
out: (message: string) => void,
captureEvents: boolean = false,
) {
const eventTarget = new QscEventTarget(captureEvents);

eventTarget.addEventListener("Message", (evt) => {
out(evt.detail + "\n");
Expand Down
Loading