Repository navigation
Conversation
The vcpkg nightly (Ubuntu) fails to compile DenseQpSolver.cpp: DenseQpSolver.cpp:269: objectivePermutation = objectiveQr.colsPermutation(); error: static assertion failed: YOU_MIXED_DIFFERENT_NUMERIC_TYPES... objectivePermutation, added in borglab#2921, was declared as PermutationMatrix<Dynamic, Dynamic>, whose index type is int. Eigen 5 indexes ColPivHouseholderQR permutations with DefaultPermutationIndex, which is lapack_int whenever EIGEN_USE_LAPACKE is defined. The vcpkg workflow enables GTSAM_WITH_EIGEN_MKL (and so EIGEN_USE_MKL_ALL), and MKL's ILP64 interface on Linux makes lapack_int a 64-bit long long. Declare the cache with ColPivHouseholderQR<Matrix>::PermutationType so it always matches the decomposition: int with the bundled Eigen 3.4, lapack_int with Eigen 5 + LAPACKE. This is the only such assignment in the library; the full library builds with Eigen 5.0.1 + MKL ILP64 + -Werror after this change.
The vcpkg nightly (Windows; Ubuntu too once it compiles) fails: testQpSolver.cpp:850: Exception: ActiveSetSolver: failed to converge. SquareRootAffineRhsRefinement, added in borglab#2923, minimizes ||J x - b||^2 with ||J||^2 ~ 1e16. originalQpKktSatisfied required each stationarity residual to be at most multiplierTolerance (1e-7) in absolute terms, but evaluating J^T (J x - b) at a floating-point optimum has roundoff of order eps |J|^T (|J| |x| + |b|) ~ 3. The check could therefore only pass at a bit-exact iterate. With EIGEN_USE_MKL_ALL, inplace_QR is routed to MKL dgeqrf, whose R differs from Eigen's by one ulp. The sparse refinement then settles at |x - x*| ~ 8e-16 with a gradient of 1.49 instead of exactly zero; every iteration recomputes the same candidate until the iteration limit. Without MKL the refinement happens to land exactly on x*. Mirror scaledGapSatisfied, which already allows 64 eps times the magnitude of the summed terms: accumulate |A_k|^T (|A| |x| + |b|) for Jacobian costs, |G_k| |x| + |g_k| for Hessian costs and |A_c^T| |lambda| for constraint rows, and allow 64 eps of it per stationarity component. Other factor types add no allowance, and primal-feasibility and dual-sign checks are unchanged. Across the constrained test suite this changes exactly one certificate decision, the one in SquareRootAffineRhsRefinement; every other evaluation has an allowance of at most 2.8e-9, far below the 1e-7 tolerance.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The nightly vcpkg workflow fails on both MKL platforms. The two failures have
separate causes, introduced by #2921 and #2923, and this PR fixes each in its
own commit. The vcpkg baseline resolves to Eigen 5.0.1 and the workflow sets
GTSAM_WITH_EIGEN_MKL=ON, so Eigen routes LAPACK-backed decompositions throughMKL on Linux and Windows. macOS does not install MKL and the other workflows use
the bundled Eigen 3.4, which is why only these two jobs fail.
Ubuntu:
DenseQpSolver.cppdoes not compileThe cached
objectivePermutationadded in #2921 is aPermutationMatrix<Dynamic, Dynamic>, whose index type isint. Eigen 5indexes
ColPivHouseholderQRpermutations withDefaultPermutationIndex, whichis
lapack_intwhenever LAPACKE is enabled. With MKL's ILP64 interface on Linux(
-DMKL_ILP64), that islong long. Windows links the LP64 interface, solapack_intisintthere and the file compiles.The fix declares the member as
ColPivHouseholderQR<Matrix>::PermutationType,so it always matches the decomposition:
intwith Eigen 3.4,lapack_intwithEigen 5 and LAPACKE. This is the only such assignment in the library.
Windows (and Ubuntu, once it compiles):
failed to convergeSquareRootAffineRhsRefinement, added in #2923, minimizes‖J x − b‖² with ‖J‖² ≈ 1e16 and the exact minimizer x* = (1, 0). The active-set
convergence certificate,
originalQpKktSatisfied, required every stationarityresidual to be at most
multiplierTolerance(1e-7) in absolute terms. Evaluatingthe gradient Jᵀ(J x − b) at a floating-point optimum has roundoff of order
eps · |J|ᵀ(|J| |x| + |b|) ≈ 3 for this cost. The check could therefore pass only
at a bit-exact iterate.
With
EIGEN_USE_MKL_ALL, GTSAM'sinplace_QRis routed to MKL'sdgeqrf, whichproduces an R factor one ulp different from Eigen's. The sparse refinement then
settles at x = (1.0000000000000002, −7.7e-16), which is accurate to 8e-16 but
has a gradient of 1.49. Each iteration recomputes the same candidate until the
iteration limit. Without MKL, the refinement happens to land exactly on (1, 0),
where the gradient is exactly zero. The pre-#2923 refinement was equally
accurate here; the test exercises whether convergence can be certified for an
ill-scaled square-root cost.
The fix gives the stationarity check the same kind of roundoff allowance that
scaledGapSatisfiedalready applies to the duality gap, 64·eps times themagnitude of the summed terms:
Other factor types add no allowance. Primal feasibility, multiplier signs and
the gap check are unchanged.
Effect on other problems
To check that the allowance does not change behavior on well-scaled problems, I
temporarily logged every certificate evaluation in the constrained test suite.
Exactly one decision changed: the one in
SquareRootAffineRhsRefinement, withresidual 1.49 and allowance 284. Every other evaluation had an allowance of at
most 2.8e-9, at least 35 times below the 1e-7 tolerance, with residuals far from
that boundary.
Validation
The build used Eigen 5.0.1,
EIGEN_USE_MKL_ALL,MKL_ILP64andGTSAM_BUILD_WITH_WERROR=ONwith GCC on Linux, matching the vcpkg Ubuntu job.DenseQpSolver.cppfails with the static assertion above.testQpSolverfails at line 850 with the same message as the Windows job.
gtsam/constrained/testspass.gtsam_unstable/lineartestQPSolverandtestLPSolver(which wrap
ActiveSetSolver) pass withGTSAM_ALLOW_DEPRECATED_SINCE_V43enabled.
git diff --checkis clean, and the changed lines follow.clang-format.