Upgrade to Pro — share decks privately, control downloads, hide ads and more …

PyTorch-BigGraph: A Large Scale Graph Embedding System

PyTorch-BigGraph: A Large Scale Graph Embedding System

¯\_(ツ)_/¯

April 25, 2019
Tweet

More Decks by ¯\_(ツ)_/¯

Other Decks in Technology

Transcript

  1. PyTorch-BigGraph - Billion-Trillionサイズのエッジを持つグラフに対して Graph Embeddingsを行う - For Knowledge Graph -

    シングルマシン、分散学習における省メモリ /計算効率の向上 - Negative Samplingにおける効率的な負例の生成 - OSS - https://github.com/facebookresearch/PyTorch-BigGraph
  2. 1. Graph Embeddings 2. PyTorch-BigGraph a. Data Structure b. Distributed

    Training c. Single Machine Training d. Negative Sampling e. Evaluation Outline
  3. - Graph Embeddingsといっても、実際には様々な Input/Outputを扱うモデルが存在する - Input: - Homogeneous Graph (e.g.

    undirected and unweighted graph) - Heterogeneous graph (e.g. Knowledge Graph) - Output: - Node, Edge, Whole-Graph - Methods - Random walk: DeepWalk, node2vec - Graph convolutional network - For Knowledge Graph: TransE, RESCAL, DistMult, ComplEx Graph Embeddings
  4. - Embeddings - Word Embeddings: word -> vector - Graph

    Embeddings: node -> vector - Approach - グラフの各ノード(エンティティ)におけるベクトル表現を獲得する。あるエッジで結ばれた エンティティ同士は結ばれていないエンティティよりも似たようなベクトルを獲得するよう に学習する - Word EmbeddingsにおけるDistributional Hypothesisのようなもの Graph Embeddings
  5. 0. すべてのマシンについて init_process_groupを実行し、以下を待つ - Parameter Server、Partition Serverを各マシンで起動し、 Rank 0 についてはLock

    Serverも起動 - Lock Server - バケットを管理する。各ワーカーから必要に応じてバ ケットを渡す Distributed Training
  6. - Parameter Server - torch.distributed.{send/recv} を利用して実装 - Parameter Sharer -

    Parameter Serverに対して定期的にモデルにおける共 有パラメータ(nn.Moduleについてstate_dictで取得で きるもの)を同期する - https://github.com/facebookresearch/PyTorch-BigG raph/issues/34 - 他の通信を優先するため 100 updates/s またはデータサイズ 1GB/s の制約の中行われる Parameter Server
  7. - Rank 0のマシンをマスターとみなし、他のマシンはワーカーとして振 る舞う - マスター: 各ワーカーに対するソケットを作成し、ワーカーの 接続を待つ。ワーカーに対して各ワーカーの情報を送る - ワーカー:

    マスターへのソケットを作成し、マスターから他の ワーカーの情報を受け取る。すべてのワーカーと疎通確認を 行う - GILの開放も行う - https://github.com/pytorch/pytorch/blob/v1.0.1/torch/csr c/utils/auto_gil.h init_process_group
  8. 疎通後の各マシンのフロー : 1. Lock Serverに対してバケットの要求( acquire_bucket)を行う - そのバケットが保有するパーティションはロックされる - 各マシンが互いに素なバケットで学習を行なう

    (Matrix FactorizationにおけるDSGDに似た話) 2. バケットからPartition Serverに対しパーティションをスワップ - 古いバケットにおけるパーティションのロックが開放される (release_bucket) Distributed Training
  9. Single Machine Training - パーティションのスワップ(ディスクに対して)の効率化 - なるべくスワップする回数を減らしたい - Outside-in 1.

    あるインデックスN(0から)をもつ組み合わせをリストアップ - <N, *>, <*,N> 2. 次に N+1について残りのリストを追加 3. 残りがなくなるまで続ける - 論文で紹介されているのはこれを反転させたもの (Inside-out)
  10. - All negatives - 入力された正例に対して、同じパーティションに属するすべてのエンティティの中で可能 な限りすべてのエッジを負例とみなして学習を行う - 膨大な数の負例が生成されるので非効率 - Negative

    Sampling - パーティションを学習する際には入力がバッチに区切られる - 同じバッチにある他のエッジを負例として利用 - 他のバッチ(同じパーティションに属するエンティティ)から一様にサンプリング ⇒ これらを組み合わせて負例を生成 Negative Sampling
  11. About Me Software Engineer @Mercari ・ GitHub: @ynqa ・ Twitter:

    @yn_9a Go で Word Embeddings 書いてます ⇒ https://github.com/ynqa/wego
  12. - PyTorch-BigGraph: A Large-scale Graph Embedding Framework - https://www.sysml.cc/doc/2019/71.pdf -

    Open-sourcing PyTorch-BigGraph for faster embeddings of extremely large graphs - https://ai.facebook.com/blog/open-sourcing-pytorch-biggraph-for-faster-embeddings-of-extremely- large-graphs - SysML 19: Adam Lerer, Pytorch-BigGraph: A Large Scale Graph Embedding System - https://www.youtube.com/watch?v=VPzwRQYM9-Y - PyTorch-BigGraph Navigation - https://torchbiggraph.readthedocs.io/en/latest/index.html References
  13. References - DISTRIBUTED COMMUNICATION PACKAGE - https://pytorch.org/docs/stable/distributed.html - WRITING DISTRIBUTED

    APPLICATIONS WITH PYTORCH - https://pytorch.org/tutorials/intermediate/dist_tuto.html - Knowledge Graph Embedding: A Survey of Approaches and Applications - https://persagen.com/files/misc/Wang2017Knowledge.pdf - A Comprehensive Survey of Graph Embedding: Problems, Techniques and Applications - https://arxiv.org/pdf/1709.07604.pdf - Holographic Embeddings of Knowledge Graphs - https://arxiv.org/pdf/1510.04935.pdf
  14. - HOGWILD!: A Lock-Free Approach to Parallelizing Stochastic Gradient Descent

    - https://papers.nips.cc/paper/4390-hogwild-a-lock-free-approach-to-parallelizing-stochastic-gradien t-descent.pdf - Adaptive Subgradient Methods for Online Learning and Stochastic Optimization - http://www.jmlr.org/papers/volume12/duchi11a/duchi11a.pdf - Large-Scale Matrix Factorization with Distributed Stochastic Gradient Descent - http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.230.7682&rep=rep1&type=pdf References