Skip to content

Add automatic schedule validation before qompile execution #154

@masa10-f

Description

@masa10-f

Is your feature request related to a problem? Please describe.

When using manual_schedule() to set a custom schedule and then passing the Scheduler to qompile(), the schedule is not validated automatically. This means invalid schedules (e.g., DAG constraint violations, improper time ordering) can silently pass through to pattern generation, potentially causing incorrect results or runtime errors later.

Current behavior:

  • manual_schedule() does not call validate_schedule()
  • solve_schedule() does not call validate_schedule()
  • qompile() does not call validate_schedule() on the passed scheduler
  • Users must remember to explicitly call validate_schedule() before qompile()

Example of problematic usage:

scheduler = Scheduler(graph, flow)
scheduler.manual_schedule(
    prepare_time={node1: 0, node2: 1},
    measure_time={node0: 1, node1: 2},
)
# Forgot to call scheduler.validate_schedule()
pattern = qompile(graph, xflow, scheduler=scheduler)  # Invalid schedule passes silently

Describe the feature you'd like

Option A: Add automatic validation in qompile() when a scheduler is passed

  • Call scheduler.validate_schedule() at the beginning of _qompile() if a scheduler is provided
  • Raises ValueError early with a clear error message for invalid schedules

Option B: Add automatic validation in manual_schedule()

  • Call validate_schedule() at the end of manual_schedule()
  • Ensures schedules are always valid immediately after setting

Option C: Add a warning/documentation

  • If automatic validation is intentionally omitted for performance or flexibility reasons, add clear documentation and/or a runtime warning when validation is skipped

Additional context

Related code locations:

  • graphqomb/scheduler.py:205-253 - manual_schedule()
  • graphqomb/scheduler.py:470-492 - validate_schedule()
  • graphqomb/qompiler.py:103-105 - scheduler handling in _qompile()

The validation methods check:

  1. Node sets consistency (_validate_node_sets)
  2. All nodes are scheduled (_validate_all_nodes_scheduled)
  3. DAG constraint compliance (_validate_dag_constraints)
  4. Time ordering (_validate_time_ordering)
  5. Entanglement time constraints (_validate_entangle_time_constraints)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions