an opencl implementation of a forward sampling algorithm
play

An OpenCL implementation of a forward sampling algorithm for - PowerPoint PPT Presentation

An OpenCL implementation of a forward sampling algorithm for CP-logic Wiebe Van Ranst Joost Vennekens KU Leuven Campus De Nayer CP-logic PLP language in family of distribution semantics languages PRISM [Sato,Kameya], Independent


  1. An OpenCL implementation of a forward sampling algorithm for CP-logic Wiebe Van Ranst Joost Vennekens � KU Leuven Campus De Nayer

  2. CP-logic • PLP language in family of distribution semantics languages • PRISM [Sato,Kameya], Independent Choice Logic [Poole], CP-logic [Vennekens et al.], … Atom Probability 
 FOL formula (sum ≤ 1) ( E 1 : � 1 ) ∨ · · · ∨ ( E n : � n ) ← � . Condition φ , when true, causes one of the effects E i (or none if sum < 1). Each of the E i is caused with probability ϵ i.

  3. Example • Random walk • Never turn back • What is the probability? • Of getting stuck • Finding exit

  4. Example (1/4) (Go(Right,t) : ⅓ ) ∨ (Go(Straight,t) : ⅓ ) ∨ (Go(Left,t): ⅓ ) ← At(p,t) ∧ FourWay(p). � � (Go(Left,t) : ½ ) ∨ (Go(Right, t) : ½ ) ← At(p,t) ∧ Facing(d,t) ∧ TJunction(p,d). (Go(Left,t) : ½ ) ∨ (Go(Straight, t) : ½ ) ← At(p,t) ∧ Facing(d,t) ∧ LeftTurn(p). (Go(Right,t) : ½ ) ∨ (Go(Straight, t) : ½ ) ← At(p,t) ∧ Facing(d,t) ∧ RightTurn(p). � � Go(Left,t) ← At(p,t) ∧ LeftBend(p). Go(Right,t) ← At(p,t) ∧ RightBend(p). Go(Straight,t) ← At(p,t) ∧ Straight(p).

  5. Example (2/4) At(to, t +1) ← At(from, t) ∧ Go(dir,t) ∧ Road(from,dir,to). � Facing(d2,t +1) ← Facing(d1,t) ∧ Go(Left,t) ∧ Next(d2,d1). Facing(d2,t +1) ← Facing(d1,t) ∧ Go(Right,t) ∧ Next(d1,d2). Facing(d, t +1) ← Facing(d,t) ∧ Go(Straight,t). � Next(N,E). Next(E,S). Next(S,W). Next(W,N). � At(Start,0). Heading(East,0).

  6. Example (3/4) Road(1,N,2). Road(1,E,3). Road(2,N,4). Road(2,E,5). … � Road(x,S,y) ← Road(y,N,x). Road(x,W,y) ← Road(y,W,x).

  7. Example (4/4) FourWay(p) ← Road(p,N,_) ∧ Road(p,E,_) ∧ Road(p,S,_) ∧ Road(p,W,_). � TJunction(p,d) ← ¬FourWay(p) ∧ Next(left,d) ∧ Next(d,right) ∧ Road(p,left,_) ∧ Road(p,right,_). LeftTurn(p,d) ← ¬FourWay(p) ∧ Next(left,d) ∧ Road(p,left,_) ∧ Road(p,d,_). RightTurn(p,d) ← ¬FourWay(p) ∧ Next(d,right) ∧ Road(p,right,_) ∧ Road(p,d,_). � ThreeJunction(p,d) ← TJunction(p,d) ∨ LeftTurn(p,d) ∨ RightTurn(p,d). � LeftBend(p,d) ← ¬FourWay(p) ∧ ¬ThreeJunction(p) ∧ Next(left,d) ∧ Road(p,left,_). RightBend(p,d) ← ¬FourWay(p) ∧ ¬ThreeJunction(p) ∧ Next(d,right) ∧ Road(p,right,_). Straight(p,d) ← ¬FourWay(p) ∧ ¬ThreeJunction(p) ∧ Road(p,d,_).

  8. Simplifying assumptions • All theories have been grounded • No negation in bodies • Two-valued well-founded model semantics • Makes both implementation and semantics bit more difficult • Probabilities in the head sum to 1

  9. Distribution semantics [Sato] Instance 1 α · δ ( a : α ) ∨ ( b : β ) ← φ . CP-theory ( c : γ ) ∨ ( d : δ ) ← ψ . … β · γ ( a : α ) ∨ ( b : β ) ← φ . ( c : γ ) ∨ ( d : δ ) ← ψ . Instance n ( a : α ) ∨ ( b : β ) ← φ . ( c : γ ) ∨ ( d : δ ) ← ψ .

  10. Distribution semantics [Sato] Instance 1 α · δ a ← φ . d ← ψ . CP-theory … β · γ ( a : α ) ∨ ( b : β ) ← φ . ( c : γ ) ∨ ( d : δ ) ← ψ . Instance n b ← φ . c ← ψ .

  11. Distribution semantics [Sato] Query yes | = Instance 1 α · δ no World 1 Σ a ← φ . yes d ← ψ . CP-theory … … … β · γ … ( a : α ) ∨ ( b : β ) ← φ . Σ World m ( c : γ ) ∨ ( d : δ ) ← ψ . … Instance n | = no b ← φ . c ← ψ .

  12. Distribution semantics … …

  13. Inference Exact • Problog system 
 [De Raedt,Kimmig,Fierens, … ] Approximative • PITA in XSB [Riguzzi, Swift] • CVE [Meert, Blockeel] • MCINTYRE [Riguzzi] All query-based Query 
 Disjoint All/some 
 (+ evidence) proofs sum

  14. This talk: Sampling with forward chaining • Sometimes no query • Debugging: prob = 0 • Diagnosis: MPE � • Different search strategy • Maybe more appropriate for certain theories • See experiments

  15. Efficient implementation: GPGPU http://michaelgalloy.com/2013/06/11/cpu-vs-gpu-performance.html

  16. Writing efficient GPGPU code • Massive number of simple cores in SIMD • Each core executes dumb code • Be smart about • Memory transfer • Memory access • Good fit

  17. Approach Ground CP-theory CPU GPU 1 sample 1 sample 1 sample 1 sample 1 sample 1 sample 1 sample 1 sample 1 sample 1 sample 1 sample 1 sample 1 sample 1 sample 1 sample 1 sample 1 sample 1 sample 1 sample 1 sample Results

  18. Approach Ground CP-theory CPU GPU 1 sample 1 sample 1 sample 1 sample 1 sample 1 sample 1 sample 1 sample 1 sample 1 sample 1 sample 1 sample 1 sample 1 sample 1 sample 1 sample 1 sample 1 sample 1 sample 1 sample Results

  19. Approach Ground CP-theory CPU GPU 1 sample 1 sample 1 sample 1 sample I = {} Repeat: 1 sample 1 sample 1 sample 1 sample Find applicable rule 1 sample 1 sample 1 sample 1 sample Sample atom from head 1 sample Add atom to I 1 sample 1 sample 1 sample Until no more rules 1 sample 1 sample 1 sample 1 sample Results

  20. Probability tree semantics … 0.5 … 0.5 … Equivalent [TPLP2009] 
 Correctness: sample = branch

  21. Optimisations • [ MEM ] Ensure coalesced memory access • [ INI ] Initialise data structures on GPU • [ PRI ] Use private instead of local memory • [ RAN ] Generate random numbers on GPU • [ RED ] Compute results on GPU • [ CHU ] Start m ≪ n samples on GPU, copy back, repeat 
 + stopping criterion

  22. Benchmarks • Taken from: W. Meert, J. Struyf, and H. Blockeel. CP-logic theory inference with contextual variable elimination and comparison to BDD based inference methods. In Proc. ILP, 2009. • Bloodtype, GrowingBody, GrowingHead • Linux machine with similarly priced GPU,CPU: • Intel Core i7 965 CPU (3.20GHz) • NVIDIA GeForce GTX 295 (GT200)

  23. Optimisations

  24. GrowingHead best: MCINTYRE, ok: OpenCL

  25. GrowingBody best: CVE, ok: OpenCL, PITA, ProbLog

  26. Bloodtype (non ground) best: PITA, ok: (C)VE, OpenCL(?)

  27. Bloodtype (non ground) $1000 best: PITA, ok: (C)VE, OpenCL(?)

  28. Experimental results best ok PITA 1 1 CVE 1 1 Problog 1 Problog MC Problog 
 k-best MCINTYRE 1 OpenCL 2 or 3

  29. Conclusion • Naive forward chaining sampling algorithm • Implemented in a smart way in OpenCL • Complements existing approaches • Not query-based • Different computation strategy • Experimental results • Optimisations really help • Performance is always ok, though never best • Close to formal semantics, maybe easier for extensions

  30. Thank you

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend