Probabilistic Rounding Error Analysis for Sums Eric Hallman North - - PowerPoint PPT Presentation

probabilistic rounding error analysis for sums
SMART_READER_LITE
LIVE PREVIEW

Probabilistic Rounding Error Analysis for Sums Eric Hallman North - - PowerPoint PPT Presentation

Probabilistic Rounding Error Analysis for Sums Eric Hallman North Carolina State University Spring 2020 Eric Hallman (North Carolina State University) Probabilistic Rounding Error Analysis Spring 2020 1 / 32 Introduction The problem: for x 1


slide-1
SLIDE 1

Probabilistic Rounding Error Analysis for Sums

Eric Hallman

North Carolina State University

Spring 2020

Eric Hallman (North Carolina State University) Probabilistic Rounding Error Analysis Spring 2020 1 / 32

slide-2
SLIDE 2

Introduction

The problem: for x1, . . . , xn ∈ R, compute sn :=

n

  • i=1

xi Compute the sum using recursive summation: ˆ s1 := x1, ˆ si := fl(ˆ si−1 + xi), i = 2 : n. The goal: bound the error |ˆ sn − sn|.

Eric Hallman (North Carolina State University) Probabilistic Rounding Error Analysis Spring 2020 2 / 32

slide-3
SLIDE 3

Introduction

Classical model for floating-point arithmetic:

Model (Classical)

For any floating point numbers a and b, fl(a ⊙ b) = (a ⊙ b)(1 + δ), |δ| ≤ u, ⊙ ∈ {+, −, ×, /, √}, where u is the unit roundoff.

Eric Hallman (North Carolina State University) Probabilistic Rounding Error Analysis Spring 2020 3 / 32

slide-4
SLIDE 4

Outline

1

Background Deterministic Error Bounds Probabilistic Error Analysis

2

Intermediate Sums

3

New Bounds

4

Experiments/Conclusions

Eric Hallman (North Carolina State University) Probabilistic Rounding Error Analysis Spring 2020 4 / 32

slide-5
SLIDE 5

Deterministic Bound

Computing the partial sums: ˆ s1 = x1, ˆ s2 = (ˆ s1 + x2)(1 + δ2) = x1(1 + δ2) + x2(1 + δ2), ˆ s3 = (ˆ s2 + x3)(1 + δ3) = x1(1 + δ2)(1 + δ3) + x2(1 + δ2)(1 + δ3) + x3(1 + δ3), . . . ˆ sn =

n

  • i=1

xi  

n

  • j=max{2,i}

(1 + δj)  

Eric Hallman (North Carolina State University) Probabilistic Rounding Error Analysis Spring 2020 5 / 32

slide-6
SLIDE 6

Deterministic Bound

Lemma (Deterministic Error Bound)

If |δi| ≤ u for i = 1 : n, and nu < 1, then

n

  • i=1

(1 + δi) = 1 + θn, where |θn| ≤ nu 1 − nu =: γn. Consequently, |ˆ sn − sn| ≤ γn

n

  • i=1

|xi|. γn ≈ nu as long as nu ≪ 1.

Eric Hallman (North Carolina State University) Probabilistic Rounding Error Analysis Spring 2020 6 / 32

slide-7
SLIDE 7

Deterministic Bound

Higham (2002): Whenever we write γn there is an implicit assumption that nu < 1, which is true in virtually any circumstance that might arise with IEEE single or double precision arithmetic.

Eric Hallman (North Carolina State University) Probabilistic Rounding Error Analysis Spring 2020 7 / 32

slide-8
SLIDE 8

Low-Precision Arithmetic

Normalized non-zero floating point numbers: x = (−1)s(1.f )2 · 2e Precision Sign Exp Float u Double (f64) 1 11 52 1.11 · 10−16 Single (f32) 1 8 23 5.96 · 10−8 Half (f16) 1 5 10 4.88 · 10−4 Quarter (??) 1 3 4 3.13 · 10−2 Problem sizes getting larger Half precision increasingly common When nu > 1, bounds using γn become useless

Eric Hallman (North Carolina State University) Probabilistic Rounding Error Analysis Spring 2020 8 / 32

slide-9
SLIDE 9

Outline

1

Background Deterministic Error Bounds Probabilistic Error Analysis

2

Intermediate Sums

3

New Bounds

4

Experiments/Conclusions

Eric Hallman (North Carolina State University) Probabilistic Rounding Error Analysis Spring 2020 9 / 32

slide-10
SLIDE 10

Probabilistic Model

Solution: abandon worst-case bounds, try probabilistic analysis instead

Model (Probabilistic)

For any floating point numbers a and b, fl(a ⊙ b) = (a ⊙ b)(1 + δ), |δ| ≤ u, ⊙ ∈ {+, −, ×, /, √}, where u is the unit roundoff. The quantities δ for each computation are independent random variables with mean zero. This model is wrong. But is it useful?

Eric Hallman (North Carolina State University) Probabilistic Rounding Error Analysis Spring 2020 10 / 32

slide-11
SLIDE 11

Probabilistic Model

Central Limit Theorem: if e = n

i=1 δiti and |δi| ≤ u, then

|e| ≤ λu n

  • i=1

t2

i

1/2 with high probability for large n. λ modest in size, controls probability Deterministic bound u n

i=1 |ti| can be factor of √n larger

Eric Hallman (North Carolina State University) Probabilistic Rounding Error Analysis Spring 2020 11 / 32

slide-12
SLIDE 12

Probabilistic Model

Wilkinson (1961): In general, the statistical distribution of the rounding errors will reduce considerably the function of n occurring in the relative errors. We might expect in each case that this function should be replaced by something which is no bigger than its square root and is usually appreciably smaller. Ultimate goal: replace nu in error bounds with something that grows like √nu

Eric Hallman (North Carolina State University) Probabilistic Rounding Error Analysis Spring 2020 12 / 32

slide-13
SLIDE 13

Probabilistic Bound

Theorem (Hoeffding’s Inequality)

Let X1, . . . , Xn be independent random variables satisfying |Xi| ≤ ci, i = 1 : n. The sum S = n

i=1 Xi satisfies

Pr(|S − E[S]| ≥ ξ) ≤ 2 exp

ξ2 2 n

i=1 c2 i

  • .

Assumptions: random variables are independent and bounded. Holds for all n, not just as n → ∞

Eric Hallman (North Carolina State University) Probabilistic Rounding Error Analysis Spring 2020 13 / 32

slide-14
SLIDE 14

Probabilistic Bound

Lemma (Higham/Mary 2018)

Assume the probabilistic model for roundoff errors. If |δi| ≤ u for i = 1 : n, and nu < 1, then

n

  • i=1

(1 + δi) = 1 + ˜ θn, where |˜ θn| ≤ ˜ γn(λ) := exp

  • λ√nu + nu2

1 − u

  • − 1 ≈ λ√nu

with failure probability at most Q(λ) = 2 exp

  • −λ2(1 − u)2

2

  • .

Eric Hallman (North Carolina State University) Probabilistic Rounding Error Analysis Spring 2020 14 / 32

slide-15
SLIDE 15

Probabilistic Bound

Deterministic bound: |ˆ sn − sn| ≤ γn

n

  • i=1

|xi| ≈ nu

n

  • i=1

|xi|. Probabilistic bound: WFP at most Q(λ), |ˆ sn − sn| ≤ ˜ γn(λ)

n

  • i=1

|xi| ≈ λ√nu

n

  • i=1

|xi|. Probabilistic approximation holds while λ√nu ≪ 1

Eric Hallman (North Carolina State University) Probabilistic Rounding Error Analysis Spring 2020 15 / 32

slide-16
SLIDE 16

Probabilistic Bound

How does the Higham/Mary bound perform in practice? Much stronger than deterministic bound Slightly pessimistic on random [0, 1] data Way off the mark on random [−1, 1] data

Eric Hallman (North Carolina State University) Probabilistic Rounding Error Analysis Spring 2020 16 / 32

slide-17
SLIDE 17

Running Error Bound

Idea (Higham 2002): rewrite the computed sums as ˆ si = ˆ si−1 + xi 1 + δi , |δi| ≤ u. Result: the deterministic running error bound |ˆ sn − sn| =

  • n
  • i=1

δi ˆ si

  • ≤ u

n

  • i=1

|ˆ si| This can be much smaller than the a priori bounds!

Eric Hallman (North Carolina State University) Probabilistic Rounding Error Analysis Spring 2020 17 / 32

slide-18
SLIDE 18

Running Error Bound

Higham 2002: In designing or choosing a summation method to achieve high accuracy, the aim should be to minimize the absolute values of the intermediate sums [ˆ si]. Our goal: find the probabilistic version of the running error bound Problem: Quantities ˆ si depend on δ terms

Difficult to apply concentration bounds directly to n

i=1 δi ˆ

si

Eric Hallman (North Carolina State University) Probabilistic Rounding Error Analysis Spring 2020 18 / 32

slide-19
SLIDE 19

Intermediate Sums

Our strategy: rewrite error as ˆ sn − sn =

n

  • i=2

 siδi

n

  • j=i+1

(1 + δj)   . Deterministic bound: |ˆ sn − sn| ≤ u(1 + γn)

n

  • i=2

|si|. Two small wrinkles in getting the probabilistic version: δi independent δi n

j=i+1(1 + δj) independent

The term (1 + γn) is a problem when nu > 1

Eric Hallman (North Carolina State University) Probabilistic Rounding Error Analysis Spring 2020 19 / 32

slide-20
SLIDE 20

Martingales

Use a martingale!

Definition (Martingale)

A squence of random variables X1, X2, . . . is a martingale with respect to δ1, δ2, . . . if for i ≥ 1

1

Xi is a function of δ1, . . . , δi−1,

2

E[|Xi|] < ∞

3

E[Xi+1|δ1, . . . , δi−1] = Xi. Examples: unbiased random walk, gambler playing a fair game The increments (Xi+1 − Xi) do not need to be independent!

Eric Hallman (North Carolina State University) Probabilistic Rounding Error Analysis Spring 2020 20 / 32

slide-21
SLIDE 21

Martingales

We can relax the requirements of Hoeffding’s Inequality.

Theorem (Azuma’s Inequality)

Suppose a martingale {X1, . . . , Xn} satisfies |Xi − Xi−1| ≤ ci, i = 2 : n. Then Pr(|Xn − X1| ≥ ξ) ≤ 2 exp

ξ2 2 n

i=2 c2 i

  • .

Eric Hallman (North Carolina State University) Probabilistic Rounding Error Analysis Spring 2020 21 / 32

slide-22
SLIDE 22

Martingales

To construct the martingale, work backwards: X1 = sn, X2 = X1 + snδn, X3 = X2 + sn−1δn−1(1 + δn), . . . Xn = Xn−1 + s2δ2

n

  • j=3

(1 + δj) Apply Azuma’s inequality with ci = |sn−i+2|u(1 + γn), ξ = λu(1 + γn) n

  • i=2

s2

i

1/2

Eric Hallman (North Carolina State University) Probabilistic Rounding Error Analysis Spring 2020 22 / 32

slide-23
SLIDE 23

Martingales

Deterministic bound: |ˆ sn − sn| ≤ u(1 + γn)

n

  • i=2

|si| Probabilistic bound: |ˆ sn − sn| ≤ λu(1 + γn) n

  • i=2

s2

i

1/2 with failure probability at most 2 exp

  • − λ2

2

  • Not good enough: (1 + γn) blows up when nu > 1!

Eric Hallman (North Carolina State University) Probabilistic Rounding Error Analysis Spring 2020 23 / 32

slide-24
SLIDE 24

Probabilistic Azuma

Second idea: why use the bound

  • δi

n

  • j=i+1

(1 + δj)

  • ≤ u(1 + γn),

when the left-hand side is probably much smaller?

Eric Hallman (North Carolina State University) Probabilistic Rounding Error Analysis Spring 2020 24 / 32

slide-25
SLIDE 25

Probabilistic Azuma

Relax Azuma’s inequality by allowing the bounds to fail with small probability.

Theorem (Azuma’s Inequality, Probabilistic Version)

Suppose a martingale {X1, . . . , Xn} satisfies |Xi − Xi−1| ≤ ci, i = 2 : n with total failure probability at most η. Then Pr(|Xn − X1| ≥ ξ) ≤ 2 exp

ξ2 2 n

i=2 c2 i

  • + η.

Using η = Q(λ), we can replace γn with ˜ γn(λ) in our bounds at minimal cost!

Eric Hallman (North Carolina State University) Probabilistic Rounding Error Analysis Spring 2020 25 / 32

slide-26
SLIDE 26

New Bound

Deterministic bound: |ˆ sn − sn| ≤ u(1 + γn)

n

  • i=2

|si| Probabilistic bound: |ˆ sn − sn| ≤ λu(1 + ˜ γn(λ)) n

  • i=2

s2

i

1/2 with failure probability at most 2Q(λ). Now works well when nu > 1 and λ√nu ≪ 1

Eric Hallman (North Carolina State University) Probabilistic Rounding Error Analysis Spring 2020 26 / 32

slide-27
SLIDE 27

Numerical Experiments

Half precison, uniform [-1,1] data ˜ γn: the Higham/Mary probabilistic bound µ: the deterministic running bound ν: our new probabilistic bound ǫ: the true error

Eric Hallman (North Carolina State University) Probabilistic Rounding Error Analysis Spring 2020 27 / 32

slide-28
SLIDE 28

Numerical Experiments

Quarter precison, uniform [-1,1] data Single/Half precision: we typically overestimate the error by a factor of 10 Quarter precison: similar performance to the deterministic running bound

Eric Hallman (North Carolina State University) Probabilistic Rounding Error Analysis Spring 2020 28 / 32

slide-29
SLIDE 29

Numerical Experiments

Half precison, uniform [-1,1] data Our estimates break down when λ√nu > 1 Still fails to capture behavior in practice for large n

Eric Hallman (North Carolina State University) Probabilistic Rounding Error Analysis Spring 2020 29 / 32

slide-30
SLIDE 30

Conclusions

Summary of bounds: Deterministic Probabilistic Data γn n

i=1 |xi|

˜ γn n

i=1 |xi|

Intermediate Sums u(1 + γn) n

i=2 |si|

λu(1 + ˜ γn(λ)) n

i=2 s2 i

1/2 Running Bound u n

i=1 |ˆ

si| ??? (How) can we drop the (1 + ˜ γn(λ)) term? (How) can we develop an effective running bound?

Eric Hallman (North Carolina State University) Probabilistic Rounding Error Analysis Spring 2020 30 / 32

slide-31
SLIDE 31

Conclusions

Thanks for listening!

Eric Hallman (North Carolina State University) Probabilistic Rounding Error Analysis Spring 2020 31 / 32

slide-32
SLIDE 32

For Further Reading I

Nicholas J. Higham Accuracy and Stability of Numerical Algorithms, 2ed. 2002. Cleve Moler “Half Precision” 16-bit Floating Point Arithmetic https://blogs.mathworks.com/cleve/2017/05/08/ half-precision-16-bit-floating-point-arithmetic/ Nicholas J. Higham and Theo Mary A New Approach to Probabilistic Rounding Error Analysis http://eprints.maths.manchester.ac.uk/2673/1/paper.pdf Fan Chung and Linyuan Lu Concentration Inequalities and Martingale Inequalities—a Survey http://people.math.sc.edu/lu/papers/concen.pdf

Eric Hallman (North Carolina State University) Probabilistic Rounding Error Analysis Spring 2020 32 / 32