Skip to content

Conversation

phalakbh
Copy link
Contributor

@phalakbh phalakbh commented Aug 6, 2025

Summary

This PR migrates the implementation of the ASAPScheduleAnalysis pass from Python to Rust, maintaining identical scheduling logic and user-facing behavior.

Details and comments

Fixes #12259
No changes have been made to the scheduling algorithm or its logic.

@phalakbh phalakbh requested a review from a team as a code owner August 6, 2025 19:05
@qiskit-bot qiskit-bot added the Community PR PRs from contributors that are not 'members' of the Qiskit repo label Aug 6, 2025
@qiskit-bot
Copy link
Collaborator

Thank you for opening a new pull request.

Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient.

While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone.

One or more of the following people are relevant to this code:

  • @Qiskit/terra-core

@coveralls
Copy link

coveralls commented Aug 6, 2025

Pull Request Test Coverage Report for Build 17270793764

Details

  • 102 of 125 (81.6%) changed or added relevant lines in 4 files are covered.
  • 5 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.01%) to 88.407%

Changes Missing Coverage Covered Lines Changed/Added Lines %
crates/transpiler/src/passes/asap_schedule_analysis.rs 97 120 80.83%
Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/expr.rs 1 93.63%
crates/qasm2/src/lex.rs 4 92.01%
Totals Coverage Status
Change from base Build 17259836956: -0.01%
Covered Lines: 90318
Relevant Lines: 102162

💛 - Coveralls

@raynelfss raynelfss added this to the 2.2.0 milestone Aug 7, 2025
@raynelfss raynelfss added Changelog: None Do not include in changelog Rust This PR or issue is related to Rust code in the repository Intern PR PR submitted by IBM Quantum interns mod: transpiler Issues and PRs related to Transpiler and removed Community PR PRs from contributors that are not 'members' of the Qiskit repo labels Aug 7, 2025
Copy link
Contributor

@raynelfss raynelfss left a comment

Choose a reason for hiding this comment

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

I just took a quick glance through the code, there is just one thought about TimeOps here.

Copy link
Contributor

@raynelfss raynelfss left a comment

Choose a reason for hiding this comment

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

This looks good, I have some questions and comments.


let &op_duration = node_durations
.get(&node_index)
.ok_or_else(|| TranspilerError::new_err("No duration for node"))?;
Copy link
Contributor

Choose a reason for hiding this comment

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

This suggestion might have the wrong syntax but make the message more specific by doing something like this:

Suggested change
.ok_or_else(|| TranspilerError::new_err("No duration for node"))?;
.ok_or_else(|| TranspilerError::new_err(format!("No duration found for node at index {}", node_index.index())))?;

// Measure instruction handling is bit tricky due to clbit_write_latency
let t0q = qargs
.iter()
.map(|q| *idle_after.get(q).unwrap_or(&zero))
Copy link
Contributor

Choose a reason for hiding this comment

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

Since these are guaranteed to exist, try using indexing instead of defaulting to zero. If something outside of there ever pops up we'd know that there is something wrong with the pass.

Suggested change
.map(|q| *idle_after.get(q).unwrap_or(&zero))
.map(|q| *idle_after[q])

// t1: end time of instruction

let (t0, t1) = if is_gate_or_delay {
let &t0 = qargs
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason why this declares a reference?. Couldn't it be more like:

            let t0 = qargs

Since you're dealing with numbers, they should implement the Copy trait.

@raynelfss raynelfss self-assigned this Aug 14, 2025
Copy link
Contributor

@raynelfss raynelfss left a comment

Choose a reason for hiding this comment

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

I think this is good to merge. Thank you for your work.

@raynelfss raynelfss enabled auto-merge August 27, 2025 15:32
@raynelfss raynelfss added this pull request to the merge queue Aug 27, 2025
Merged via the queue into Qiskit:main with commit ce16e1a Aug 27, 2025
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: None Do not include in changelog Intern PR PR submitted by IBM Quantum interns mod: transpiler Issues and PRs related to Transpiler Rust This PR or issue is related to Rust code in the repository
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Port ASAPScheduleAnalysis to Rust
4 participants