Upload
milton-black
View
234
Download
1
Tags:
Embed Size (px)
Citation preview
AI & ParallelismAI & Parallelism
By: Bryan GriffithsBy: Bryan Griffiths
TopicsTopics
Parallel AI in AcademicsParallel AI in AcademicsParallel AI in the Gaming IndustryParallel AI in the Gaming Industry
Parallel AI in AcademicsParallel AI in Academics
Areas of useAreas of useAcademic StigmaAcademic StigmaExtending Specific Algorithms (GA)Extending Specific Algorithms (GA)Benefits for other AlgorithmsBenefits for other Algorithms
Areas of UseAreas of Use
There have been significant advances in parallel There have been significant advances in parallel and distributed computing.and distributed computing.
But what are the implications of these advances But what are the implications of these advances for AI?for AI?
Four areas:Four areas: Psychological modelingPsychological modeling Improving efficiencyImproving efficiency Helping to organize systems in modular fashionHelping to organize systems in modular fashion New methods and mechanismsNew methods and mechanisms
Psychological ModelingPsychological Modeling This system was originally proposed as a model of This system was originally proposed as a model of
human information processing and storage.human information processing and storage. The ideas of short term and long-term memory, The ideas of short term and long-term memory,
independently operating productions, matching, and independently operating productions, matching, and other operations came from psychological literature.other operations came from psychological literature.
The human brain contains individual neurons which are The human brain contains individual neurons which are slow compared to digital computer circuits, but there are slow compared to digital computer circuits, but there are vast numbers of these and they are richly connected vast numbers of these and they are richly connected components that operate concurrently.components that operate concurrently.
SOAR is production system with dual mission:SOAR is production system with dual mission: Architecture for building AI systemsArchitecture for building AI systems Model human intelligenceModel human intelligence
SOAR incorporates both sequential and parallel aspects.SOAR incorporates both sequential and parallel aspects.
Improving EfficiencyImproving Efficiency AI programs consume significant space and time AI programs consume significant space and time
resources when working with complex problems.resources when working with complex problems. It is therefore important that AI algorithms make use of It is therefore important that AI algorithms make use of
advances in parallel computation to speed-up research.advances in parallel computation to speed-up research. There are several sources of parallelism for speedup in There are several sources of parallelism for speedup in
production systems:production systems: Production level parallelism, in which all the productions match Production level parallelism, in which all the productions match
themselves against working memory in parallel.themselves against working memory in parallel. Condition level parallelism, in which all of the conditions of single Condition level parallelism, in which all of the conditions of single
production are matched in parallel.production are matched in parallel. Action level parallelism, in which all of the actions of a single Action level parallelism, in which all of the actions of a single
production are executed in parallel.production are executed in parallel. Task level parallelism, in which several cycles are executed Task level parallelism, in which several cycles are executed
simultaneously.simultaneously.
Parallelizing AI AlgorithmsParallelizing AI Algorithms The amount of task level parallelism available is The amount of task level parallelism available is
completely dependent on the nature of the task.completely dependent on the nature of the task. In medical diagnosis, each production firing In medical diagnosis, each production firing
might be dependent on the previous production might be dependent on the previous production firing, thus enabling a long, sequential chain of firing, thus enabling a long, sequential chain of reasoning to occur.reasoning to occur.
If the system is diagnosing five patients If the system is diagnosing five patients simultaneously, productions involving different simultaneously, productions involving different patients would not interact with one another and patients would not interact with one another and could be executed in parallel.could be executed in parallel.
Embarrassingly parallel, but extremely useful.Embarrassingly parallel, but extremely useful.
Parallelizing AI AlgorithmsParallelizing AI Algorithms Examples:Examples:
Ten authors can write a book much faster than one authorTen authors can write a book much faster than one author Ten woman cannot bear a child any faster than one can!Ten woman cannot bear a child any faster than one can! Likewise throwing more processors at an AI problem may not bring Likewise throwing more processors at an AI problem may not bring
desired benefits.desired benefits. Many problems can be solved efficiently by parallel methods.Many problems can be solved efficiently by parallel methods. It is not always easy to convert a sequential algorithm into an It is not always easy to convert a sequential algorithm into an
efficient parallel one.efficient parallel one. Some AI algorithms whose parallel aspects have been studied are:Some AI algorithms whose parallel aspects have been studied are:
Genetic AlgorithmsGenetic Algorithms Most types of searches (BFS, DFS, IDA*)Most types of searches (BFS, DFS, IDA*) Alpha-beta pruningAlpha-beta pruning Theorem provingTheorem proving Neural NetsNeural Nets
Academic StigmaAcademic Stigma
Currently most AI research does not use Currently most AI research does not use parallel implementations of the AI parallel implementations of the AI algorithms. Why is that?algorithms. Why is that?Parallel algorithms need parallel machines, Parallel algorithms need parallel machines,
which of course means more money is which of course means more money is needed to do the research.needed to do the research.
Also the way other academics view the Also the way other academics view the effectiveness of an algorithm:effectiveness of an algorithm:If its parallel it must be slow.If its parallel it must be slow.If its parallel it must be a weaker algorithm.If its parallel it must be a weaker algorithm.
Academic StigmaAcademic Stigma
If its parallel it must be slow?If its parallel it must be slow?You obviously parallelized it because your You obviously parallelized it because your
implementation was slow.implementation was slow. If its parallel it must be a weaker If its parallel it must be a weaker
algorithm?algorithm?You must have parallelized it because you You must have parallelized it because you
were not getting “good” solutions and needed were not getting “good” solutions and needed more CPUs traversing the search space to more CPUs traversing the search space to achieve your answers.achieve your answers.
Extending Specific AlgorithmsExtending Specific Algorithms
Genetic Algorithms:Genetic Algorithms: is a search technique used to compute is a search technique used to compute
solutions to optimization and search solutions to optimization and search problems. problems.
Categorized as global search heuristics.Categorized as global search heuristics.A class of evolutionary algorithms that use A class of evolutionary algorithms that use
techniques inspired by evolutionary techniques inspired by evolutionary biology such as inheritance, mutation, biology such as inheritance, mutation, selection, and recombination.selection, and recombination.
Genetic AlgorithmsGenetic Algorithms
Implemented as a computer simulation in Implemented as a computer simulation in which a population of abstract which a population of abstract representations of candidate solutions to representations of candidate solutions to an optimization problem, evolves toward an optimization problem, evolves toward better solutions.better solutions.
Applications in biogenetics, computer Applications in biogenetics, computer science, engineering, economics, science, engineering, economics, chemistry, manufacturing, mathematics, chemistry, manufacturing, mathematics, physics and other fields.physics and other fields.
Genetic AlgorithmsGenetic Algorithms
Parallel Genetic AlgorithmsParallel Genetic Algorithms
Parallel implementations of genetic Parallel implementations of genetic algorithms come in various flavours:algorithms come in various flavours: Coarse grained parallel genetic algorithms Coarse grained parallel genetic algorithms
assume a population on each of the computer assume a population on each of the computer nodes and migration of individuals among the nodes and migration of individuals among the nodes. nodes. Types: Island Model, Migration Models.Types: Island Model, Migration Models.
Fine grained parallel genetic algorithms Fine grained parallel genetic algorithms assume an individual on each processor node assume an individual on each processor node which acts with neighboring individuals for which acts with neighboring individuals for selection and reproduction. A.k.a Cellular selection and reproduction. A.k.a Cellular PGA.PGA.
Parallel Genetic AlgorithmsParallel Genetic Algorithms
Single-population master-slave GAs distributes the evaluation of individuals by scheduling fractions of the population among the processing slave nodes. Such a model has the advantage for ease of implementation and does not alter the search behavior of a sequential GA.
Hierarchical parallel GAs are basically any combination of two or more of the three basic forms of PGA is an HPGA.
Parallel Genetic AlgorithmsParallel Genetic Algorithms
PGA - MigrationPGA - Migration
Migration can be done in various ways and Migration can be done in various ways and can be a factor or function of your cluster can be a factor or function of your cluster design.design.
Ring MethodRing MethodGrid MethodGrid Method
PGA - MigrationPGA - Migration
There are also various ways of choosing There are also various ways of choosing which chromosome will migrate from one which chromosome will migrate from one subpopulation to the next.subpopulation to the next.
RandomRandomBest/BadBest/Bad
PGA - MigrationPGA - Migration
PGA - MigrationPGA - Migration
PGA - MigrationPGA - Migration
Another approach could be to implement a Another approach could be to implement a central database that subpopulations would central database that subpopulations would submit their best too and then draw the best submit their best too and then draw the best chromosome from that database to replace their chromosome from that database to replace their worst. (King of the Hill Migration)worst. (King of the Hill Migration)
This provides a faster migration of your top This provides a faster migration of your top chromosome across your entire set of chromosome across your entire set of subpopulations and thereby exposing your elite subpopulations and thereby exposing your elite to new genetic materials in hopes of advancing it to new genetic materials in hopes of advancing it even farther.even farther.
PGA - MigrationPGA - Migration
PGA – MigrationPGA – Migration
Advantages:Advantages:Easy to implement, even in existing GA code.Easy to implement, even in existing GA code.Low network traffic.Low network traffic.Customizable to your architecture.Customizable to your architecture.Faster than sequential GA and generally Faster than sequential GA and generally
achieves a better result. (Unless optimal achieves a better result. (Unless optimal solution is easy to obtain.)solution is easy to obtain.)
PGA – MigrationPGA – Migration
Disadvantages:Disadvantages:Supposedly harder to work with because you Supposedly harder to work with because you
know have three new variables to fine tune.know have three new variables to fine tune.Migration rateMigration rateNumber of chromosomes to migrateNumber of chromosomes to migrateMigration direction and layoutMigration direction and layout
Grid Enabled - HPGAGrid Enabled - HPGA
Benefits for other AlgorithmsBenefits for other Algorithms(Greedy Algorithms)(Greedy Algorithms)
Large search space.A heuristic that tells which current
alternative looks best.Take that alternative first.Potentially neglect other paths.
In parallel:Take first N best looking alternatives.Reducing the neglect.
Benefits for other AlgorithmsBenefits for other Algorithms(Parameter sweeping)(Parameter sweeping)
Find the best solution for a given N dimensional function by trying all input values.
Given a function f(x,y,z,…) Find its max, min, highest differential, etc Tries all x, y, z,…
Mostly embarrassingly parallel.Algorithms are extremely stupid.
Use other AI/search methods !
Benefits for other AlgorithmsBenefits for other Algorithms(Simulated Annealing / Tabu Search)(Simulated Annealing / Tabu Search)
Every value (or group of) can be handled by a cpu and searched along its own path.
When a cpu becomes free it could request a new value (or group) from another cpu and continue on from that point.
Benefits for other AlgorithmsBenefits for other Algorithms(Neural Networks)(Neural Networks)
Large neural networks can have huge computational needs.
Training a neural network with many input data sets can be time consuming.
Some problems require real time behaviour.
Benefits for other AlgorithmsBenefits for other Algorithms (Neural Networks) (Neural Networks)
Perform learning in parallel Embarrassingly parallel approaches:
Simply start N neural networks in parallel with different (pseudo) random initial weights and then select one from the final trained networks.
Evaluate input using multiple different networks in parallel and choose answer from network with highest level of confidence
In this approach messages only need to be sent for: Sending input data to processors Retrieving output from all processors
Benefits for other AlgorithmsBenefits for other Algorithms (Neural Networks) (Neural Networks)
Split forward propagating network into columns:
Split network into strongly connected clusters:
(Neural Networks)(Neural Networks)
Benefits for other AlgorithmsBenefits for other Algorithms (Breadth First Search) (Breadth First Search)
Parallel Implementation:Maintain shared queues for all processors
One queue per depth
Each processor gets/adds vertices from queue
Barrier until all vertices from one depth visitedNote: search order is potentially different
than sequential search order
Benefits for other AlgorithmsBenefits for other Algorithms (Depth First Search) (Depth First Search)
Sequential_DFS(root) Visited(root) = true; For all neighbour vertices w of root
If not visited(w) Dfs_parent(w) = r Sequential_DFS(w)
Parallel_DFS(root) Visited(root) = true; ParFor all neighbour vertices w of root
If not visited(w) Dfs_parent(w) = r parallel_DFS(w)
Note: search order is potentially different than sequential search order
Benefits for other AlgorithmsBenefits for other Algorithms (IDA *)(IDA *)
Sequential:For I = 0 to max_depth
DFS_search_to_depth(I)
• Parallel:For I = 0 to max_depth
Parallel BFS_search_to_depth(I)
Parallel AI in the Gaming IndustryParallel AI in the Gaming Industry
Industry StigmasIndustry StigmasAreas of UseAreas of UseA Look at Past and Current Generations of A Look at Past and Current Generations of
HardwareHardwareSome Examples Of AI EnginesSome Examples Of AI EnginesSome Ideas of MineSome Ideas of MineWhat the Future HoldsWhat the Future Holds
Industry StigmaIndustry Stigma True AI uses to many resources that we need instead for True AI uses to many resources that we need instead for
our new “mega-super cool flashy graphics that are uber-our new “mega-super cool flashy graphics that are uber-realistic” engine and that other stuff…realistic” engine and that other stuff… Generally true especially when you understand that “stuff” they Generally true especially when you understand that “stuff” they
are talking about outside of the graphics engine include, physics are talking about outside of the graphics engine include, physics engines, audio engines, voice and/or video – chat, and engines, audio engines, voice and/or video – chat, and everything else that goes into the game.everything else that goes into the game.
In most companies AI gets a choke-hold put on it very early in In most companies AI gets a choke-hold put on it very early in development reducing it to simple finite state machines and development reducing it to simple finite state machines and scripting/trigger based events because “well it works and that’s scripting/trigger based events because “well it works and that’s all we need”.all we need”.
Games that feature “revolutionary” AI are sometimes as simple Games that feature “revolutionary” AI are sometimes as simple as a system that now randomly says some kind of battle chatter as a system that now randomly says some kind of battle chatter or screams of agony when they die.or screams of agony when they die.
Areas of UseAreas of Usefor Parallel AIfor Parallel AI
Everywhere in this industry:Everywhere in this industry:Graphics, animation, face effects, ect.Graphics, animation, face effects, ect.Pathfinding and path smoothing.Pathfinding and path smoothing. Individual and group NPC behaviours.Individual and group NPC behaviours.Dynamic music and sound systems.Dynamic music and sound systems.Competitive and co-operative strategic play.Competitive and co-operative strategic play.Arcade games that have large search spaces.Arcade games that have large search spaces.
Chess, Go, ect.Chess, Go, ect.
Limitations of Past GenerationsLimitations of Past Generations
Single ProcessorSingle ProcessorSingle ThreadSingle ThreadLimited ResourcesLimited Resources
Small amount of RAMSmall amount of RAMSmall amount of ROMSmall amount of ROM
Current Generation of HardwareCurrent Generation of Hardware
PS3:PS3:Cell Processor:Cell Processor:
1 1 Power PE:Power PE: A 64-bit general purpose register set.A 64-bit general purpose register set. a 64-bit floating point register set.a 64-bit floating point register set. a 128-bit Altivec register set.a 128-bit Altivec register set.
8 8 Synergistic PEs:Synergistic PEs: Able to do SIMD computations.Able to do SIMD computations. Or scalar data types ranging from 8 to 128-bits in size.Or scalar data types ranging from 8 to 128-bits in size.
Current Generation of HardwareCurrent Generation of Hardware
Xbox 360:Xbox 360: triple-core PowerPC-based design.triple-core PowerPC-based design.
Each of the cores has two symmetric hardware Each of the cores has two symmetric hardware threads.threads.
Multiple FPU and SIMD vector processing units in Multiple FPU and SIMD vector processing units in each core.each core.
VMX128 (similar to Altivec, just with more registers) VMX128 (similar to Altivec, just with more registers)
Current Generation of HardwareCurrent Generation of Hardware
Computers:Computers: Intel CPUs – Dual, Quad and Eight-core Intel CPUs – Dual, Quad and Eight-core
versions are in production or in the pipeline.versions are in production or in the pipeline.GPU Technologies becoming even more GPU Technologies becoming even more
parallel in nature:parallel in nature:Multi-processor cardsMulti-processor cardsSLISLICrossfireCrossfire
So how did they use this power?So how did they use this power?
UE3… multi-threaded, barely. UE3… multi-threaded, barely. But that’s not all bad, it means we could But that’s not all bad, it means we could
do more advanced AI elements in a game do more advanced AI elements in a game if we separate it from the engine and if we separate it from the engine and parallelize the AI middleware engine.parallelize the AI middleware engine.
AI Middleware EnginesAI Middleware Engines
AI.implant, from BioGraphic Technologies in AI.implant, from BioGraphic Technologies in Montreal, Canada.Montreal, Canada. Focuses on animation control, offering unique AI Focuses on animation control, offering unique AI
solutions for complex animations that a developer solutions for complex animations that a developer might need a solution for.might need a solution for.
Hierarchical pathfindingHierarchical pathfinding Rule-based decisions Rule-based decisions Group behaviorsGroup behaviors Flocking behaviorsFlocking behaviors
We could further parallelize this by computing We could further parallelize this by computing behaviours for various groups or characters that behaviours for various groups or characters that are currently running around.are currently running around.
AI Middleware EnginesAI Middleware Engines
Kynapse Engine, Kynogon.Kynapse Engine, Kynogon. A.I. code reusable independently of engine codeA.I. code reusable independently of engine code Advanced 3D topology dynamic analysisAdvanced 3D topology dynamic analysis
Runtime identification of key topological places for hiding, Runtime identification of key topological places for hiding, surrounding, organizing opposite flank assault, etc. surrounding, organizing opposite flank assault, etc.
Path planningPath planning Path smoothingPath smoothing
3D pathfinding in a destructible world: 3D pathfinding in a destructible world: http://www.kynogon.com/images-blog/Demos/GDC/dehttp://www.kynogon.com/images-blog/Demos/GDC/destructibleworld.avistructibleworld.avi
What They Could be Doing…What They Could be Doing…
Take the internet, a simple hosted server, Take the internet, a simple hosted server, storage drives, a learning algorithm, an AI storage drives, a learning algorithm, an AI implementation of algorithm “X” and a little implementation of algorithm “X” and a little bit of big brother, now blend…bit of big brother, now blend…
If we can’t do the parallel heavy weight AI If we can’t do the parallel heavy weight AI on the user’s system then outsource the on the user’s system then outsource the work.work.
What They Could be Doing…What They Could be Doing… NPC AI for FPS that could be updated over time keeping NPC AI for FPS that could be updated over time keeping
the game fresh and challenging. the game fresh and challenging. Just use a GA offsite on your company server that analyses the Just use a GA offsite on your company server that analyses the
fitness of the AI when playing against different players then fitness of the AI when playing against different players then recombine the chromosome and send out the new AI to be recombine the chromosome and send out the new AI to be tested and fitness to be evaluated.tested and fitness to be evaluated.
Planning AI for RTS games that constantly evolves along Planning AI for RTS games that constantly evolves along with players as they both discover new strategies.with players as they both discover new strategies. Even after 10 different “balancing patches” have been applied to Even after 10 different “balancing patches” have been applied to
a game like Starcraft, the AI would not be outdated if you played a game like Starcraft, the AI would not be outdated if you played it in a single player game or included an AI player in a it in a single player game or included an AI player in a multiplayer game.multiplayer game.
What They Could be Doing…What They Could be Doing…
Do you enjoy different kinds of music Do you enjoy different kinds of music besides the rock, techno and orchestral besides the rock, techno and orchestral music used in most games?music used in most games?No problem, submit your favorite playlist of No problem, submit your favorite playlist of
music and have the game adapt it to the music and have the game adapt it to the gameplay using a Neural Net that replaces gameplay using a Neural Net that replaces battle music with your favorite Kung-fu Fighter battle music with your favorite Kung-fu Fighter remix or cranky truck driver-gone mad country remix or cranky truck driver-gone mad country track, ect.track, ect.
Where this Could Lead in the Where this Could Lead in the FutureFuture
LucasArts next Indiana Jones video game LucasArts next Indiana Jones video game and Star wars game contains some and Star wars game contains some interesting AI improvments for character interesting AI improvments for character animations and physics reactions:animations and physics reactions:http://www.youtube.com/watch?v=jKLfD5M_I6http://www.youtube.com/watch?v=jKLfD5M_I6
o&eurl=http%3A%2F%2Fwww%2Egame%2Do&eurl=http%3A%2F%2Fwww%2Egame%2Dreviews%2Eca%2Fnews%5F1116%2Ehtmreviews%2Eca%2Fnews%5F1116%2Ehtm
http://media.ps3.ign.com/media/823/823668/vihttp://media.ps3.ign.com/media/823/823668/vids_1.htmlds_1.html
Where this Could Lead in the Where this Could Lead in the FutureFuture
CryEngine 2:CryEngine 2:Multi-threaded EngineMulti-threaded EngineWhich improves many aspects of the game Which improves many aspects of the game
such as AI and physics by speeding up CPU such as AI and physics by speeding up CPU computations. One huge advantage to the computations. One huge advantage to the CryEngine 2 is that it will detect the number of CryEngine 2 is that it will detect the number of threads the CPU(s) have and will then equally threads the CPU(s) have and will then equally distribute code out across all of the threads. distribute code out across all of the threads.
Where this Could Lead in the Where this Could Lead in the FutureFuture
At a glance many of AI problems can be At a glance many of AI problems can be solved with embarrassingly parallel solved with embarrassingly parallel approaches. approaches. PathingPathingBehavioursBehavioursLearningLearningetc…etc…
Where this Could Lead in the Where this Could Lead in the FutureFuture
But when you look at the problem more in-But when you look at the problem more in-depth you begin to realize that the depth you begin to realize that the problems can be solved in their simple problems can be solved in their simple forms this way, but in there more complex forms this way, but in there more complex forms communication, scheduling and forms communication, scheduling and prediction issues become apparent.prediction issues become apparent.Group pathingGroup pathingComplex strategies (Flanking, bait and trap, Complex strategies (Flanking, bait and trap,
surrounding, ect.)surrounding, ect.)
Where this Could Lead in the Where this Could Lead in the FutureFuture
This brings us back to many of the harder This brings us back to many of the harder parallel problems to be solved in order to parallel problems to be solved in order to implement these more complex forms of implement these more complex forms of game AI in parallel.game AI in parallel.
Comments, Questions or Ideas?Comments, Questions or Ideas?
ReferencesReferences PGA Paper: PGA Paper:
http://www.hindawi.com/GetArticle.aspx?doi=10.1155/JAMDS/2006/http://www.hindawi.com/GetArticle.aspx?doi=10.1155/JAMDS/2006/6574665746
PGA Paper 2: PGA Paper 2: http://www.evolutionaria.com/publications/scale-ecj-final.pdfhttp://www.evolutionaria.com/publications/scale-ecj-final.pdf
AI Algoritms: AI Algoritms: http://www.pes.edu/mcnc/AI/data/presentation/Rich&Knight/Chapterhttp://www.pes.edu/mcnc/AI/data/presentation/Rich&Knight/Chapter16_Parallel_AI.ppt16_Parallel_AI.ppt
AI Algorithms 2: AI Algorithms 2: http://www2.informatik.uni-erlangen.de/Lehre/WS200506/ParAlg/lecthttp://www2.informatik.uni-erlangen.de/Lehre/WS200506/ParAlg/lecture-10-new.pdf?language=deure-10-new.pdf?language=de
AI.Implant: AI.Implant: http://www.gamasutra.com/features/20030721/dybsand_01.shtmlhttp://www.gamasutra.com/features/20030721/dybsand_01.shtml
Kynapse: Kynapse: http://www.kynogon.com/products/products/index.htmlhttp://www.kynogon.com/products/products/index.html Crytek: Crytek: http://http://www.crytek.com/news/index.phpwww.crytek.com/news/index.php