--- Final Solver (used for performance test) ---
import numpy as np
import scipy.linalg

try:
    import threadpoolctl

    _HAS_THREADPOOLCTL = True
except Exception:
    _HAS_THREADPOOLCTL = False


class Solver:
    def __init__(self):
        pass

    def solve(self, problem, **kwargs):
        A = problem.get("matrix")
        if A is None:
            return {"sqrtm": {"X": []}}

        A = np.asarray(A, dtype=complex)

        if A.ndim != 2 or A.shape[0] != A.shape[1]:
            return {"sqrtm": {"X": []}}

        n = A.shape[0]
        try:
            if _HAS_THREADPOOLCTL and n >= 80:
                with threadpoolctl.threadpool_limits(limits=1, user_api="blas"):
                    X = scipy.linalg.sqrtm(A)
            else:
                X = scipy.linalg.sqrtm(A)
        except Exception:
            return {"sqrtm": {"X": []}}

        return {"sqrtm": {"X": X.tolist()}}
--- End Solver ---
Running performance test...
============================= test session starts ==============================
platform linux -- Python 3.12.13, pytest-9.0.2, pluggy-1.6.0
rootdir: /tests
plugins: anyio-4.13.0, jaxtyping-0.3.9
collected 3 items

../tests/test_outputs.py .
--- Performance Summary ---
Validity: True
Total Baseline Time: 25.4514s
Total Solver Time:   4.1565s
Raw Speedup:         6.1232 x
Final Reward (Score): 6.1232
---------------------------
..

=============================== warnings summary ===============================
test_outputs.py: 1100 warnings
  /tests/evaluator.py:79: DeprecationWarning: The `disp` argument is deprecated and will be removed in SciPy 1.18.0.
    X, _ = scipy.linalg.sqrtm(

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
==================================== PASSES ====================================
=========================== short test summary info ============================
PASSED ../tests/test_outputs.py::test_solver_exists
PASSED ../tests/test_outputs.py::test_solver_validity
PASSED ../tests/test_outputs.py::test_solver_speedup
================= 3 passed, 1100 warnings in 445.83s (0:07:25) =================
