Skip to content
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

Q# Package System #1698

Merged
merged 14 commits into from
Jul 8, 2024
Merged

Q# Package System #1698

merged 14 commits into from
Jul 8, 2024

Conversation

sezna
Copy link
Contributor

@sezna sezna commented Jul 3, 2024

This PR:

  1. Refactors the compiler API such that the caller passes in a constructed package store, allowing for dependencies to be pre-compiled and inserted before compiling user code
  2. Introduces the BuildableProgram abstraction, which encapsulates the notion of "some user code that is ready to compile, along with a package store that has all of its dependencies compiled"
  3. As a drive-by fix, fixes circuits for internal operations
  4. Removes the notion of Visibility from the AST, since visibility is calculated via exports now. internal is still parsed without error for backwards compatibility, but is a no-op because internal is the default now.
  5. Enforces visibility in the HIR, where items must be Visibility::Public to show up across packages as a GlobalItem
  6. Adds export statements to the standard library to preserve the existing API with the new internal-by-default semantics
  7. Inserts all packages into the user code's namespace tree with the prefix defined as the package alias in the qsharp.json

closes #883

The Q# formatting CI stage will fail until #1692 goes in

This PR supersedes #1693

@sezna sezna self-assigned this Jul 3, 2024
@sezna sezna mentioned this pull request Jul 3, 2024
Copy link
Collaborator

@swernli swernli left a comment

Choose a reason for hiding this comment

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

Finished reviewing, changes look good, a few minor things called out. The only major thing is a possible side effect of removing visibility from the AST precluding future lints, but even that can be something we add back in later in a limited fashion if it makes sense to do so.

@sezna sezna marked this pull request as ready for review July 3, 2024 21:31
Copy link

github-actions bot commented Jul 3, 2024

Change in memory usage detected by benchmark.

Memory Report for e1e316f

Test This Branch On Main Difference
compile core + standard lib 16755780 bytes 16689324 bytes 66456 bytes

Copy link

github-actions bot commented Jul 3, 2024

Benchmark for e1e316f

Click to view benchmark
Test Base PR %
Array append evaluation 330.3±3.02µs 329.9±4.15µs -0.12%
Array literal evaluation 188.7±0.74µs 188.5±0.91µs -0.11%
Array update evaluation 411.8±1.30µs 409.8±2.39µs -0.49%
Core + Standard library compilation 20.7±1.12ms 21.6±1.08ms +4.35%
Deutsch-Jozsa evaluation 5.2±0.06ms 5.1±0.04ms -1.92%
Large file parity evaluation 34.4±0.14ms 34.3±1.51ms -0.29%
Large input file compilation 12.4±0.36ms 12.5±0.40ms +0.81%
Large input file compilation (interpreter) 48.4±1.25ms 49.3±2.50ms +1.86%
Large nested iteration 32.0±0.13ms 33.5±0.42ms +4.69%
Perform Runtime Capabilities Analysis (RCA) on Deutsch-Jozsa sample 1564.8±37.89µs 1540.0±32.51µs -1.58%
Perform Runtime Capabilities Analysis (RCA) on large file sample 7.8±0.09ms 7.8±0.13ms 0.00%
Perform Runtime Capabilities Analysis (RCA) on teleport sample 1429.0±47.47µs 1414.8±51.00µs -0.99%
Perform Runtime Capabilities Analysis (RCA) on the core and std libraries 28.3±1.38ms 27.8±0.25ms -1.77%
Teleport evaluation 91.1±3.43µs 89.2±5.77µs -2.09%

Copy link
Contributor

@cesarzc cesarzc left a comment

Choose a reason for hiding this comment

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

I finished reviewing and the changes look good. I left a few comments with mostly non-blocking things, but it would be good to address them before merging.

@sezna sezna enabled auto-merge July 8, 2024 16:22
Copy link

github-actions bot commented Jul 8, 2024

Change in memory usage detected by benchmark.

Memory Report for c83314c

Test This Branch On Main Difference
compile core + standard lib 16755780 bytes 16689324 bytes 66456 bytes

Copy link

github-actions bot commented Jul 8, 2024

Change in memory usage detected by benchmark.

Memory Report for 3aff1d9

Test This Branch On Main Difference
compile core + standard lib 16755780 bytes 16689324 bytes 66456 bytes

Copy link

github-actions bot commented Jul 8, 2024

Benchmark for 3aff1d9

Click to view benchmark
Test Base PR %
Array append evaluation 332.5±4.79µs 333.6±2.13µs +0.33%
Array literal evaluation 186.3±1.45µs 209.4±9.70µs +12.40%
Array update evaluation 412.7±5.91µs 413.5±1.06µs +0.19%
Core + Standard library compilation 20.7±0.65ms 21.2±0.65ms +2.42%
Deutsch-Jozsa evaluation 5.2±0.09ms 5.1±0.06ms -1.92%
Large file parity evaluation 34.4±0.12ms 34.1±0.26ms -0.87%
Large input file compilation 12.5±0.20ms 12.2±0.14ms -2.40%
Large input file compilation (interpreter) 50.5±1.51ms 48.6±1.65ms -3.76%
Large nested iteration 32.2±0.19ms 32.5±0.25ms +0.93%
Perform Runtime Capabilities Analysis (RCA) on Deutsch-Jozsa sample 1563.1±34.63µs 1559.5±46.55µs -0.23%
Perform Runtime Capabilities Analysis (RCA) on large file sample 7.8±0.08ms 8.0±0.18ms +2.56%
Perform Runtime Capabilities Analysis (RCA) on teleport sample 1450.6±118.66µs 1418.4±38.05µs -2.22%
Perform Runtime Capabilities Analysis (RCA) on the core and std libraries 28.0±0.31ms 28.0±0.32ms 0.00%
Teleport evaluation 90.1±3.35µs 90.3±4.10µs +0.22%

Copy link

github-actions bot commented Jul 8, 2024

Change in memory usage detected by benchmark.

Memory Report for 1c15995

Test This Branch On Main Difference
compile core + standard lib 16755780 bytes 16689324 bytes 66456 bytes

Copy link

github-actions bot commented Jul 8, 2024

Change in memory usage detected by benchmark.

Memory Report for e56ee3a

Test This Branch On Main Difference
compile core + standard lib 16755780 bytes 16689324 bytes 66456 bytes

Copy link

github-actions bot commented Jul 8, 2024

Benchmark for 1c15995

Click to view benchmark
Test Base PR %
Array append evaluation 326.9±3.52µs 328.7±2.33µs +0.55%
Array literal evaluation 171.6±2.35µs 186.6±1.07µs +8.74%
Array update evaluation 407.6±2.20µs 407.5±1.31µs -0.02%
Core + Standard library compilation 19.9±0.26ms 21.1±0.25ms +6.03%
Deutsch-Jozsa evaluation 5.2±0.06ms 5.1±0.05ms -1.92%
Large file parity evaluation 34.3±0.08ms 34.1±0.21ms -0.58%
Large input file compilation 12.2±0.24ms 12.2±0.54ms 0.00%
Large input file compilation (interpreter) 47.3±0.79ms 48.5±1.64ms +2.54%
Large nested iteration 31.9±0.54ms 32.0±0.36ms +0.31%
Perform Runtime Capabilities Analysis (RCA) on Deutsch-Jozsa sample 1565.4±31.62µs 1567.7±33.27µs +0.15%
Perform Runtime Capabilities Analysis (RCA) on large file sample 7.8±0.11ms 7.7±0.07ms -1.28%
Perform Runtime Capabilities Analysis (RCA) on teleport sample 1435.4±29.79µs 1422.0±31.14µs -0.93%
Perform Runtime Capabilities Analysis (RCA) on the core and std libraries 27.8±0.20ms 27.9±0.16ms +0.36%
Teleport evaluation 92.2±5.69µs 88.8±3.62µs -3.69%

@sezna sezna added this pull request to the merge queue Jul 8, 2024
Copy link

github-actions bot commented Jul 8, 2024

Benchmark for e56ee3a

Click to view benchmark
Test Base PR %
Array append evaluation 327.5±9.22µs 327.7±4.24µs +0.06%
Array literal evaluation 169.0±3.53µs 169.2±1.37µs +0.12%
Array update evaluation 408.2±12.66µs 405.9±4.11µs -0.56%
Core + Standard library compilation 23.2±0.88ms 22.2±0.64ms -4.31%
Deutsch-Jozsa evaluation 5.2±0.05ms 5.2±0.06ms 0.00%
Large file parity evaluation 34.5±0.21ms 34.2±0.61ms -0.87%
Large input file compilation 14.0±0.62ms 12.7±0.43ms -9.29%
Large input file compilation (interpreter) 55.7±3.25ms 51.5±2.11ms -7.54%
Large nested iteration 32.1±0.38ms 31.7±0.40ms -1.25%
Perform Runtime Capabilities Analysis (RCA) on Deutsch-Jozsa sample 1604.1±105.14µs 1584.2±79.68µs -1.24%
Perform Runtime Capabilities Analysis (RCA) on large file sample 8.5±0.28ms 8.1±0.15ms -4.71%
Perform Runtime Capabilities Analysis (RCA) on teleport sample 1472.7±174.96µs 1431.3±47.04µs -2.81%
Perform Runtime Capabilities Analysis (RCA) on the core and std libraries 28.7±0.37ms 28.2±0.40ms -1.74%
Teleport evaluation 91.7±3.73µs 89.4±3.71µs -2.51%

Merged via the queue into main with commit 18d5b5f Jul 8, 2024
19 checks passed
@sezna sezna deleted the alex-and-mine/qsharp-packages branch July 8, 2024 17:12
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.

Initial Q# Package System
3 participants