A question about backward propagation speed in cpp extension in tutorial

Ouverte
#68 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
15/100
Type d'issue
Bug
Clarté
À clarifier
Activité
À l'abandon
Stack technique
cpp, python
Domaine
performance

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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.

Langage dominant
Python
Étoiles
1.2k
Forks
250
Métriques de merge des PR
Aucune PR mergée en 30 j

Préparer son environnement

Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de pytorch/extension-cpp

Toutes les issues de pytorch/extension-cpp

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.