Python wrappers
Public Python APIs implemented by this engine symbol.Compute the reduced QR factorisation of a float matrix.
Forward calls LAPACK *geqrf + *orgqr on the CPU stream or
mlx::core::linalg::qr on the GPU stream and returns the two
factors as a length-2 vector {Q, R}. Autograd is not wired —
both outputs are leaves in the gradient graph.
Math
Shape
a:(..., m, n).Q:(..., m, k),R:(..., k, n)with .
References
Golub & Van Loan, Matrix Computations (4th ed.), Algorithm 5.2.1 (Householder QR). Walter & Lehmann, "Algorithmic Differentiation of Linear Algebra Functions" (2010), §3. Bettale, "Differentiating the QR Decomposition" (2013).
See Also
inv_op : Matrix inverse, often composed with QR for least squares. Lstsq.h : Direct least-squares solver built on top of QR.
Parameters
aTensorImplPtr(..., m, n). Must be at least 2-D and have a floating-point dtype. Leading dimensions are treated as independent batch dimensions.Returns
std::vector<TensorImplPtr>Length-2 vector {Q, R} where - Q has shape (..., m, k) with , - R has shape (..., k, n) and is upper-triangular, and .
Raises
ValueErrora is fewer than 2 dimensions or has a non-float dtype.Notes
- Only the reduced ("thin") factorisation is produced;
mode='complete'parity with the reference framework is not currently exposed. - No backward is registered. Wrapping
qr_opinside a graph whereQorRrequires gradients will yield leaf tensors.