microsoft / qsharp

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

Fix RIR panic on value updated during loop #1587

Closed swernli closed 4 months ago

swernli commented 4 months ago

This fixes an issue with mutable variables that are static on a first run through a loop and dynamic afterward when they are used in a unary operation. The unary operation needs to be fully evaluated rather than generated into RIR, much the way static binary operations are.

github-actions[bot] commented 4 months ago

Benchmark for 33211c3

Click to view benchmark | Test | Base | PR | % | |------|--------------|------------------|---| | Array append evaluation | 332.7±2.89µs | **327.7±0.71µs** | **-1.50%** | | Array literal evaluation | 183.4±0.81µs | **174.7±8.42µs** | **-4.74%** | | Array update evaluation | 412.5±5.45µs | 410.7±2.39µs | -0.44% | | Core + Standard library compilation | **18.2±0.40ms** | 19.0±1.23ms | **+4.40%** | | Deutsch-Jozsa evaluation | 5.2±0.21ms | **5.1±0.07ms** | **-1.92%** | | Large file parity evaluation | **33.8±0.06ms** | 34.0±1.29ms | **+0.59%** | | Large input file compilation | **12.4±0.23ms** | 12.7±0.50ms | **+2.42%** | | Large input file compilation (interpreter) | **45.4±1.53ms** | 50.7±1.68ms | **+11.67%** | | Large nested iteration | 32.8±0.18ms | **32.5±1.46ms** | **-0.91%** | | Perform Runtime Capabilities Analysis (RCA) on Deutsch-Jozsa sample | 1555.9±30.97µs | 1581.0±82.51µs | +1.61% | | Perform Runtime Capabilities Analysis (RCA) on large file sample | 7.9±0.14ms | 8.0±0.11ms | +1.27% | | Perform Runtime Capabilities Analysis (RCA) on teleport sample | 1416.4±33.65µs | 1435.1±65.90µs | +1.32% | | Perform Runtime Capabilities Analysis (RCA) on the core and std libraries | **28.0±0.14ms** | 28.7±1.16ms | **+2.50%** | | Teleport evaluation | 89.6±3.67µs | 86.7±3.71µs | -3.24% |
github-actions[bot] commented 4 months ago

Benchmark for 99978d1

Click to view benchmark | Test | Base | PR | % | |------|--------------|------------------|---| | Array append evaluation | 334.6±2.11µs | **331.2±3.05µs** | **-1.02%** | | Array literal evaluation | 172.5±5.10µs | 172.0±2.35µs | -0.29% | | Array update evaluation | 416.3±3.60µs | 414.1±5.45µs | -0.53% | | Core + Standard library compilation | 20.1±1.12ms | **19.1±0.48ms** | **-4.98%** | | Deutsch-Jozsa evaluation | 5.2±0.06ms | 5.2±0.07ms | 0.00% | | Large file parity evaluation | 34.6±0.20ms | 34.7±0.21ms | +0.29% | | Large input file compilation | 13.7±0.61ms | 13.5±0.59ms | -1.46% | | Large input file compilation (interpreter) | 53.5±2.84ms | 51.9±1.74ms | -2.99% | | Large nested iteration | 33.2±0.35ms | **32.7±0.22ms** | **-1.51%** | | Perform Runtime Capabilities Analysis (RCA) on Deutsch-Jozsa sample | 1621.5±55.28µs | 1627.4±70.52µs | +0.36% | | Perform Runtime Capabilities Analysis (RCA) on large file sample | 8.0±0.15ms | 8.0±0.16ms | 0.00% | | Perform Runtime Capabilities Analysis (RCA) on teleport sample | 1476.3±85.78µs | 1476.0±83.69µs | -0.02% | | Perform Runtime Capabilities Analysis (RCA) on the core and std libraries | 28.4±0.44ms | 28.5±0.47ms | +0.35% | | Teleport evaluation | 90.4±3.92µs | 92.0±3.83µs | +1.77% |