Vengineerの戯言

人生は短いけど、長いです。人生を楽しみましょう!

Graphcoreの3つのケースとは?

@Vengineerの戯言 : Twitter
SystemVerilogの世界へようこそすべては、SystemC v0.9公開から始まった 

下記の 「London Meetup: Deep Dive into TensorFlow #27」に関するTweetから

ハッシュタグ #TensorFlowLDN で Graphcore に関するものを見ていきます。

www.eventbrite.com

 

 

 この最後の写真にある3つのケース

  • MODEL SHARDING
  • MODEL REPLICATION
  • MODEL PIPELING

これ、昨日のgithub の examples にもありました。

TensorFlow の code_examples の中に。

ここ の説明によれば、Sharding とは、以下のように1つのモデルを複数チップ実行するときのオプション。

--shards : The number of IPUs to split the model over (default 1). If shards > 1 then the first part of the model will be run on one IPU with later parts run on other IPUs with data passed between them. This is essential if the model is too large to fit on a single IPU, but can also be used to increase the possible batch size. As an advanced usage, the sharding algorithm can be influenced using the --sharding-exclude-filter and --sharding-include-filter options. These specify sub-strings of edge names that can be used when looking for a cutting point in the graph.

このファイルが、-shards の例題になっている。

tensorflow.python.ipu.autoshard.ipu_autoshard() にて、自動分割してくれる。

tensorflow.python.ipu.scopes.ipu_shard(n) にて、手動分割ができる。

cfg = utils.create_ipu_config(profiling=True)
cfg = utils.auto_select_ipus(cfg, NUM_SHARDS)

utils.configure_ipu_system(cfg)

にて、分割を指定できる。あとは普通にTensorFlowのsessionにて、run するだけ。

 

 このファイルが、REPLICATIONの例

# To use replication, we make as many feeds as there are replicated IPUs by passing in replication_factor
infeed = ipu_infeed_queue.IPUInfeedQueue(dataset, replication_factor=opts.replication_factor, feed_name='in')
outfeed = ipu_outfeed_queue.IPUOutfeedQueue(replication_factor=opts.replication_factor, feed_name='out')

InfeedQueueとOutputfeedQueueの replication_factorを指定すればいいみたい。

 

PIPELININGについては、Image Classification Inference には、

Run inference using optimized data pipelining for image classification with pre-trained weights

とありました。

また、ここ には、

  • --pipeline-splits
  • --pipeline-depth

というオプションの説明があります。

--pipeline-depth : When a model is run over multiple shards (see --shards) pipelining the data flow can improve throughput by utilising more than one IPU at a time. At present the splitting points for the pipelined model must be specified, with one less split than the number of shards used. Use --pipeline-splits to specifiy the splits - if omitted then the list of available splits will be output.