for Programs that Execute on Unreliable Hardware Michael Carbin , - - PowerPoint PPT Presentation

for programs that execute on
SMART_READER_LITE
LIVE PREVIEW

for Programs that Execute on Unreliable Hardware Michael Carbin , - - PowerPoint PPT Presentation

Rely: Verifying Quantitative Reliability for Programs that Execute on Unreliable Hardware Michael Carbin , Sasa Misailovic, and Martin Rinard MIT CSAIL Image Scaling Image Scaling Kernel: Bilinear Interpolation f ( ) = Bilinear


slide-1
SLIDE 1

Rely: Verifying Quantitative Reliability for Programs that Execute on Unreliable Hardware

Michael Carbin, Sasa Misailovic, and Martin Rinard MIT CSAIL

slide-2
SLIDE 2

Image Scaling

slide-3
SLIDE 3

f (

)

Image Scaling Kernel: Bilinear Interpolation

=

slide-4
SLIDE 4

Bilinear Interpolation

int bilinear_interpolation(int i, int j, int src[][], int dest[][]) { int i_src = map_y(i, src, dest), j_src = map_x(j, src, dest); int up = i_src - 1, down = i_src + 1, left = j_src – 1, right = j_src + 1; int val = src[up][left] + src[up][right] + src[down][right] + src[down][left]; return 0.25 * val; }

slide-5
SLIDE 5

Bilinear Interpolation

int bilinear_interpolation(int i, int j, int src[][], int dest[][]) { int i_src = map_y(i, src, dest), j_src = map_x(j, src, dest); int up = i_src - 1, down = i_src + 1, left = j_src – 1, right = j_src + 1; int val = src[up][left] + src[up][right] + src[down][right] + src[down][left]; return 0.25 * val; }

slide-6
SLIDE 6

Unreliable Hardware

Unreliable Units (ALUs and Memories)

  • May produce incorrect results
  • Faster, smaller, and lower power

Registers

Memory

CU

CPU

ALU

slide-7
SLIDE 7

Image Scaling with Approximate Bilinear Interpolation

20% 40% 60% 80% 99% 99.9% 90% Reliability

slide-8
SLIDE 8

Unreliable Hardware

Necessitates

  • Hardware Specification: probability operations execute correctly
  • Software Specification: required reliability of computations
  • Analysis: verify software satisfies its specification on hardware

Registers

Memory

CU

CPU

ALU

slide-9
SLIDE 9

Rely: a Language for Quantitative Reliability

20% 40% 60% 80% 99% 99.9% 90% Reliability

Hardware Specification (Architect) Software Specification (Developer) Static Analysis (Language)

slide-10
SLIDE 10

Hardware Specification

hardware {

  • perator (+) = 1 - 10^-7;
  • perator (-) = 1 - 10^-7;
  • perator (*) = 1 - 10^-7;
  • perator (<) = 1 - 10^-7;

memory urel {rd = 1 - 10^-7, wr = 1}; }

slide-11
SLIDE 11

Approximate Bilinear Interpolation in Rely

int bilinear_interpolation(int i, int j, int src[][], int dest[][]) { int i_src = map_y(i, src, dest), j_src = map_x(j, src, dest); int up = i_src - 1, down = i_src + 1, left = j_src – 1, right = j_src + 1; int val = src[up][left] +. src[up][right] +. src[down][right] +. src[down][left]; return 0.25 *. val; }

Unreliable Operations: executed on unreliable ALUs

slide-12
SLIDE 12

Approximate Bilinear Interpolation in Rely

int bilinear_interpolation(int i, int j, int in urel src[][], int in urel dest[][]) { int i_src = map_y(i, src, dest), j_src = map_x(j, src, dest); int up = i_src - 1, down = i_src + 1, left = j_src – 1, right = j_src + 1; int in urel val = src[up][left] +. src[up][right] +. src[down][right] +. src[down][left]; return 0.25 *. val; }

Unreliable Memories: stored in unreliable SRAM/DRAM

slide-13
SLIDE 13

What is reliability?

slide-14
SLIDE 14
  • Reliable Hardware
  • One Execution
  • Unreliable Hardware
  • Multiple Executions
  • Reliability
  • Probability unreliable

execution reaches same state

  • Or, 𝑆({𝑦, 𝑧}) = probability over distribution of

states that x and y (only) have correct values.

Semantics of Reliability

slide-15
SLIDE 15
  • Reliable Hardware
  • One Execution
  • Unreliable Hardware
  • Multiple Executions
  • Reliability
  • Probability unreliable

execution reaches same state

  • Or, 𝑆({𝑦, 𝑧}) = probability over distribution of

states that x and y (only) have correct values.

Semantics of Reliability

slide-16
SLIDE 16

Approximate Bilinear Interpolation Reliability Specification

int bilinear_interpolation(int i, int j, int in urel src[][], int in urel dest[][]);

slide-17
SLIDE 17
  • Reliability of output is a function of reliability of inputs

Approximate Bilinear Interpolation Reliability Specification

int<.99> bilinear_interpolation(int i, int j, int in urel src[][], int in urel dest[][]);

slide-18
SLIDE 18
  • Reliability of output is a function of reliability of inputs
  • The term R(i, j, src, dest) abstracts the joint

reliability of the function’s inputs on entry

Approximate Bilinear Interpolation Reliability Specification

int<.99 * R(i, j, src, dest)> bilinear_interpolation(int i, int j, int in urel src[][], int in urel dest[][]);

slide-19
SLIDE 19
  • Reliability of output is a function of reliability of inputs
  • The term R(i, j, src, dest) abstracts the joint

reliability of the function’s inputs on entry

  • Coefficient .99 bounds reliability degradation

Approximate Bilinear Interpolation Reliability Specification

int<.99 * R(i, j, src, dest)> bilinear_interpolation(int i, int j, int in urel src[][], int in urel dest[][]);

slide-20
SLIDE 20

How does Rely verify reliability?

slide-21
SLIDE 21

Rely’s Analysis Framework

  • Precondition generator for statements

𝑗

𝑠

𝑗 ∗ 𝑆 {𝑦𝑗1, … , 𝑦𝑗𝑜} ≤ 𝑠′𝑗 ∗ 𝑆 {𝑦′𝑗1, … , 𝑦′𝑗𝑛}

{ Precondition } s { Postcondition }

Specification Computation

0.9 ∗ 𝑆 {x} ≤ 0.99 ∗ 𝑆({y})

slide-22
SLIDE 22

Assignment Rule

{𝑠

1 ∗ 𝑆

𝑦1 … , 𝑦𝑜 ≤ 𝑠

2 ∗ 𝑠𝑓𝑚 𝑓 ∗ 𝑥𝑠 𝑦′ ∗ 𝑆( 𝑦′1, … , 𝑦′𝑛 ∪ 𝑔𝑤 𝑓 )}

x’ = e {𝑠

1 ∗ 𝑆

𝑦1 … , 𝑦𝑜 ≤ 𝑠

2 ∗ 𝑆({𝑦′1, … , 𝑦′, … , 𝑦′𝑛)}

slide-23
SLIDE 23

Assignment Rule

{𝑠

1 ∗ 𝑆

𝑦1 … , 𝑦𝑜 ≤ 𝑠

2 ∗ 𝑠𝑓𝑚 𝑓 ∗ 𝑥𝑠 𝑦′ ∗ 𝑆( 𝑦′1, … , 𝑦′𝑛 ∪ 𝑔𝑤 𝑓 )}

x’ = e {𝑠

1 ∗ 𝑆

𝑦1 … , 𝑦𝑜 ≤ 𝑠

2 ∗ 𝑆({𝑦′1, … , 𝑦′, … , 𝑦′𝑛)} Unmodified

slide-24
SLIDE 24

Assignment Rule

{𝑠

1 ∗ 𝑆

𝑦1 … , 𝑦𝑜 ≤ 𝑠

2 ∗ 𝑠𝑓𝑚 𝑓 ∗ 𝑥𝑠 𝑦′ ∗ 𝑺( 𝒚′𝟐, … , 𝒚′𝒏 ∪ 𝒈𝒘 𝒇 )}

x’ = e {𝑠

1 ∗ 𝑆

𝑦1 … , 𝑦𝑜 ≤ 𝑠

2 ∗ 𝑺({𝒚′𝟐, … , 𝒚′, … , 𝒚′𝒏)}

Standard Substitution

slide-25
SLIDE 25

Assignment Rule

  • 𝑠𝑓𝑚 𝑓 ∗ 𝑥𝑠 𝑦′ is the probability the expression and

write execute correctly

{𝑠

1 ∗ 𝑆

𝑦1 … , 𝑦𝑜 ≤ 𝑠

2 ∗ 𝒔𝒇𝒎 𝒇 ∗ 𝒙𝒔 𝒚′ ∗ 𝑆( 𝑦′1, … , 𝑦′𝑛 ∪ 𝑔𝑤 𝑓 )}

x’ = e {𝑠

1 ∗ 𝑆

𝑦1 … , 𝑦𝑜 ≤ 𝑠

2 ∗ 𝑆({𝑦′1, … , 𝑦′, … , 𝑦′𝑛)}

slide-26
SLIDE 26

int<.99 * R(i,j,src,dest)> bilinear_interpolation(int i, int j, int in urel src[][], int in urel dest[][]) { int i_src = map_y(i, src, dest), j_src = map_x(j, src, dest); int up = i_src - 1, down = i_src + 1, left = j_src – 1, right = j_src + 1; int in urel val = src[up][left] +. src[up][right] +. src[down][right] +. src[down][left]; return 0.25 *. val; }

Verifying the Reliability of Bilinear Interpolation

slide-27
SLIDE 27

Verifying the Reliability of Bilinear Interpolation

  • 1. Generate postcondition from return statement
  • 2. Work backwards to produce verification condition
  • 3. Use hardware specification to replace reliabilities

.99 ∗ 𝑆 𝑡𝑠𝑑, 𝑗, 𝑘, 𝑒𝑓𝑡𝑢 ≤ 𝑠𝑒(𝑤𝑏𝑚) ∗ 𝑝𝑞(∗. ) ∗ 𝑆(𝑤𝑏𝑚) .99 ∗ 𝑆 𝑡𝑠𝑑, 𝑗, 𝑘, 𝑒𝑓𝑡𝑢 ≤ 𝑠𝑒(𝑤𝑏𝑚) ∗ 𝑝𝑞(∗. ) ∗ 𝑠𝑒 𝑡𝑠𝑑 4 ∗ 𝑝𝑞 +. 3 ∗ 𝑥𝑠(𝑤𝑏𝑚) ∗ 𝑆(𝑡𝑠𝑑, 𝑗, 𝑘, 𝑒𝑓𝑡𝑢) .99 ∗ 𝑆 𝑡𝑠𝑑, 𝑗, 𝑘, 𝑒𝑓𝑡𝑢 ≤ (1 − 10−7) ∗ (1 − 10−7) ∗ 1 − 10−7 4 ∗ 1 − 10−7 3 ∗ 1.0 ∗ 𝑆(𝑡𝑠𝑑, 𝑗, 𝑘, 𝑒𝑓𝑡𝑢) return 0.25 *. val;

Reliability of return Reliability of sum of neighbors

slide-28
SLIDE 28

Verifying the Reliability of Bilinear Interpolation

  • 1. Generate postcondition from return statement
  • 2. Work backwards to produce verification condition
  • 3. Use hardware specification to replace reliabilities
  • 4. Discharge Verification Condition

.99 ∗ 𝑆 𝑡𝑠𝑑, 𝑗, 𝑘, 𝑒𝑓𝑡𝑢 ≤ 𝑠𝑒(𝑤𝑏𝑚) ∗ 𝑝𝑞(∗. ) ∗ 𝑆(𝑤𝑏𝑚) .99 ∗ 𝑆 𝑡𝑠𝑑, 𝑗, 𝑘, 𝑒𝑓𝑡𝑢 ≤ 𝑠𝑒(𝑤𝑏𝑚) ∗ 𝑝𝑞(∗. ) ∗ 𝑠𝑒 𝑡𝑠𝑑 4 ∗ 𝑝𝑞 +. 3 ∗ 𝑥𝑠(𝑤𝑏𝑚) ∗ 𝑆(𝑡𝑠𝑑, 𝑗, 𝑘, 𝑒𝑓𝑡𝑢) .99 ∗ 𝑆 𝑡𝑠𝑑, 𝑗, 𝑘, 𝑒𝑓𝑡𝑢 ≤

. 999999 ∗ 𝑆(𝑡𝑠𝑑, 𝑗, 𝑘, 𝑒𝑓𝑡𝑢)

return 0.25 *. val;

slide-29
SLIDE 29

Verification Condition Checking Insight

Computing full joint distributions is intractable and input distribution dependent 𝑦′1, … , 𝑦′𝑛 ⊆ 𝑦1, … , 𝑦𝑜 → 𝑆 𝑦1, … , 𝑦𝑜 ≤ 𝑆( 𝑦′1, … , 𝑦′𝑛 )

𝑗

𝑠𝑗 ∗ 𝑆 {𝑦𝑗1, … , 𝑦𝑗𝑜} ≤ 𝑠′𝑗 ∗ 𝑆 {𝑦′𝑗1, … , 𝑦′𝑗𝑛}

slide-30
SLIDE 30

Conjunct Checking

  • A conjunct is implied by a pair of constraints
  • Decidable, efficiently checkable, and input

distribution agnostic

𝑠

1 ≤ 𝑠2

𝑠

1 ∗ 𝑆 𝑦1, … , 𝑦𝑜

≤ 𝑠2 ∗ 𝑆 {𝑦′1, … , 𝑦′𝑛}

𝑦′1, … , 𝑦′𝑛 ⊆ {𝑦1, … , 𝑦𝑜}

slide-31
SLIDE 31

Verification Condition Checking for Approximate Bilinear Interpolation

.99 ≤ .999999 .99 ∗ 𝑆 src, i, j, dest ≤ .999999 ∗ 𝑆 src, i, j, dest src, i, j, dest ⊆ src, i, j, dest

Hardware Specification Data Dependences

slide-32
SLIDE 32

What about…programs? (conditionals, loops, and functions)

slide-33
SLIDE 33

Conditionals

if (y >. 0) x = x +. 1 x = 2 *. x +. 1

slide-34
SLIDE 34

ℓ = y >. 0

if (ℓ) x1 = x0 +. 1 x2 = 2 *. x0 +. 1

Conditionals

slide-35
SLIDE 35

Conditionals

ℓ = y >. 0

if (ℓ)

x = φ (ℓ, x1, x2)

x1 = x0 +. 1 x2 = 2 *. x0 +. 1

slide-36
SLIDE 36

Conditionals

ℓ = y >. 0

if (ℓ)

x = φ (ℓ, x1, x2)

x1 = x0 +. 1 x2 = 2 *. x0 +. 1

Spec ≤ R(x) Spec ≤ R(ℓ, x1) Spec ≤ R(ℓ, x2)

slide-37
SLIDE 37

Conditionals

ℓ = y >. 0

if (ℓ)

x = φ (ℓ, x1, x2)

x1 = x0 +. 1 x2 = 2 *. x0 +. 1

Spec ≤ R(x) Spec ≤ R(ℓ, x1) Spec ≤ op(+.)  R(ℓ, x0) Spec ≤ op(+.) 

  • p(*.)  R(ℓ, x0)

Spec ≤ R(ℓ, x2)

slide-38
SLIDE 38

Conditionals

ℓ = y >. 0

if (ℓ)

x = φ (ℓ, x1, x2)

x1 = x0 +. 1 x2 = 2 *. x0 +. 1

Spec ≤ R(x) Spec ≤ R(ℓ, x1)

Spec ≤ R(ℓ, x2) Spec ≤ op(+.)  R(ℓ, x0) Spec ≤ op(+.) 

  • p(*.)  R(ℓ, x0)
slide-39
SLIDE 39

Conditionals

ℓ = y >. 0

if (ℓ)

x = φ (ℓ, x1, x2)

x1 = x0 +. 1 x2 = 2 *. x0 +. 1

Spec ≤ R(x) Spec ≤ R(ℓ, x1)

Spec ≤ R(ℓ, x2) Spec ≤ op(+.)  R(ℓ, x0) Spec ≤ op(+.) 

  • p(*.)  R(ℓ, x0)

Spec ≤ op(+.)  op(>.)  R(x0, y) ⋀ Spec ≤ op(+.)  op(*.)  op(>.)  R(x0, y)

slide-40
SLIDE 40

Spec ≤ op(+.)  op(>.)  R(x0, y) ⋀ Spec ≤ op(+.)  op(*.)  op(>.)  R(x0, y)

Simplification

ℓ = y >. 0

if (ℓ)

x = φ (ℓ, x1, x2)

x1 = x0 +. 1 x2 = 2 *. x0 +. 1

Spec ≤ R(x) Spec ≤ R(ℓ, x1) Spec ≤ R(ℓ, x2)

Spec ≤ op(+.)  R(ℓ, x0) Spec ≤ op(+.) 

  • p(*.)  R(ℓ, x0)
slide-41
SLIDE 41

Simplification

ℓ = y >. 0

if (ℓ)

x = φ (ℓ, x1, x2)

x1 = x0 +. 1 x2 = 2 *. x0 +. 1

Spec ≤ R(x) Spec ≤ R(ℓ, x1) Spec ≤ R(ℓ, x2)

Spec ≤ op(+.)  R(ℓ, x0) Spec ≤ op(+.) 

  • p(*.)  R(ℓ, x0)

Spec ≤ op(+.)  op(>.)  R(x0, y) ⋀ Spec ≤ op(+.)  op(*.)  op(>.)  R(x0, y)

slide-42
SLIDE 42
  • Reliability of loop-carried, unreliably updated

variables decreases monotonically

  • Finitely Bounded Loops: bounded decrease
  • Unbounded loops: conservative result is 0

int sum = 0; for (int i = 0; i < n; i = i + 1) { sum = sum +. a[i]; }

Loops

R(sum) depends on n unreliable adds

slide-43
SLIDE 43

Functions

  • Verification is modular (assume/guarantee)
  • Recursion similar to loops: unreliably updated

variables naturally have 0 reliability

int<𝑠

𝑔 ∗ 𝑆 x > f(x);

𝑠

1 ∗ 𝑆 𝑌 ≤ 𝑠 2 ∗ 𝑠 𝑔 ∗ 𝑆(𝑍 ∖ {y} ∪ x )

y = f(x); 𝑠

1 ∗ 𝑆 𝑌 ≤ 𝑠 2 ∗ 𝑆(𝑍)

slide-44
SLIDE 44

Rely: a Language for Quantitative Reliability

20% 40% 60% 80% 99% 99.9% 90% Reliability

Hardware Specification (Architect) Software Specification (Developer) Static Analysis (Language)

slide-45
SLIDE 45

Evaluation

  • Experiment #1: verify specifications
  • How does the analysis behave?
slide-46
SLIDE 46

Benchmarks

  • newton: zero-finding using Newton’s method
  • secant: zero-finding using Secant Method
  • coord: Cartesian to polar coordinate converter
  • search_ref: motion estimation
  • mat_vec: matrix-vector multiply
  • hadamard: frequency-domain pixel-block

difference metric

slide-47
SLIDE 47

Experiment #1: Results

Observation: small number of conjuncts with simplification

Benchmark LOC Time (ms) Conjuncts w/o with newton 21 8 82 1 secant 30 7 16356 2 coord 36 19 20 1 search_ref 37 348 36205 3 matvec 32 110 1061 4 hadamard 87 18 3 3

slide-48
SLIDE 48

Evaluation

  • Experiment #2: application scenarios
  • How to use reliabilities?
slide-49
SLIDE 49

Checkable Computations

  • A simple checker can validate whether the

program produced a correct result

  • Execution time optimization:

T𝑠𝑓𝑚𝑗𝑏𝑐𝑚𝑓 vs. T𝑣𝑜𝑠𝑓𝑚𝑗𝑏𝑐𝑚𝑓 + T𝑑ℎ𝑓𝑑𝑙𝑓𝑠 + 1 − 𝐬 ⋅ T𝑠𝑓𝑚𝑗𝑏𝑐𝑚𝑓

slide-50
SLIDE 50

Approximate Computations

10 20 30 40 50 60 70

2 4 6 8 10

High Quality

Bilinear Interpolation Reliability (as Negative Log Failure Probability) Quality

Target Reliability

slide-51
SLIDE 51

Other Concerns for Unreliable Hardware

Safety: does the program always produce a result?

– no failures or ill-defined behaviors

[Misailovic et al. ICSE ’10; Carbin et al. ISSTA ’10; Sidiroglou et al. FSE’11; Carbin et al., PLDI ’12; Carbin et al., PEPM ’13]

Accuracy: is result accurate enough?

– small expected error

[Rinard ICS’06; Misailovic et al.,ICSE ’10; Hofffmann at al. ASPLOS ’11; Misailovic et al. SAS ’11; Sidiroglou et al. FSE’11; Zhu et al. POPL ’12; Misailovic et al. RACES ‘12]

slide-52
SLIDE 52

Takeaway

  • Separating approximate computation isn’t enough
  • Acceptability of results depends on reliability

Rely

  • Architect provides hardware specification
  • Developer provides software specification
  • Rely provides verified reliability guarantee
slide-53
SLIDE 53

Backup Slides

slide-54
SLIDE 54
  • Execution of e is a

stochastic process

  • Independent probability of

failure for each operation

  • Reliability is probability
  • f fully reliable path

Semantic Model

𝑞1 𝑞2 1 − 𝑞1 1 − 𝑞2 𝑞2 1 − 𝑞2

slide-55
SLIDE 55

Semantic Formalization

  • Probabilistic transition system

𝑡, 𝜏 →

𝑞 𝑡′, 𝜏′

  • Set of possible executions on unreliable

hardware gives distributions of states 𝜚 ∈ Σ → ℝ 𝑡, 𝜚 ⇒ 𝜚

  • Predicates defined over distributions

𝑄 ∈ ℘(Φ)

See paper for inference rules!

slide-56
SLIDE 56

Identifying Reliably Update Variabes

  • Reliably updated vs. unreliably updated variables
  • Dependence graph gives classification
  • Reliably updated variables have same reliability

int sum = 0; for (int i = 0; i < n; i = i + 1) { sum = sum +. a[i]; }

i sum a n