A question about backward propagation speed in cpp extension in tutorial

Abierto
#68 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

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

Línea de trabajo

Start by running benchmark.py with the py and cpp arguments, with and without --runs 10000, to reproduce the reported gap in backward time. The report gives no explanation for why the C++ backward path is slower than the Python one, so the work is to find the cause in the extension's backward implementation. Done means either a fix that brings backward timing in line with the Python version, or a written explanation of the gap.

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

Descripción

When submitting a bug report, please include the following information (where relevant):

  • OS: Kubuntu 20.04
  • PyTorch version: 1.7.0+cpu
  • How you installed PyTorch (conda, pip, source): pip
  • Python version: 3.8.5
  • CUDA/cuDNN version: None
  • GPU models and configuration: None
  • GCC version (if compiling from source): 9.3.0

hello, everyone. I have a question about backward propagation speed in writing cpp extension.

I download the source code of "Custom C++ and CUDA extensions" in PyTorch Tutorial, which is at https://github.com/pytorch/extension-cpp .

when I ran benchmark.py, I found that the backward propagation time in cpp is much longer than that in python. I really do not know why this happen.

The result is listed as below. And I use the original code in extension-cpp repo.

(base) wmf997@wmf997-E743-Q7C08:~/extension-cpp-master$ python benchmark.py py
Forward: 246.525/250.680 us | Backward 365.973/376.601 us
(base) wmf997@wmf997-E743-Q7C08:~/extension-cpp-master$ python benchmark.py cpp
Forward: 178.099/180.986 us | Backward 536.442/549.297 us

I ran 10000 times, and the result is listed as below. (the result above ran 100 times)

(base) wmf997@wmf997-E743-Q7C08:~/extension-cpp-master$ python benchmark.py --runs 10000 py
Forward: 245.571/334.904 us | Backward 363.827/486.081 us
(base) wmf997@wmf997-E743-Q7C08:~/extension-cpp-master$ python benchmark.py --runs 10000 cpp 
Forward: 177.860/290.786 us | Backward 537.395/834.295 us

I run my code on Kubuntu 20.04, with Python 3.8.5(Anaconda) and PyTorch 1.7.0+cpu installed. The CPU is intel core i7-3540m.

Lenguaje dominante
Python
Estrellas
1.2k
Forks
250
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

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 pytorch/extension-cpp

Todos los issues de pytorch/extension-cpp

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.