Optimizing DNN Computation with Relaxed Graph Substitutions Tim - - PowerPoint PPT Presentation

optimizing dnn computation with relaxed graph
SMART_READER_LITE
LIVE PREVIEW

Optimizing DNN Computation with Relaxed Graph Substitutions Tim - - PowerPoint PPT Presentation

Optimizing DNN Computation with Relaxed Graph Substitutions Tim Lazarus 26 November, 2019 Graph Substitutions We can optimise DNNs if we replace subgraphs with equivalent ones that improve overall performance For a particular input I ,


slide-1
SLIDE 1

Optimizing DNN Computation with Relaxed Graph Substitutions

Tim Lazarus 26 November, 2019

slide-2
SLIDE 2

Graph Substitutions

We can optimise DNNs if we replace subgraphs with equivalent

  • nes that improve overall performance

For a particular input I, computation graph G will produce output O, or written as O = G(I) We then say that two graphs, G and G0 are equivalent if they produce the same output for every input. (∀I : G(I) = G0(I))

slide-3
SLIDE 3

Relaxed Graph Substitutions

This is a local form of optimisation and may not result in optimal results. Previous work with graph substitutions employed a greedy approach. As with most modern optimising compilers, sometimes further

  • ptimisations can be gained if we decrease performance in

intermediate steps.

slide-4
SLIDE 4

Example

Figure: Example relaxed graph substitution optimisation

slide-5
SLIDE 5

Defining substitutions

Essentially a mapping between a source graph and target graph. Source graph defines constraints on a subgraph. Target graph uses those constraints to create the substituted subgraph. We need the substitution to be valid

slide-6
SLIDE 6

Example

Figure: Example substitution definition

slide-7
SLIDE 7

Cost Model

We need to estimate the cost of each substitution. Cost model incorporates many metrics. Can also accurately estimate dynamic execution too

slide-8
SLIDE 8

Searching the Space

Use a priority queue to search most optimal graph first and backtrack if necessary. The space can be huge if we consider all possible substitutions. Use a parameter α that determines the trade-off between search time and space explored. (See next slide)

slide-9
SLIDE 9

Search Algorithm

Algorithm 1: A Backtracking Search Algorithm

Input: An initial computation graph G0, a cost model Cost(·), a list of valid graph substitutions {S1, ..., Sm}, and a hyper parameter α Output: An optimised computation graph. // Q is a priority queue of graphs sorted by Cost(·) Q = {G0} while Q 6= {} do G = Q.dequeue() for i = 1 to m do G0 = Si(G) if Cost(G0) < Cost(Gopt) then Gopt = G0 end if Cost(G0) < α ⇥Cost(Gopt) then Q.enqueue(G0) end end end return Gopt

slide-10
SLIDE 10

Graph Splitting

Split the graph into smaller subgraphs so the search is more manageable. For each node v, we define the Cap(v) as the number of substitutions that map to an in or out edge of v. We can then minimise the number of substitutions that span across a split as the problem maps to a minimum vertex cut problem. Can perform a local search around splits to find further potential

  • ptimisations.
slide-11
SLIDE 11

Evaluation

Figure: Compared with TensorFlow, TensorRT and TensorFlow XLA

slide-12
SLIDE 12

Evaluation

Figure: Comparison of different cost metrics

slide-13
SLIDE 13

Evaluation

Figure: Evaluation of varying values of α

slide-14
SLIDE 14

Criticism

Strengths I Well defined problem I System is open-source I Good testing of system I Can be used on top of

  • ther optimisations
slide-15
SLIDE 15

Criticism

Strengths I Well defined problem I System is open-source I Good testing of system I Can be used on top of

  • ther optimisations

Weaknesses I Paper lacked implementation detail I Poor analysis of results

slide-16
SLIDE 16

Extensions

Can be used with existing optimisations like TVM or FlexFlow (as we saw last week) There’s a new paper in town...

slide-17
SLIDE 17

TASO

Extends this paper by automatically generating possible graph substitutions. For a given set of operators, it enumerates all possible subgraphs up to a fixed size. It then finds equivalent subgraphs through formal verification.

slide-18
SLIDE 18

Questions?