Runnable examples, quantum identities, and capability checks demonstrated by osxQ / QuantumStudio.
250 examples · every entry links to its source on GitHube257370). Examples cover gate algebra, state preparation, algorithm identities
(Bell, GHZ, QFT, Grover, Toffoli, teleportation, QPE), MPS tensor-network parity, OpenQASM
execution, and the QuantumStudio backend/MCP API. Run them all with ./test.sh, or one
module with python3 -m pytest <file> -q. For the parameterized benchmark circuits and
the OpenQASM corpus, see the Example & Circuit Gallery.
src/tests/mlxQCoreTest.pytest_hadamard_superposition ↗test_pauli_x_on_zero ↗test_rotations_unitarity_norm ↗test_z_expectation_on_zero_and_one ↗test_cnot_creates_bell ↗test_swap_moves_amplitudes ↗test_qft_iqft_identity_3q ↗test_bell_sampling_counts_reasonable ↗test_qasm_bell_exec ↗test_qasm_qft4_exec ↗test_commutator_xy_equals_2iZ ↗test_anticommutator_xz_zero ↗test_s_times_sdg_identity ↗test_t_squared_equals_s ↗test_phase_additivity ↗test_rz_additivity ↗test_u3_unitary ↗test_cphase_pi_equals_cz ↗test_swap_three_cnot_decomposition ↗test_qft_uniform_to_zero_state_2q ↗test_hadamard_squared_identity ↗test_pauli_squared_identity ↗test_plus_minus_x_expectations ↗test_bell_state_from_states ↗test_ghz3_xxx_expectation_one ↗test_comp_basis_states_2q_full ↗test_device_exec_h_then_probs ↗test_rz_2pi_identity ↗test_random_state_norm ↗test_openqasm_parse_counts ↗test_iswap_squared_equals_zz ↗test_hh_cnot_hh_equals_cnot_21 ↗test_cnot_to_cz_via_h ↗test_u2_decomposition_rz_ry_rz ↗test_u3_euler_zyz ↗test_qft_uniform_to_zero_state_3q ↗test_y_basis_state_expval_minus ↗test_swap_conjugation_xz_to_zx ↗test_cphase_zero_equals_identity ↗test_device_counts_hadamard ↗test_conjugation_hzh_equals_x ↗test_conjugation_hxh_equals_z ↗test_cnot_conjugation_x_on_control ↗test_cnot_conjugation_z_on_target ↗test_t_times_tdg_identity ↗test_ry_pi_maps_zero_to_one ↗test_rx_pi_maps_zero_to_one ↗test_deutsch_qasm_norm ↗test_grover2_qasm_norm ↗test_toffoli_truth_table_flip ↗test_fredkin_swaps_when_control_one ↗test_swap_nonadjacent_0_2_moves ↗test_counts_total_equals_shots ↗test_expectation_z_on_plus_zero ↗test_bell_xx_expectation_one ↗test_bell_zz_expectation_one ↗test_bell_yy_expectation_minus_one ↗test_inverse_qft_qasm_norm ↗test_wstate3_qasm_norm ↗test_vqe_n4_qasm_norm ↗test_h_on_first_qubit_state_vector ↗test_global_phase_invariance_probabilities ↗test_bloch_vector_plus_x_axis ↗test_bloch_vector_zero_z_axis ↗test_pauli_decomposition_reconstruction_2x2 ↗test_is_unitary_core_gates_set ↗test_commute_different_qubits_xi_iz_zero ↗test_qft_iqft_identity_2q_on_basis ↗test_pauli_exponential_matches_rz ↗test_eigenstates_basic_xyz ↗test_multictrlx_1_equals_cnot_matrix ↗test_rx_additivity ↗test_ry_additivity ↗test_crx_zero_is_identity ↗test_cry_zero_is_identity ↗test_crz_zero_is_identity ↗test_identity_action_does_nothing ↗test_ghz3_zzI_expectation_one ↗test_w3_single_qubit_z_expectation_thirds ↗test_uniform_superposition_probs_2q_equal_quarter ↗test_hh_zz_hh_equals_xx ↗test_commutator_yz_2ix ↗test_sx_unitary ↗test_swap_self_inverse ↗test_iswap_unitary ↗test_device_sequence_norm_preserved ↗test_random_state_probability_sum_one_n4 ↗test_counts_uniform_after_hadamards_3q ↗test_cphase_commutes_with_z_on_target ↗test_crz_commutes_with_z_on_target ↗test_rz_conjugates_x_to_y ↗test_rx_conjugates_z_to_y ↗test_h_conjugates_y_to_minus_y ↗test_swap_commutes_with_cz_different_qubits ↗test_cnot_square_is_identity ↗test_cz_square_is_identity ↗test_t_dagger_times_t_identity ↗test_s_dagger_times_s_identity ↗test_device_counts_bell_correlated ↗test_bell_state_fidelity_with_constructor ↗test_shot_based_measurements_convergence ↗test_qi_bell_reduced_max_mixed ↗test_qi_purity_pure_and_mixed ↗test_qi_negativity_bell_and_product ↗test_qi_concurrence_bell_one ↗test_qi_entropy_reduced_bell_one ↗test_qi_depolarizing_channel_max_mixed ↗test_qi_amplitude_damping_excited ↗test_qi_bitflip_channel_zero_to_one ↗test_qi_choi_psd_amplitude_damping ↗test_qi_ptrace_dimensions_consistency ↗test_qi_operator_vectorization_roundtrip ↗test_qi_stacked_index_roundtrip ↗test_spin_pauli_as_half ↗test_spin_expectation_on_states ↗test_spin_larmor_precession_sz ↗test_spin_rotation_about_x_maps_z ↗test_superoperator_unitary_action ↗test_vectorization_superoperator_identity ↗test_appendix_vqe_parameter_sweep ↗test_appendix_two_qubit_pauli_strings ↗test_appendix_ising_model_ground_state ↗test_appendix_bell_state_pauli_expectations ↗test_appendix_multi_qubit_hamiltonian_grouping ↗test_appendix_hw3_bell_state_expectations ↗test_appendix_hw3_pure_vs_mixed_state ↗test_appendix_hw2_tensor_products ↗test_appendix_hw2_matrix_exponential ↗test_appendix_hw2_unitary_property ↗test_appendix_hw2_concurrence ↗test_appendix_hw214b_y_basis_time_evolution ↗test_appendix_hw24_pauli_decomposition ↗test_appendix_hw3_advanced_circuit_decomposition ↗test_elitzur_vaidman_bomb_tester ↗test_two_qubit_separability_analysis ↗test_bell_basis_measurements ↗test_grover_search_algorithm ↗test_spin_general_spinor_expectations ↗test_spin_sy_measurements ↗test_spin_sx_sy_eigenproblem ↗test_spin_two_stage_field_rotation ↗test_spin_cosine_field_flip ↗test_multictrlz_two_controls_phase_on_all_ones ↗test_multictrlx_two_controls_flip_truth ↗test_is_hermitian_and_commutator_api ↗test_draw_ascii_small ↗test_draw_ascii_random_medium ↗test_quantikz_small ↗test_circuit_mpl_small_and_random ↗src/tests/mlxQInternalConsistencyTest.pytest_consist_apply_matrix_single_qubit ↗test_consist_apply_matrix_two_qubit ↗test_consist_apply_swap_dense_vs_builtin_2q ↗test_consist_apply_cphase_dense_vs_builtin ↗test_consist_apply_crz_dense_vs_builtin ↗test_consist_apply_sequence_dense_vs_builtin ↗test_consist_compute_expectation_pauli_string ↗test_consist_measure_collapse_project ↗test_consist_abs2sum_on_z_basis_mask ↗test_consist_set_state_vector_custom ↗test_consist_set_state_vector_random_norm ↗test_consist_apply_pauli_xyz_probabilities ↗test_consist_measure_on_z_basis_sample_counts ↗test_consist_uniform_sampling_n3 ↗test_consist_measure_collapse_then_expectation ↗test_consist_abs2sum_multiwire_mask ↗test_consist_compute_expectation_custom_1q ↗test_consist_apply_matrix_noncontiguous_cnot_20 ↗test_consist_sample_subset_wires_bell_marginals ↗test_consist_collapse_multi_qubits_and_normalize ↗src/tests/mlxQMpsBackendTest.pytest_mps_sv_parity_small_random ↗test_mps_tebd_tfim_single_step ↗test_mps_tebd_eps_effect ↗test_mps_long_range_ising_single_step ↗test_mps_ladder_heisenberg_single_step ↗test_mps_mpo_xx_single_step ↗test_mps_early_stop_flag ↗test_mps_bonds_csv_emitted ↗src/tests/mlxQMpsParamSuiteTest.pysrc/tests/mlxQMeasurementParityTest.pysrc/tests/mlxQBenchCatalogTest.pysrc/tests/mlxQQCExamplesTest.pytest_hzh_equals_x_and_hxh_equals_z_and_hyh_equals_minus_y ↗test_cnot_conjugated_by_target_h_equals_cz ↗test_u3_euler_decomposition_matches_rz_ry_rz ↗test_h_on_first_qubit_of_10 ↗test_pauli_commutation_su2 ↗test_y_basis_expectation_pm_one ↗test_bell_orthogonality_and_sigma_y_otimes_sigma_z_expectation ↗test_cphase_pi_equals_cz ↗test_bell_phi_plus_y_y_expectation_is_minus_one ↗test_swap_conjugation_exchanges_tensor_factors ↗test_iswap_squared_equals_zz ↗test_toffoli_action_on_110_and_100 ↗test_ghz3_zz_parity_is_one ↗test_w3_single_qubit_z_expectation_is_third ↗test_uniform_superposition_2q_probs_are_quarter ↗test_pauli_decomposition_coefficients_by_traces ↗test_qft2_iqft2_identity ↗test_phase_and_rz_additivity ↗test_t_squared_equals_s_and_s_dagger ↗test_rz_2pi_is_minus_identity ↗test_bloch_vectors_plus_and_zero ↗test_bell_reduction_is_maximally_mixed ↗test_purity_pure_vs_mixed ↗test_fredkin_action_on_basis_states ↗test_mcx1_equals_cnot_action ↗test_concurrence_of_bell_phi_plus_is_one ↗test_entropy_of_reduced_bell_state_is_one_bit ↗test_depolarizing_channel_maps_to_half_I_at_p1 ↗test_amplitude_damping_on_one_to_zero_at_gamma1 ↗test_bit_flip_on_zero_with_p1_goes_to_one ↗test_choi_matrix_psd_for_depolarizing ↗test_vectorization_identity_abc ↗test_ppt_negativity_for_bell ↗test_log_negativity_for_bell_is_one ↗test_negativity_bell_half_and_product_zero ↗test_trace_and_hs_distances ↗test_unitary_superoperator_action_and_kraus_equivalence ↗test_partial_trace_dimensions_consistency ↗test_operator_vector_roundtrip_stack_unstack ↗test_swap_decomposition_three_cnot ↗test_control_target_swap_via_double_h ↗src/tests/mlxQQmlWrapperTest.pytest_qml_qnode_expval_z_after_rx ↗test_qml_grad_parameter_shift_rx ↗test_qml_expval_shots_matches_expectation ↗test_qml_template_smoke ↗test_qpe_exact_energy_fit ↗src/tests/mlxQQpeEnergyEstimationTest.pysrc/tests/mlxQVisualizationPlotsTest.pyquantumstudio/tests/test_backend_api.pytest_health_contains_runtime_controls ↗test_metrics_endpoint_tracks_requests ↗test_api_security_headers_present ↗test_auth_token_enforced_when_enabled ↗test_rate_limit_returns_429 ↗test_http_error_includes_request_id ↗test_invalid_env_override_is_rejected ↗test_large_logs_are_truncated ↗test_env_override_limit ↗test_env_override_names_are_normalized ↗quantumstudio/tests/test_mcp_server.pytest_all_tools_have_required_fields ↗test_tool_names_are_unique ↗test_required_tool_coverage ↗test_initialize ↗test_tools_list ↗test_unknown_tool_returns_error ↗test_unknown_method_returns_error ↗