A question about backward propagation speed in cpp extension in tutorial

Aberta
#68 0 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
15/100
Tipo de issue
Bug
Clareza
Precisa de esclarecimento
Status de atividade
Estagnada
Stack de tecnologia
cpp, python
Domínio
performance

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.

Linguagem predominante
Python
Estrelas
1.2k
Forks
250
Métricas de merge de PRs
Nenhum PR com merge em 30d

Preparar o ambiente

Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de pytorch/extension-cpp

Todas as issues de pytorch/extension-cpp

Issues semelhantes

Mais issues de Python

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.