1 from pathlib
import Path
7 REPO_ROOT = Path(__file__).resolve().parents[2]
8 if str(REPO_ROOT)
not in sys.path:
9 sys.path.insert(0, str(REPO_ROOT))
11 from squander.partitioning.noisy_runtime
import (
12 PHASE3_RUNTIME_PATH_BASELINE,
13 PHASE3_RUNTIME_PATH_FUSED_UNITARY_ISLANDS,
14 execute_partitioned_density,
15 execute_partitioned_density_fused,
19 PHASE3_RUNTIME_DENSITY_TOL,
20 execute_fused_with_reference,
33 assert baseline_result.runtime_path == PHASE3_RUNTIME_PATH_BASELINE
34 assert baseline_result.requested_runtime_path == PHASE3_RUNTIME_PATH_BASELINE
35 assert fused_result.actual_fused_execution
is True 36 assert fused_result.runtime_path == PHASE3_RUNTIME_PATH_FUSED_UNITARY_ISLANDS
37 assert fused_result.requested_runtime_path == PHASE3_RUNTIME_PATH_FUSED_UNITARY_ISLANDS
38 assert fused_result.fused_region_count > 0
42 """Fused kernels and sequential NoisyCircuit lowering share gate semantics.""" 46 np.testing.assert_allclose(
47 fused.density_matrix_numpy(),
48 unfused.density_matrix_numpy(),
49 atol=PHASE3_RUNTIME_DENSITY_TOL,
58 assert result.actual_fused_execution
is True 59 assert density_metrics[
"frobenius_norm_diff"] <= PHASE3_RUNTIME_DENSITY_TOL
60 assert density_metrics[
"max_abs_diff"] <= PHASE3_RUNTIME_DENSITY_TOL
def test_partitioned_runtime_fused_and_unfused_density_matrices_match()
def test_partitioned_runtime_direct_fused_result_matches_sequential_reference()
def execute_partitioned_density
def execute_fused_with_reference
def execute_partitioned_density_fused
def test_partitioned_runtime_direct_fused_runtime_path_differs_from_baseline_when_exercised()
def iter_fusion_structured_cases()
def _first_structured_case()