microsoft / qsharp

Azure Quantum Development Kit, including the Q# programming language, resource estimator, and Quantum Katas
https://microsoft.github.io/qsharp/
MIT License
367 stars 73 forks source link

Refactor: Consolidate "active Q# program" logic in VS Code #1623

Closed minestarks closed 1 week ago

minestarks commented 2 weeks ago

This is in preparation for the package work, but I think it's a useful refactor in its own right. No behavior changes.

There are quite a few features/commands across the VS Code extension* that are meant to operate on the "currently active Q# project". This is defined as the Q# document in the currently active editor, and if that document is associated with a qsharp.json, the entire project.

This code was duplicated across all these commands, and was slightly different everywhere. There have been bugs where we weren't respecting some of the common settings (e.g. #1565) and changes where we had to update each command separately if we changed something about project semantics (e.g. #1089, #918) . This PR aims to unify all that so we touch fewer places when we change something about the project compiler configuration logic.

*Run, Debug, Circuit, Estimate, Histogram commands, Show Documentation, Get QIR and Submit to Azure.

github-actions[bot] commented 2 weeks ago

Benchmark for a0b5ec6

Click to view benchmark | Test | Base | PR | % | |------|--------------|------------------|---| | Array append evaluation | 329.3±6.49µs | 331.0±2.33µs | +0.52% | | Array literal evaluation | 189.3±0.80µs | 189.7±3.68µs | +0.21% | | Array update evaluation | **409.9±4.09µs** | 413.2±1.39µs | **+0.81%** | | Core + Standard library compilation | 21.2±0.84ms | 20.8±0.66ms | -1.89% | | Deutsch-Jozsa evaluation | 5.1±0.05ms | 5.1±0.05ms | 0.00% | | Large file parity evaluation | **34.1±0.08ms** | 34.2±0.93ms | **+0.29%** | | Large input file compilation | 14.2±0.40ms | **13.5±0.64ms** | **-4.93%** | | Large input file compilation (interpreter) | 52.9±1.70ms | 51.8±1.78ms | -2.08% | | Large nested iteration | 32.4±0.43ms | 32.5±0.30ms | +0.31% | | Perform Runtime Capabilities Analysis (RCA) on Deutsch-Jozsa sample | 1633.1±143.83µs | 1615.7±129.12µs | -1.07% | | Perform Runtime Capabilities Analysis (RCA) on large file sample | 8.2±0.24ms | 8.2±0.34ms | 0.00% | | Perform Runtime Capabilities Analysis (RCA) on teleport sample | 1490.9±157.80µs | 1467.4±118.32µs | -1.58% | | Perform Runtime Capabilities Analysis (RCA) on the core and std libraries | 29.1±0.27ms | 29.0±0.34ms | -0.34% | | Teleport evaluation | 89.3±4.57µs | 88.4±4.02µs | -1.01% |
github-actions[bot] commented 2 weeks ago

Benchmark for cef9b56

Click to view benchmark | Test | Base | PR | % | |------|--------------|------------------|---| | Array append evaluation | 328.9±5.80µs | 331.0±6.74µs | +0.64% | | Array literal evaluation | 195.2±4.51µs | 195.4±5.05µs | +0.10% | | Array update evaluation | **408.8±1.77µs** | 411.0±6.49µs | **+0.54%** | | Core + Standard library compilation | 19.0±0.66ms | 18.8±0.32ms | -1.05% | | Deutsch-Jozsa evaluation | 5.1±0.05ms | 5.1±0.05ms | 0.00% | | Large file parity evaluation | **34.0±0.08ms** | 34.1±0.40ms | **+0.29%** | | Large input file compilation | 12.7±0.17ms | **12.4±0.18ms** | **-2.36%** | | Large input file compilation (interpreter) | 49.0±1.12ms | 49.1±2.01ms | +0.20% | | Large nested iteration | 32.7±1.52ms | 32.6±0.70ms | -0.31% | | Perform Runtime Capabilities Analysis (RCA) on Deutsch-Jozsa sample | 1570.1±37.35µs | 1576.3±57.41µs | +0.39% | | Perform Runtime Capabilities Analysis (RCA) on large file sample | 7.8±0.10ms | 7.8±0.09ms | 0.00% | | Perform Runtime Capabilities Analysis (RCA) on teleport sample | 1432.2±34.21µs | 1429.9±32.30µs | -0.16% | | Perform Runtime Capabilities Analysis (RCA) on the core and std libraries | 28.4±1.18ms | 28.3±0.62ms | -0.35% | | Teleport evaluation | 88.9±3.73µs | 88.6±3.44µs | -0.34% |
github-actions[bot] commented 1 week ago

Benchmark for 3a88555

Click to view benchmark | Test | Base | PR | % | |------|--------------|------------------|---| | Array append evaluation | 324.5±1.89µs | 325.5±3.63µs | +0.31% | | Array literal evaluation | **192.5±2.84µs** | 196.3±4.35µs | **+1.97%** | | Array update evaluation | 408.3±1.44µs | 409.5±3.37µs | +0.29% | | Core + Standard library compilation | **20.0±0.09ms** | 20.1±0.27ms | **+0.50%** | | Deutsch-Jozsa evaluation | 5.1±0.06ms | 5.1±0.10ms | 0.00% | | Large file parity evaluation | **33.9±0.07ms** | 34.1±0.81ms | **+0.59%** | | Large input file compilation | 12.4±0.12ms | **12.3±0.07ms** | **-0.81%** | | Large input file compilation (interpreter) | 48.3±0.92ms | 47.8±0.83ms | -1.04% | | Large nested iteration | 32.2±0.37ms | 32.1±0.19ms | -0.31% | | Perform Runtime Capabilities Analysis (RCA) on Deutsch-Jozsa sample | 1549.9±33.19µs | 1553.5±28.92µs | +0.23% | | Perform Runtime Capabilities Analysis (RCA) on large file sample | 7.8±0.12ms | 7.7±0.11ms | -1.28% | | Perform Runtime Capabilities Analysis (RCA) on teleport sample | 1414.3±30.50µs | 1415.7±30.99µs | +0.10% | | Perform Runtime Capabilities Analysis (RCA) on the core and std libraries | 28.0±0.33ms | 28.0±0.22ms | 0.00% | | Teleport evaluation | 89.7±3.62µs | 89.8±4.09µs | +0.11% |
github-actions[bot] commented 1 week ago

Benchmark for 8d7ad21

Click to view benchmark | Test | Base | PR | % | |------|--------------|------------------|---| | Array append evaluation | 325.3±1.60µs | 326.0±3.47µs | +0.22% | | Array literal evaluation | 192.4±1.33µs | 193.1±1.79µs | +0.36% | | Array update evaluation | 406.4±3.54µs | 406.2±7.30µs | -0.05% | | Core + Standard library compilation | 20.4±0.65ms | 20.6±0.49ms | +0.98% | | Deutsch-Jozsa evaluation | 5.1±0.05ms | 5.1±0.15ms | 0.00% | | Large file parity evaluation | 34.3±0.17ms | 34.3±0.59ms | 0.00% | | Large input file compilation | 12.5±0.27ms | 12.6±0.26ms | +0.80% | | Large input file compilation (interpreter) | 49.8±1.56ms | **48.5±1.18ms** | **-2.61%** | | Large nested iteration | **32.3±0.25ms** | 33.6±2.74ms | **+4.02%** | | Perform Runtime Capabilities Analysis (RCA) on Deutsch-Jozsa sample | 1579.6±42.50µs | 1555.1±41.73µs | -1.55% | | Perform Runtime Capabilities Analysis (RCA) on large file sample | 7.9±0.22ms | 7.8±0.13ms | -1.27% | | Perform Runtime Capabilities Analysis (RCA) on teleport sample | 1425.7±46.51µs | 1422.6±37.09µs | -0.22% | | Perform Runtime Capabilities Analysis (RCA) on the core and std libraries | 28.0±0.24ms | 28.0±0.25ms | 0.00% | | Teleport evaluation | 90.3±4.05µs | 89.5±3.51µs | -0.89% |
sezna commented 1 week ago

test failure in CI: https://github.com/microsoft/qsharp/actions/runs/9575713105/job/26400994276?pr=1623#step:9:4573

minestarks commented 1 week ago

Huh, that's almost certainly not due to these changes since it's in kata validation.

@cesarzc / @tcNickolas I think we may have a flaky kata:

 # Subtest: key_distribution kata is valid
  not ok 21 - key_distribution kata is valid
    ---
    duration_ms: 97.515708
    failureType: 'testCodeFailure'
    error: 'Solution "key_distribution__random_array_solution" for exercise "key_distribution__random_array" is incorrect'
    code: 'ERR_ASSERTION'
    name: 'AssertionError'
    expected: true
    actual: false
    operator: '=='
    stack: |-
      validateExercise (file:///home/runner/work/qsharp/qsharp/npm/qsharp/test/basics.js:260:7)
      async validateKata (file:///home/runner/work/qsharp/qsharp/npm/qsharp/test/basics.js:279:5)
      async TestContext.<anonymous> (file:///home/runner/work/qsharp/qsharp/npm/qsharp/test/basics.js:316:5)
      async Test.run (node:internal/test_runner/test:574:9)
      async Test.processPendingSubtests (node:internal/test_runner/test:318:7)

https://github.com/microsoft/qsharp/actions/runs/9575713105/job/26400994276?pr=1623#step:9:4568

tcNickolas commented 1 week ago

That's interesting, I don't remember it being noisy in the classic katas. I guess we run CI a lot more often in the new repo, so low-probability failures will happen more frequently. I'll take a look at improving this once I'm back.Message ID: @.*** com>

sezna commented 1 week ago

Just re-ran the pipeline so hopefully it won't flake this time.

github-actions[bot] commented 1 week ago

Benchmark for 8d7ad21

Click to view benchmark | Test | Base | PR | % | |------|--------------|------------------|---| | Array append evaluation | 332.6±3.87µs | 333.2±2.86µs | +0.18% | | Array literal evaluation | 206.7±3.65µs | **198.8±1.05µs** | **-3.82%** | | Array update evaluation | 415.7±2.44µs | 415.6±2.65µs | -0.02% | | Core + Standard library compilation | 23.0±0.87ms | 22.9±0.99ms | -0.43% | | Deutsch-Jozsa evaluation | 5.2±0.11ms | 5.2±0.06ms | 0.00% | | Large file parity evaluation | 34.2±0.10ms | 34.2±1.09ms | 0.00% | | Large input file compilation | **13.4±0.34ms** | 14.7±0.69ms | **+9.70%** | | Large input file compilation (interpreter) | 53.0±1.89ms | 53.8±1.90ms | +1.51% | | Large nested iteration | 32.8±0.65ms | 32.8±2.00ms | 0.00% | | Perform Runtime Capabilities Analysis (RCA) on Deutsch-Jozsa sample | 1607.2±139.09µs | 1628.9±154.36µs | +1.35% | | Perform Runtime Capabilities Analysis (RCA) on large file sample | 8.1±0.45ms | 8.2±0.15ms | +1.23% | | Perform Runtime Capabilities Analysis (RCA) on teleport sample | 1486.4±137.21µs | 1486.2±153.76µs | -0.01% | | Perform Runtime Capabilities Analysis (RCA) on the core and std libraries | 29.3±0.17ms | **29.0±0.24ms** | **-1.02%** | | Teleport evaluation | 93.0±3.79µs | 90.5±3.57µs | -2.69% |
github-actions[bot] commented 1 week ago

Benchmark for 12f4733

Click to view benchmark | Test | Base | PR | % | |------|--------------|------------------|---| | Array append evaluation | 330.6±2.40µs | 330.4±1.32µs | -0.06% | | Array literal evaluation | 201.3±4.41µs | **198.5±1.29µs** | **-1.39%** | | Array update evaluation | 415.1±2.72µs | **412.6±1.14µs** | **-0.60%** | | Core + Standard library compilation | 20.3±0.34ms | 20.2±0.36ms | -0.49% | | Deutsch-Jozsa evaluation | 5.1±0.05ms | 5.1±0.06ms | 0.00% | | Large file parity evaluation | **33.9±0.08ms** | 34.0±0.30ms | **+0.29%** | | Large input file compilation | 12.5±0.16ms | 12.4±0.21ms | -0.80% | | Large input file compilation (interpreter) | 49.4±1.10ms | 49.1±0.95ms | -0.61% | | Large nested iteration | 32.1±0.26ms | 32.2±0.17ms | +0.31% | | Perform Runtime Capabilities Analysis (RCA) on Deutsch-Jozsa sample | 1554.5±37.53µs | 1568.3±37.05µs | +0.89% | | Perform Runtime Capabilities Analysis (RCA) on large file sample | 8.1±0.09ms | **7.8±0.09ms** | **-3.70%** | | Perform Runtime Capabilities Analysis (RCA) on teleport sample | 1420.1±47.35µs | 1426.6±36.69µs | +0.46% | | Perform Runtime Capabilities Analysis (RCA) on the core and std libraries | **28.0±0.16ms** | 28.2±0.18ms | **+0.71%** | | Teleport evaluation | 90.7±3.65µs | 91.8±3.96µs | +1.21% |