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

Packages for Q# #1693

Closed
wants to merge 290 commits into from
Closed

Packages for Q# #1693

wants to merge 290 commits into from

Conversation

sezna
Copy link
Contributor

@sezna sezna commented Jul 1, 2024

WIP branch, putting it up for code review meetings

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

@sezna sezna changed the title Feature/party Packages for Q# Jul 1, 2024
@@ -49,12 +49,16 @@

impl CompilationContext {
fn new(source: &str) -> Self {
let mut store = qsc::PackageStore::new(qsc::compile::core());
// TODO(alex) ask cesarzc if std is wanted here

Check notice

Code scanning / devskim

A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note test

Suspicious comment
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cesarzc should these tests include the stdlib or no?

Copy link

github-actions bot commented Jul 1, 2024

Change in memory usage detected by benchmark.

Memory Report for 3b462ee

Test This Branch On Main Difference
compile core + standard lib 16756956 bytes 16689324 bytes 67632 bytes

Copy link

github-actions bot commented Jul 1, 2024

Benchmark for 3b462ee

Click to view benchmark
Test Base PR %
Array append evaluation 327.6±5.91µs 333.5±12.55µs +1.80%
Array literal evaluation 169.0±1.27µs 169.6±5.66µs +0.36%
Array update evaluation 408.4±5.45µs 414.7±16.47µs +1.54%
Core + Standard library compilation 19.9±0.40ms 21.0±0.32ms +5.53%
Deutsch-Jozsa evaluation 5.2±0.06ms 5.1±0.04ms -1.92%
Large file parity evaluation 34.3±0.10ms 34.1±0.17ms -0.58%
Large input file compilation 12.2±0.23ms 12.3±0.32ms +0.82%
Large input file compilation (interpreter) 47.1±1.01ms 48.0±1.21ms +1.91%
Large nested iteration 31.8±0.51ms 31.8±0.13ms 0.00%
Perform Runtime Capabilities Analysis (RCA) on Deutsch-Jozsa sample 1555.1±30.82µs 1544.4±33.91µs -0.69%
Perform Runtime Capabilities Analysis (RCA) on large file sample 7.8±0.11ms 7.7±0.08ms -1.28%
Perform Runtime Capabilities Analysis (RCA) on teleport sample 1420.5±33.07µs 1406.4±33.69µs -0.99%
Perform Runtime Capabilities Analysis (RCA) on the core and std libraries 27.9±0.29ms 27.7±0.36ms -0.72%
Teleport evaluation 91.0±3.42µs 90.5±5.47µs -0.55%

Copy link

github-actions bot commented Jul 2, 2024

Change in memory usage detected by benchmark.

Memory Report for 6437607

Test This Branch On Main Difference
compile core + standard lib 16755772 bytes 16689324 bytes 66448 bytes

Copy link

github-actions bot commented Jul 2, 2024

Benchmark for 6437607

Click to view benchmark
Test Base PR %
Array append evaluation 331.0±3.09µs 327.5±2.00µs -1.06%
Array literal evaluation 188.3±15.85µs 169.2±1.45µs -10.14%
Array update evaluation 411.7±4.47µs 407.7±9.78µs -0.97%
Core + Standard library compilation 23.4±1.15ms 23.1±0.73ms -1.28%
Deutsch-Jozsa evaluation 5.2±0.07ms 5.1±0.21ms -1.92%
Large file parity evaluation 34.4±0.08ms 34.2±0.09ms -0.58%
Large input file compilation 13.5±0.49ms 14.4±0.58ms +6.67%
Large input file compilation (interpreter) 52.1±1.82ms 52.7±1.59ms +1.15%
Large nested iteration 32.2±1.32ms 33.5±0.17ms +4.04%
Perform Runtime Capabilities Analysis (RCA) on Deutsch-Jozsa sample 1611.0±144.48µs 1609.3±153.90µs -0.11%
Perform Runtime Capabilities Analysis (RCA) on large file sample 8.1±0.19ms 8.1±0.19ms 0.00%
Perform Runtime Capabilities Analysis (RCA) on teleport sample 1471.4±124.63µs 1461.5±166.85µs -0.67%
Perform Runtime Capabilities Analysis (RCA) on the core and std libraries 29.0±0.41ms 28.9±1.09ms -0.34%
Teleport evaluation 91.4±3.40µs 89.1±3.25µs -2.52%

@sezna sezna mentioned this pull request Jul 3, 2024
@sezna
Copy link
Contributor Author

sezna commented Jul 3, 2024

Superseded by #1698

@sezna sezna closed this Jul 3, 2024
github-merge-queue bot pushed a commit that referenced this pull request Jul 8, 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 deleted the feature/party branch July 24, 2024 05:56
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
2 participants