Skip to content

ABRIK accuracy benchmark: singular-value error without the sqrt(eps) floor - #278

Open
mmelnich wants to merge 1 commit into
mainfrom
abrik/sval-rayleigh-metric
Open

mmelnich wants to merge 1 commit into
mainfrom
abrik/sval-rayleigh-metric

Conversation

@mmelnich

Copy link
Copy Markdown
Contributor

Summary

ABRIK_accuracy_analysis reports the singular-value error as sval_pyth = sqrt(|s_gesdd^2 - s_abrik^2|) / s_gesdd. That is the square root of a difference of two numbers that are each accurate to machine precision, so it cannot fall below about sqrt(2 eps) = 2e-8, even when s_abrik is correct to all digits.

This PR adds a version of the same metric that has no such floor. It is computed from the computed singular vectors rather than from s_abrik. Write each computed vector as the GESDD vector plus a small orthogonal correction: v = c_v v_gesdd + s_v w and u = c_u u_gesdd + s_u z. Then the Rayleigh quotient rho = u' A v satisfies

1 - rho / sigma = (1 - c_u c_v) - s_u s_v (z' A w) / sigma,

and every term on the right is small by construction. The cosines and sines come from the Householder QR that the singular-vector error already runs, and z' A w costs one matvec per triplet.

Changes

  • benchmark/bench_ABRIK/ABRIK_accuracy_analysis.cc: three new CSV columns, all appended after the existing ones.
    • rq_diff: the signed 1 - rho / sigma from the identity above.
    • sval_rq: sqrt(|rq_diff (2 - rq_diff)|), the Pythagorean error with rho in place of s_abrik.
    • rq_gap: |rho - s_abrik| / s_abrik, with rho formed directly, so readers can see how far the measured Rayleigh quotient is from the returned singular value.
  • The two-column QR helper now also returns the cosine and the orthogonal part. per_triplet_residuals optionally returns u' A v.
  • The existing thirteen columns are unchanged.

…loor

The sval_pyth column, sqrt(|s_gesdd^2 - s_abrik^2|) / s_gesdd, is the root of a
difference of two eps-accurate numbers, so it floors at sqrt(2 eps), about 2e-8, even
when s_abrik is correct to all digits. Three new columns measure the same quantity
from the computed vectors instead:

- rq_diff = 1 - rho / sigma (signed), with rho = u' A v of ABRIK's unit-scaled vectors
  and sigma the singular value of GESDD's triplet taken as exact. Writing
  v = c_v v_gesdd + s_v w and u = c_u u_gesdd + s_u z gives
  rq_diff = (1 - c_u c_v) - s_u s_v (z' A w) / s_gesdd, a sum of small terms.
  c, s and s w come from the Householder QR that the svec_diff sine already runs
  (now followed by ORGQR); z' A w costs one matvec per triplet.
- sval_rq = sqrt(|rq_diff (2 - rq_diff)|): sval_pyth with rho in place of s_abrik.
- rq_gap = |u' A v / (||u|| ||v||) - s_abrik| / s_abrik: how far the measured
  Rayleigh quotient is from the returned singular value.

The existing thirteen columns are unchanged; svec_diff reads the same |R(2,2)| as
before. The CSV now has sixteen columns.

Checked on two 1500 x 1500 dense synthetic inputs (b = 16, 32 iterations, two runs,
MKL). Where sval_pyth > 1e-5, sval_rq agrees with it to within 7e-6 relative. Below
the floor, sval_rq tracks res_err_abrik (median ratio 1.0) down to about 1e-15.
rq_gap is at most 2.6e-15 on every triplet. A numpy replica of the formula agrees
with a 40-digit mpmath reference: 1.512e-11 against 1.512e-11 at an angle of 1e-12,
where the literal (s_gesdd - rho) / s_gesdd would give 3.9e-8.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant