Nested Dataset Slowdown

オープン
#593 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
python, tensorflow

調査の方向性

例に示されているネストされた DataLoader パスから始め、特に低速化が報告されている state の作成と検証を確認してください。pyinstrument の flamegraph を使って、Grain が内側の dataset に対して repr を呼び出す理由を確認してください。ネストされた episode/steps ループと、ネストされていないケースを比較してください。state の作成と検証で報告されている低速化が、ネストされた dataset の動作を変更せずに解消されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

type:performance

TLDR: I'm working with robotics datasets. They are expressed a nested dataset. Grain calls repr on the inner dataset which slows down the loops significantly.

I think grain has serious benefits over tfds for nested datasets like this. Currently, rlds is the best way of handling these types of datasets. It somewhat abuses tfds dataset manipulation techniques since it doesn't have a better of handling this. I think grain would be able to simplify a lot of these workflows and allow for much more complex things to be created, i.e stitching multiple robot episodes together in unique ways that aren't easily expressible in tfds or rlds.

Fixing the above problem would be hugely beneficial and doesn't feel like it's super necessary.

Simple example to showcase the problem:

builder = tfds.builder_from_directory(builder_dir=dataset_path)
episode_data_source = builder.as_data_source("train", deserialize_method=tfds.core.decode.DeserializeMethod.DESERIALIZE_AND_DECODE)
episode_index_sampler = grain.IndexSampler(
    num_records=2,
    num_epochs=1,
    shard_options=grain.ShardOptions(shard_index=0, shard_count=1, drop_remainder=True),
    shuffle=True,
    seed=0
)

steps_index_sampler = grain.IndexSampler(
    num_records=2,
    num_epochs=1,
    shard_options=grain.ShardOptions(shard_index=0, shard_count=1, drop_remainder=True),
    shuffle=True,
    seed=0
)

import pyinstrument
profiler = pyinstrument.Profiler()

profiler.start()

episode_data_loader = grain.DataLoader(data_source=episode_data_source, sampler=episode_index_sampler)
for episode_data in episode_data_loader:
    steps_data_source = episode_data[rlds.STEPS]
    steps_data_loader = grain.DataLoader(data_source=steps_data_source, sampler=steps_index_sampler)
    for steps_data in steps_data_loader:
        pass

profiler.stop()

# Save the flamegraph to an HTML file
with open('flamegraph.html', 'w') as f:
    f.write(profiler.output_html())

Specific slowdowns happen when creating the state/validating the state.

主要言語
Python
スター
801
フォーク
97
平均マージ
20時間 16分
マージ済み PR(30日)
12

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

google/grain のほかの issue

google/grain の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。