Skip to content

Conversation

rniczh
Copy link
Contributor

@rniczh rniczh commented Sep 23, 2025

Context:

Hackweek project

Description of the Change:

builtin.module {
  func.func @qnode_main(%shots : i64, %num_qubits : i64, %angle : f64) -> tensor<4xf64> {
    %result = quantum.call_execution(%shots, %num_qubits, %angle) {callee = @execution_1} : (i64, i64, f64) -> tensor<4xf64>
    func.return %result : tensor<4xf64>
  }

  quantum.execution() {function_type = (i64, i64, f64) -> tensor<4xf64>, sym_name = "execution_1"} (
    init {
    ^bb0(%shots : i64, %num_qubits : i64, %angle : f64):
      quantum.device shots(%shots) [
          "...dylib",
          "LightningSimulator",
          "{'mcmc': False, 'num_burnin': 0, 'kernel_name': None}"
      ]
      %qreg = quantum.alloc(%num_qubits) : !quantum.reg
      quantum.exec_yield %qreg, %angle : !quantum.reg, f64
    },
    evolution {
    ^bb1(%qreg_in : !quantum.reg, %rx_angle : f64):
      %q0 = quantum.extract %qreg_in[0] : !quantum.reg -> !quantum.bit
      %q0_rx = quantum.custom "RX"(%rx_angle) %q0 : !quantum.bit
      %qreg_evolved = quantum.insert %qreg_in[0], %q0_rx : !quantum.reg, !quantum.bit
      quantum.exec_yield %qreg_evolved : !quantum.reg
    },
    measurement {
    ^bb2(%qreg_meas : !quantum.reg):
      %obs = quantum.compbasis qreg %qreg_meas : !quantum.obs
      %probs = quantum.probs %obs : tensor<4xf64>
      quantum.exec_yield %qreg_meas, %probs : !quantum.reg, tensor<4xf64>
    },
    teardown {
    ^bb3(%qreg_cleanup : !quantum.reg, %final_result : tensor<4xf64>):
      quantum.dealloc %qreg_cleanup : !quantum.reg
      quantum.device_release
      quantum.exec_yield %final_result : tensor<4xf64>
    }
  )
}

Benefits:

Possible Drawbacks:

Related GitHub Issues:

@rniczh rniczh marked this pull request as draft September 23, 2025 20:39
Copy link

codecov bot commented Sep 23, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.45%. Comparing base (7070359) to head (29aa557).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2061   +/-   ##
=======================================
  Coverage   97.45%   97.45%           
=======================================
  Files          90       90           
  Lines       10476    10476           
  Branches      972      972           
=======================================
  Hits        10209    10209           
  Misses        213      213           
  Partials       54       54           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@paul0403
Copy link
Member

😲

@rniczh rniczh changed the title Quantum execution for structured qnode repr is added to the Catalyst … Quantum execution for structured qnode repr is added to the Catalyst Sep 24, 2025
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.

2 participants