Nested Dataset Slowdown

Abierto
#593 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Necesita aclaración
Estado de actividad
Estancado
Stack tecnológico
python, tensorflow

Línea de trabajo

Comienza con la ruta anidada de DataLoader mostrada en el ejemplo, especialmente con la creación y validación del estado, donde se informa de la ralentización; usa el flamegraph de pyinstrument para confirmar por qué Grain llama a repr en el dataset interno. Compara el bucle anidado de episode/steps con un caso no anidado. Se considera terminado cuando se haya resuelto la ralentización informada en el estado y la validación sin cambiar el comportamiento de los datasets anidados.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Python
Estrellas
800
Forks
94
Merge medio
1 d 9 h
PR fusionados (30 d)
9

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de google/grain

Todos los issues de google/grain

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.