Optimizing Synthesis f a i c t t r A C o m p * * l e - - PowerPoint PPT Presentation

optimizing synthesis
SMART_READER_LITE
LIVE PREVIEW

Optimizing Synthesis f a i c t t r A C o m p * * l e - - PowerPoint PPT Presentation

Optimizing Synthesis f a i c t t r A C o m p * * l e t t n e e * A t * s i W s E n e L o l l C C P D * o O * e c s u P u m e E e R n with Metasketches * o t e v t d y s a E * a d


slide-1
SLIDE 1

Optimizing Synthesis with Metasketches

James Bornholt Emina Torlak Dan Grossman Luis Ceze

C
  • n
s i s t e n t * C
  • m
p l e t e * W e l l D
  • c
u m e n t e d * E a s y t
  • R
e u s e *

*

E v a l u a t e d

* P O P L *

A r t i f a c t

* A E C

University of Washington

SYNAPSE

slide-2
SLIDE 2

Program synthesis

slide-3
SLIDE 3

Specification

Program synthesis

slide-4
SLIDE 4

Program Specification

Program synthesis

slide-5
SLIDE 5

Program Specification

Program synthesis

f(x) = 4x

slide-6
SLIDE 6

Program Specification

Program synthesis

x+x+x+x f(x) = 4x

slide-7
SLIDE 7

Program Specification

Program synthesis

x+x+x+x f(x) = 4x

C

  • m

p i l a t i

  • n

[PLDI’14]

Browser Layout

[ P P

  • P

P ’ 1 3 ]

Executable Biology

[POPL’13]

End-user Programming

[POPL’11]

Cache Protocols

[PLDI’13]

Data Structures

[PLDI’15]

slide-8
SLIDE 8

Program Specification

Program synthesis

Ofuen looking for an

  • ptimal solution, not just

any correct program

C

  • m

p i l a t i

  • n

[PLDI’14]

Browser Layout

[ P P

  • P

P ’ 1 3 ]

Executable Biology

[POPL’13]

End-user Programming

[POPL’11]

Cache Protocols

[PLDI’13]

Data Structures

[PLDI’15]

slide-9
SLIDE 9

Program Specification

Program synthesis

Ofuen looking for an

  • ptimal solution, not just

any correct program There are many programs, so tools must control search strategy

C

  • m

p i l a t i

  • n

[PLDI’14]

Browser Layout

[ P P

  • P

P ’ 1 3 ]

Executable Biology

[POPL’13]

End-user Programming

[POPL’11]

Cache Protocols

[PLDI’13]

Data Structures

[PLDI’15]

slide-10
SLIDE 10

Program Specification

Program synthesis

Ofuen looking for an

  • ptimal solution, not just

any correct program There are many programs, so tools must control search strategy

C

  • m

p i l a t i

  • n

[PLDI’14]

Browser Layout

[ P P

  • P

P ’ 1 3 ]

Executable Biology

[POPL’13]

End-user Programming

[POPL’11]

Cache Protocols

[PLDI’13]

Data Structures

[PLDI’15]

slide-11
SLIDE 11

Program Specification

Program synthesis

slide-12
SLIDE 12

Program Specification

Program synthesis

Metasketches

slide-13
SLIDE 13

Program Specification

Program synthesis

Metasketches

A framework that makes search strategy and optimality part of the problem definition

slide-14
SLIDE 14

Metasketches

Design and structure

slide-15
SLIDE 15

Metasketches

Design and structure

Synapse

A metasketch solver

slide-16
SLIDE 16

Metasketches

Design and structure

Results

Better solutions, faster

Synapse

A metasketch solver

slide-17
SLIDE 17

Metasketches

Design and structure

Results

Better solutions, faster

Synapse

A metasketch solver

Background

Syntax-guided synthesis

slide-18
SLIDE 18

Syntax-guided synthesis

Program Specification

Program synthesis

slide-19
SLIDE 19

Syntax-guided synthesis

Program Specification

Program synthesis

Sketch

slide-20
SLIDE 20

Syntax-guided synthesis

Program Specification

Program synthesis

Sketch

def f(x): return Expr Expr := x | ?? | Expr op Expr

  • p := + | * | - | >> | <<

?? := integer constant

slide-21
SLIDE 21

Syntax-guided synthesis: guess, check, learn

def f(x): return Expr Expr := x | ?? | Expr op Expr

  • p := + | * | - | >> | <<

?? := integer constant

slide-22
SLIDE 22

Syntax-guided synthesis: guess, check, learn

def f(x): return Expr Expr := x | ?? | Expr op Expr

  • p := + | * | - | >> | <<

?? := integer constant

Syntax

slide-23
SLIDE 23

Syntax-guided synthesis: guess, check, learn

Semantics Syntax

Counterexample-guided inductive synthesis [Solar-Lezama et al, 2006]

slide-24
SLIDE 24

Syntax-guided synthesis: guess, check, learn

Semantics Syntax

f(x) = 4x

Counterexample-guided inductive synthesis [Solar-Lezama et al, 2006]

slide-25
SLIDE 25

Syntax-guided synthesis: guess, check, learn

Semantics Syntax

f(x) = 4x

Counterexample-guided inductive synthesis [Solar-Lezama et al, 2006]

slide-26
SLIDE 26

Syntax-guided synthesis: guess, check, learn

Semantics Syntax

f(x) = 4x

Counterexample-guided inductive synthesis [Solar-Lezama et al, 2006]

slide-27
SLIDE 27

Syntax-guided synthesis: guess, check, learn

Semantics Syntax

f(x) = 4x

Counterexample-guided inductive synthesis [Solar-Lezama et al, 2006]

slide-28
SLIDE 28

Syntax-guided synthesis: guess, check, learn

Semantics Syntax

f(x) = 4x

Counterexample-guided inductive synthesis [Solar-Lezama et al, 2006]

slide-29
SLIDE 29

Syntax-guided synthesis: guess, check, learn

Semantics Syntax

f(x) = 4x x+x+x+x

Counterexample-guided inductive synthesis [Solar-Lezama et al, 2006]

slide-30
SLIDE 30

Syntax-guided synthesis: guess, check, learn

Syntax

  • 1. Search order is critical

x+x+x+x

Counterexample-guided inductive synthesis [Solar-Lezama et al, 2006]

slide-31
SLIDE 31

Syntax-guided synthesis: guess, check, learn

Syntax

  • 1. Search order is critical
  • 2. Desire optimal solutions

x+x+x+x

Counterexample-guided inductive synthesis [Solar-Lezama et al, 2006]

slide-32
SLIDE 32

Syntax-guided synthesis: guess, check, learn

Syntax

  • 1. Search order is critical
  • 2. Desire optimal solutions

x+x+x+x x << 2

Counterexample-guided inductive synthesis [Solar-Lezama et al, 2006]

slide-33
SLIDE 33

Metasketches

Design and structure

Results

Better solutions, faster

Synapse

A metasketch solver

Background

Syntax-guided synthesis

slide-34
SLIDE 34

Metasketches

Design and structure

Results

Better solutions, faster

Synapse

A metasketch solver

Background

Syntax-guided synthesis

slide-35
SLIDE 35

Metasketches express structure and strategy

Syntax

  • 1. Search order is critical
  • 2. Desire optimal solutions
slide-36
SLIDE 36

Metasketches express structure and strategy

Syntax

S1 S2 S3 S4 S6 S5 S7

  • 1. Search order is critical
  • 2. Desire optimal solutions
  • 1. structured candidate space (𝓣, ≼)

A metasketch contains:

slide-37
SLIDE 37

Metasketches express structure and strategy

Syntax

S1 S2 S3 S4 S6 S5 S7

  • 1. Search order is critical
  • 2. Desire optimal solutions
  • 1. structured candidate space (𝓣, ≼)
  • 2. cost function (κ)𝓣

A metasketch contains:

slide-38
SLIDE 38

Metasketches express structure and strategy

Syntax

S1 S2 S3 S4 S6 S5 S7

  • 1. Search order is critical
  • 2. Desire optimal solutions
  • 1. structured candidate space (𝓣, ≼)
  • 2. cost function (κ)𝓣
  • 3. gradient function (g)𝓣

A metasketch contains:

slide-39
SLIDE 39

Syntax

S1 S2 S3 S4 S6 S5 S7

Metasketches express structure and strategy

  • 1. structured candidate space (𝓣, ≼)
  • 2. cost function (κ)𝓣
  • 3. gradient function (g)𝓣

A metasketch contains:

  • 1. Search order is critical
  • 2. Desire optimal solutions
slide-40
SLIDE 40

Syntax

S1 S2 S3 S4 S6 S5 S7

Metasketches express structure and strategy

  • 1. structured candidate space (𝓣, ≼)
  • 2. cost function (κ)𝓣
  • 3. gradient function (g)𝓣

A metasketch contains:

  • 1. Search order is critical
  • 2. Desire optimal solutions
slide-41
SLIDE 41

Syntax

S1 S2 S3 S4 S6 S5 S7

Metasketches express structure and strategy

Program

  • 1. structured candidate space (𝓣, ≼)
  • 2. cost function (κ)𝓣
  • 3. gradient function (g)𝓣

A metasketch contains:

  • 1. Search order is critical
  • 2. Desire optimal solutions
slide-42
SLIDE 42

Syntax

S1 S2 S3 S4 S6 S5 S7

Metasketches express structure and strategy

Program

Superoptimizer

  • 1. structured candidate space (𝓣, ≼)
  • 2. cost function (κ)𝓣
  • 3. gradient function (g)𝓣

A metasketch contains:

  • 1. Search order is critical
  • 2. Desire optimal solutions
slide-43
SLIDE 43

Syntax

S1 S2 S3 S4 S6 S5 S7

Metasketches express structure and strategy

Program Optimal Program

Superoptimizer

  • 1. structured candidate space (𝓣, ≼)
  • 2. cost function (κ)𝓣
  • 3. gradient function (g)𝓣

A metasketch contains:

  • 1. Search order is critical
  • 2. Desire optimal solutions
slide-44
SLIDE 44

Metasketches express structure and strategy

  • 1. structured candidate space (𝓣, ≼)
  • 2. cost function (κ)𝓣
  • 3. gradient function (g)𝓣
slide-45
SLIDE 45

Metasketches express structure and strategy

  • 1. structured candidate space (𝓣, ≼)
  • 2. cost function (κ)𝓣
  • 3. gradient function (g)𝓣

A fragmentation of the candidate space, and an ordering on those fragments.

slide-46
SLIDE 46

Metasketches express structure and strategy

  • 1. structured candidate space (𝓣, ≼)
  • 2. cost function (κ)𝓣
  • 3. gradient function (g)𝓣

def S 𝓣 = set of all SSA programs

A fragmentation of the candidate space, and an ordering on those fragments.

slide-47
SLIDE 47

Metasketches express structure and strategy

  • 1. structured candidate space (𝓣, ≼)
  • 2. cost function (κ)𝓣
  • 3. gradient function (g)𝓣

def S

S1 S2 S3 S4 S5 …

𝓣 = set of all SSA programs

A fragmentation of the candidate space, and an ordering on those fragments.

slide-48
SLIDE 48

Metasketches express structure and strategy

  • 1. structured candidate space (𝓣, ≼)
  • 2. cost function (κ)𝓣
  • 3. gradient function (g)𝓣

def S

S1 S2 S3 S4 S5 …

𝓣 = set of all SSA programs

  • a countable set 𝓣 of sketches
  • a total order ≼ on 𝓣

A fragmentation of the candidate space, and an ordering on those fragments.

slide-49
SLIDE 49

Metasketches express structure and strategy

  • 1. structured candidate space (𝓣, ≼)
  • 2. cost function (κ)𝓣
  • 3. gradient function (g)𝓣
  • a countable set 𝓣 of sketches
  • a total order ≼ on 𝓣

def f(x): r1 = ??op(??{x}) r2 = ??op(??{x,r1}) r3 = ??op(??{x,r1,r2}) return r3 S3 (SSA programs of length 3)

S1 S2 S3 S4 S5 …

𝓣 = set of all SSA programs

A fragmentation of the candidate space, and an ordering on those fragments.

slide-50
SLIDE 50

Metasketches express structure and strategy

  • 1. structured candidate space (𝓣, ≼)
  • 2. cost function (κ)𝓣
  • 3. gradient function (g)𝓣
  • a countable set 𝓣 of sketches
  • a total order ≼ on 𝓣

def f(x): r1 = ??op(??{x}) r2 = ??op(??{x,r1}) r3 = ??op(??{x,r1,r2}) return r3 S3 (SSA programs of length 3)

S1 S2 S3 S4 S5 …

𝓣 = set of all SSA programs

+, -, <, if, …

A fragmentation of the candidate space, and an ordering on those fragments.

slide-51
SLIDE 51

Metasketches express structure and strategy

  • 1. structured candidate space (𝓣, ≼)
  • 2. cost function (κ)𝓣
  • 3. gradient function (g)𝓣
  • a countable set 𝓣 of sketches
  • a total order ≼ on 𝓣

def f(x): r1 = ??op(??{x}) r2 = ??op(??{x,r1}) r3 = ??op(??{x,r1,r2}) return r3 S3 (SSA programs of length 3)

S1 S2 S3 S4 S5 …

𝓣 = set of all SSA programs

+, -, <, if, … Vars & constants

A fragmentation of the candidate space, and an ordering on those fragments.

slide-52
SLIDE 52

Metasketches express structure and strategy

  • 1. structured candidate space (𝓣, ≼)
  • 2. cost function (κ)𝓣
  • 3. gradient function (g)𝓣
  • a countable set 𝓣 of sketches
  • a total order ≼ on 𝓣

S1 S2 S3 S4 S5 …

𝓣 = set of all SSA programs def f(x): r1 = ??op(??{x}) r2 = ??op(??{x,r1}) r3 = ??op(??{x,r1,r2}) return r3 S3 (SSA programs of length 3)

A fragmentation of the candidate space, and an ordering on those fragments.

slide-53
SLIDE 53

Metasketches express structure and strategy

  • 1. structured candidate space (𝓣, ≼)
  • 2. cost function (κ)𝓣
  • 3. gradient function (g)𝓣
  • a countable set 𝓣 of sketches
  • a total order ≼ on 𝓣

S1 S2 S3 S4 S5 …

𝓣 = set of all SSA programs def f(x): r1 = ??op(??{x}) r2 = ??op(??{x,r1}) r3 = ??op(??{x,r1,r2}) return r3 S3 (SSA programs of length 3)

Ordering expresses high-level search strategy. A fragmentation of the candidate space, and an ordering on those fragments.

slide-54
SLIDE 54

Metasketches express structure and strategy

  • 1. structured candidate space (𝓣, ≼)
  • 2. cost function (κ)𝓣
  • 3. gradient function (g)𝓣
  • a countable set 𝓣 of sketches
  • a total order ≼ on 𝓣

S1 S2 S3 S4 S5 …

𝓣 = set of all SSA programs def f(x): r1 = ??op(??{x}) r2 = ??op(??{x,r1}) r3 = ??op(??{x,r1,r2}) return r3 S3 (SSA programs of length 3)

≼ ≼ ≼ ≼ ≼

Ordering expresses high-level search strategy. Here, ≼ expresses iterative deepening. A fragmentation of the candidate space, and an ordering on those fragments.

slide-55
SLIDE 55

Metasketches express structure and strategy

  • 1. structured candidate space (𝓣, ≼)
  • 2. cost function (κ)𝓣
  • 3. gradient function (g)𝓣
  • a countable set 𝓣 of sketches
  • a total order ≼ on 𝓣

𝓣 = set of all SSA programs

A fragmentation of the candidate space, and an ordering on those fragments. def f(x): r1 = ??op(??{x}) r2 = ??op(??{x,r1}) r3 = ??op(??{x,r1,r2}) return r3

S3

def f(x): r1 = ??op(??{x}) r2 = ??op(??{x,r1}) return r2

S2

def f(x): r1 = ??op(??{x}) return r1

S1

Implemented as a generator that returns the next sketch in the space

slide-56
SLIDE 56

Metasketches express structure and strategy

  • 1. structured candidate space (𝓣, ≼)
  • 2. cost function (κ)𝓣
  • 3. gradient function (g)𝓣
  • a countable set 𝓣 of sketches
  • a total order ≼ on 𝓣

𝓣 = set of all SSA programs Semantics

S1 S4 S5 … S2 S3

slide-57
SLIDE 57

Metasketches express structure and strategy

  • 1. structured candidate space (𝓣, ≼)
  • 2. cost function (κ)𝓣
  • 3. gradient function (g)𝓣
  • a countable set 𝓣 of sketches
  • a total order ≼ on 𝓣

𝓣 = set of all SSA programs Semantics

⟦S3⟧ S1 S4 S5 … S2 S3

slide-58
SLIDE 58

Metasketches express structure and strategy

  • 1. structured candidate space (𝓣, ≼)
  • 2. cost function (κ)𝓣
  • 3. gradient function (g)𝓣
  • a countable set 𝓣 of sketches
  • a total order ≼ on 𝓣

𝓣 = set of all SSA programs Semantics

⟦S2⟧ ⟦S3⟧ S1 S4 S5 … S2 S3

slide-59
SLIDE 59

Metasketches express structure and strategy

  • 1. structured candidate space (𝓣, ≼)
  • 2. cost function (κ)𝓣
  • 3. gradient function (g)𝓣
  • a countable set 𝓣 of sketches
  • a total order ≼ on 𝓣

𝓣 = set of all SSA programs Semantics

⟦S2⟧ ⟦S3⟧

Semantic redundancy in the search space.

S1 S4 S5 … S2 S3

slide-60
SLIDE 60

Metasketches express structure and strategy

  • 1. structured candidate space (𝓣, ≼)
  • 2. cost function (κ)𝓣
  • 3. gradient function (g)𝓣
  • a countable set 𝓣 of sketches
  • a total order ≼ on 𝓣

𝓣 = set of all SSA programs Semantics

⟦S2⟧ ⟦S3⟧

Semantic redundancy in the search space.

S1 S4 S5 … S2 S3

Structure constraints eliminate some overlap between sketches

slide-61
SLIDE 61

Metasketches express structure and strategy

  • 1. structured candidate space (𝓣, ≼)
  • 2. cost function (κ)𝓣
  • 3. gradient function (g)𝓣
  • a countable set 𝓣 of sketches
  • a total order ≼ on 𝓣

𝓣 = set of all SSA programs Semantics

⟦S2⟧ ⟦S3⟧

Semantic redundancy in the search space.

S1 S4 S5 … S2 S3

Structure constraints eliminate some overlap between sketches

def f(x): r1 = ??op(??{x}) r2 = ??op(??{x,r1}) r3 = ??op(??{x,r1,r2}) return r3 S3 (SSA programs of length 3)

slide-62
SLIDE 62

Metasketches express structure and strategy

  • 1. structured candidate space (𝓣, ≼)
  • 2. cost function (κ)𝓣
  • 3. gradient function (g)𝓣
  • a countable set 𝓣 of sketches
  • a total order ≼ on 𝓣

𝓣 = set of all SSA programs Semantics

⟦S2⟧ ⟦S3⟧

Semantic redundancy in the search space.

S1 S4 S5 … S2 S3

Structure constraints eliminate some overlap between sketches Eliminate dead-code redundancy: assert that each ri is read

def f(x): r1 = ??op(??{x}) r2 = ??op(??{x,r1}) r3 = ??op(??{x,r1,r2}) return r3 S3 (SSA programs of length 3)

slide-63
SLIDE 63

Cost functions rank candidate programs

  • 1. structured candidate space (𝓣, ≼)
  • 2. cost function (κ)𝓣
  • 3. gradient function (g)𝓣

𝓣 = set of all SSA programs

S1 S4 S5 … S2 S3

κ : 𝓜 → ℝ assigns a numeric cost to each program in the language 𝓜

≼ ≼ ≼ ≼ ≼

slide-64
SLIDE 64

Cost functions rank candidate programs

  • 1. structured candidate space (𝓣, ≼)
  • 2. cost function (κ)𝓣
  • 3. gradient function (g)𝓣

𝓣 = set of all SSA programs

S1 S4 S5 … S2 S3

κ : 𝓜 → ℝ assigns a numeric cost to each program in the language 𝓜

Cost functions can be based

  • n both syntax and semantics

(dynamic behavior)

≼ ≼ ≼ ≼ ≼

slide-65
SLIDE 65

Cost functions rank candidate programs

  • 1. structured candidate space (𝓣, ≼)
  • 2. cost function (κ)𝓣
  • 3. gradient function (g)𝓣

𝓣 = set of all SSA programs

S1 S4 S5 … S2 S3

κ : 𝓜 → ℝ assigns a numeric cost to each program in the language 𝓜 κ(P) = i for P ∈ Si ∈ 𝓣

The number of variables defined in P

≼ ≼ ≼ ≼ ≼

Cost functions can be based

  • n both syntax and semantics

(dynamic behavior)

slide-66
SLIDE 66

Gradient functions provide cost structure

  • 1. structured candidate space (𝓣, ≼)
  • 2. cost function (κ)𝓣
  • 3. gradient function (g)𝓣

𝓣 = set of all SSA programs

S1 S4 S5 … S2 S3

κ(P) = i for P ∈ Si ∈ 𝓣 g : ℝ → 2𝓣 g(c) is the set of sketches in 𝓣 that may contain a solution P with κ(P) < c

≼ ≼ ≼ ≼ ≼

slide-67
SLIDE 67

Gradient functions provide cost structure

  • 1. structured candidate space (𝓣, ≼)
  • 2. cost function (κ)𝓣
  • 3. gradient function (g)𝓣

𝓣 = set of all SSA programs

S1 S4 S5 … S2 S3

κ(P) = i for P ∈ Si ∈ 𝓣 g : ℝ → 2𝓣 g(c) is the set of sketches in 𝓣 that may contain a solution P with κ(P) < c

The gradient function

  • verapproximates the

behavior of κ on 𝓣

≼ ≼ ≼ ≼ ≼

slide-68
SLIDE 68

Gradient functions provide cost structure

  • 1. structured candidate space (𝓣, ≼)
  • 2. cost function (κ)𝓣
  • 3. gradient function (g)𝓣

𝓣 = set of all SSA programs

S1 S4 S5 … S2 S3

κ(P) = i for P ∈ Si ∈ 𝓣 g : ℝ → 2𝓣 g(c) is the set of sketches in 𝓣 that may contain a solution P with κ(P) < c

The gradient function

  • verapproximates the

behavior of κ on 𝓣

g(c) = { Si ∈ 𝓣 | i < c }

≼ ≼ ≼ ≼ ≼

slide-69
SLIDE 69

Gradient functions provide cost structure

  • 1. structured candidate space (𝓣, ≼)
  • 2. cost function (κ)𝓣
  • 3. gradient function (g)𝓣

𝓣 = set of all SSA programs

S1 S4 S5 … S2 S3

κ(P) = i for P ∈ Si ∈ 𝓣 g : ℝ → 2𝓣 g(c) is the set of sketches in 𝓣 that may contain a solution P with κ(P) < c

The gradient function

  • verapproximates the

behavior of κ on 𝓣

g(c) = { Si ∈ 𝓣 | i < c }

g(4) = {S1, S2, S3}

≼ ≼ ≼ ≼ ≼

slide-70
SLIDE 70

Gradient functions provide cost structure

  • 1. structured candidate space (𝓣, ≼)
  • 2. cost function (κ)𝓣
  • 3. gradient function (g)𝓣

𝓣 = set of all SSA programs

S1 S4 S5 … S2 S3

κ(P) = i for P ∈ Si ∈ 𝓣 g : ℝ → 2𝓣 g(c) is the set of sketches in 𝓣 that may contain a solution P with κ(P) < c

The gradient function

  • verapproximates the

behavior of κ on 𝓣

g(c) = { Si ∈ 𝓣 | i < c }

g(4) = {S1, S2, S3}

≼ ≼ ≼ ≼ ≼

Always sound for g to return all of 𝓣 if a tighter bound is unavailable.

slide-71
SLIDE 71

Gradient functions provide cost structure

  • 1. structured candidate space (𝓣, ≼)
  • 2. cost function (κ)𝓣
  • 3. gradient function (g)𝓣

𝓣 = set of all SSA programs

S1 S4 S5 … S2 S3

κ(P) = i for P ∈ Si ∈ 𝓣 g : ℝ → 2𝓣 g(c) is the set of sketches in 𝓣 that may contain a solution P with κ(P) < c

The gradient function

  • verapproximates the

behavior of κ on 𝓣

g(c) = { Si ∈ 𝓣 | i < c }

g(4) = {S1, S2, S3}

≼ ≼ ≼ ≼ ≼

Always sound for g to return all of 𝓣 if a tighter bound is unavailable. g(c) always being finite is sufficient (not necessary) to guarantee termination.

slide-72
SLIDE 72
  • 1. structured candidate space (𝓣, ≼)
  • 2. cost function (κ)𝓣
  • 3. gradient function (g)𝓣

Metasketches

Design and structure

𝓣 = set of all SSA programs

S1 S4 S5 … S2 S3

κ(P) = i for P ∈ Si ∈ 𝓣

≼ ≼ ≼ ≼ ≼

g(c) = { Si ∈ 𝓣 | i < c }

slide-73
SLIDE 73

Metasketches

Design and structure

Results

Better solutions, faster

Synapse

A metasketch solver

Background

Syntax-guided synthesis

slide-74
SLIDE 74

Metasketches

Design and structure

Results

Better solutions, faster

Synapse

A metasketch solver

Background

Syntax-guided synthesis

slide-75
SLIDE 75

Solving with two cooperative searches

Global search Local search Local search Local search

⟨𝓣, ≼, κ, g⟩ ...

Coordinates the search for an optimal solution,

  • ffloading work to parallel

local searches

slide-76
SLIDE 76

Solving with two cooperative searches

Global search Local search Local search Local search

⟨𝓣, ≼, κ, g⟩ ...

Coordinates the search for an optimal solution,

  • ffloading work to parallel

local searches An incremental form of CEGIS that can accept new information from the global search

slide-77
SLIDE 77

Solving with two cooperative searches

Global search Local search Local search

⟨𝓣, ≼, κ, g⟩

S1 S2 S3 S4 S6 S5 S7

Local search Local search

slide-78
SLIDE 78

Solving with two cooperative searches

Global search Local search Local search

⟨𝓣, ≼, κ, g⟩

S1 S2 S3 S4 S6 S5 S7

Local search Local search

slide-79
SLIDE 79

Solving with two cooperative searches

Global search Local search Local search

⟨𝓣, ≼, κ, g⟩

UNSAT

S1 S2 S3 S4 S6 S5 S7

Local search

S2

Local search

slide-80
SLIDE 80

Solving with two cooperative searches

Global search Local search Local search

⟨𝓣, ≼, κ, g⟩

UNSAT

S1 S2 S3 S4 S6 S5 S7

Local search

S2

Local search

slide-81
SLIDE 81

Solving with two cooperative searches

Global search Local search Local search

⟨𝓣, ≼, κ, g⟩

S1 S3 S4 S6 S5 S7

Local search Local search

slide-82
SLIDE 82

SAT (P)

Solving with two cooperative searches

Global search Local search Local search

⟨𝓣, ≼, κ, g⟩

S1 S3 S4 S6 S5 S7

Local search Local search

slide-83
SLIDE 83

SAT (P)

Solving with two cooperative searches

Global search Local search Local search

⟨𝓣, ≼, κ, g⟩

S1 S3 S4 S6 S5 S7

Local search Local search

slide-84
SLIDE 84

Solving with two cooperative searches

Global search Local search Local search

⟨𝓣, ≼, κ, g⟩

κ(P) κ(P)

S1 S3 S4 S6 S5 S7

Local search

κ(P)

Local search

slide-85
SLIDE 85

Solving with two cooperative searches

Global search Local search Local search

⟨𝓣, ≼, κ, g⟩

κ(P) κ(P)

S1 S3 S4 S6 S5 S7

Local search

κ(P)

Prune local search spaces using κ(P)

Local search

slide-86
SLIDE 86

S3

Solving with two cooperative searches

Global search Local search Local search

⟨𝓣, ≼, κ, g⟩

κ(P) κ(P)

S6 S5 S7

Local search

κ(P)

S1 S4 Prune local search spaces using κ(P)

Local search

slide-87
SLIDE 87

S3

Solving with two cooperative searches

Global search Local search Local search

⟨𝓣, ≼, κ, g⟩

κ(P) κ(P)

S6 S5 S7

Local search

κ(P)

S1 S4 Prune local search spaces using κ(P) Prune global search space using g(κ(P))

Local search

slide-88
SLIDE 88

S3

Solving with two cooperative searches

Global search Local search Local search

⟨𝓣, ≼, κ, g⟩

κ(P) κ(P)

S6 S5

Local search

κ(P)

S1 S4 Prune local search spaces using κ(P) Prune global search space using g(κ(P))

Local search

slide-89
SLIDE 89

S3

Solving with two cooperative searches

Global search Local search Local search

⟨𝓣, ≼, κ, g⟩

κ(P) κ(P)

S6 S5

Local search

κ(P)

S1 S4 Prune local search spaces using κ(P) Prune global search space using g(κ(P)) Continues until all search spaces exhausted, yielding an optimal solution.

Local search

slide-90
SLIDE 90

Synapse implementation

Implemented in Rosette, a solver-aided extension of Racket

Global search Local search Local search Local search

⟨𝓣, ≼, κ, g⟩ ...

slide-91
SLIDE 91

Synapse implementation

Implemented in Rosette, a solver-aided extension of Racket Local CEGIS searches can share counterexamples

Global search Local search Local search Local search

⟨𝓣, ≼, κ, g⟩ ...

slide-92
SLIDE 92

Synapse implementation

Implemented in Rosette, a solver-aided extension of Racket Local CEGIS searches can share counterexamples Local searches can time out, which weakens optimality

Global search Local search Local search Local search

⟨𝓣, ≼, κ, g⟩ ...

slide-93
SLIDE 93

Metasketches

Design and structure

Results

Better solutions, faster

Synapse

A metasketch solver

Background

Syntax-guided synthesis

slide-94
SLIDE 94

Metasketches

Design and structure

Results

Better solutions, faster

Synapse

A metasketch solver

Background

Syntax-guided synthesis

slide-95
SLIDE 95

Is Synapse a practical approach to solving different kinds of synthesis problems?

Approximate computing, array programs

Evaluation questions

slide-96
SLIDE 96

Is Synapse a practical approach to solving different kinds of synthesis problems?

Approximate computing, array programs

Can Synapse reason about complex cost functions?

Evaluation questions

slide-97
SLIDE 97

Is Synapse a practical approach to solving different kinds of synthesis problems?

Approximate computing, array programs

Can Synapse reason about complex cost functions? In the paper:

  • Parallel speedup
  • Optimizations (structure constraints, sharing)
  • More kinds of problems
  • More complex cost functions

Evaluation questions

slide-98
SLIDE 98

Synapse solves previously-intractable problems

Parrot benchmarks from approximate computing [Esmaelizadeh et al., 2012] Find the most efficient approximate program within an error bound

slide-99
SLIDE 99

Synapse solves previously-intractable problems

10 100 1000 10000

fft−cos fft−sin inversek2j−1 inversek2j−2 kmeans sobel−x sobel−y

Solving time (secs)

Parrot benchmarks from approximate computing [Esmaelizadeh et al., 2012] Find the most efficient approximate program within an error bound

slide-100
SLIDE 100

Synapse solves previously-intractable problems

10 100 1000 10000

fft−cos fft−sin inversek2j−1 inversek2j−2 kmeans sobel−x sobel−y

Solving time (secs)

Parrot benchmarks from approximate computing [Esmaelizadeh et al., 2012] Find the most efficient approximate program within an error bound

All intractable to Sketch and Stoke

slide-101
SLIDE 101

Synapse solves standard benchmarks optimally

Array Search benchmarks from the syntax-guided synthesis (SyGuS) 
 competition [Alur et al., 2015] arraysearch-n: find program that searches lists of length n

slide-102
SLIDE 102

Synapse solves standard benchmarks optimally

10 100 1000 10000

fft−cos fft−sin inversek2j−1 inversek2j−2 kmeans sobel−x sobel−y

Solving time (secs)

arraysearch−2 arraysearch−3 arraysearch−4 arraysearch−5 arraysearch−6 arraysearch−7 arraysearch−8 arraysearch−9 arraysearch−10 arraysearch−11 arraysearch−12 arraysearch−13 arraysearch−14 arraysearch−15

Array Search benchmarks from the syntax-guided synthesis (SyGuS) 
 competition [Alur et al., 2015] arraysearch-n: find program that searches lists of length n

slide-103
SLIDE 103

Synapse solves standard benchmarks optimally

10 100 1000 10000

fft−cos fft−sin inversek2j−1 inversek2j−2 kmeans sobel−x sobel−y

Solving time (secs)

arraysearch−2 arraysearch−3 arraysearch−4 arraysearch−5 arraysearch−6 arraysearch−7 arraysearch−8 arraysearch−9 arraysearch−10 arraysearch−11 arraysearch−12 arraysearch−13 arraysearch−14 arraysearch−15

Synapse: 349 bytes SyGuS: 7.1 MB

Array Search benchmarks from the syntax-guided synthesis (SyGuS) 
 competition [Alur et al., 2015] arraysearch-n: find program that searches lists of length n

slide-104
SLIDE 104

Is this a cat?

slide-105
SLIDE 105

Synapse reasons about complex costs

?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ??

slide-106
SLIDE 106

Synapse reasons about complex costs

?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ??

κ(P) =

X

i

|P(xi) − yi|

Classification error executes the program for each point in the training set

slide-107
SLIDE 107

Metasketches

Design and structure

Results

Better solutions, faster

Synapse

A metasketch solver

slide-108
SLIDE 108

Metasketches

Design and structure

Results

Better solutions, faster

Synapse

A metasketch solver

synapse.uwplse.org