Welcome to ModelZoo-PyTorch

English | 简体中文

Introduction

ModelZoo-PyTorch provides training model references adapted for Ascend devices, covering common AI tasks such as computer vision, natural language processing, speech, multimodality, and recommendation. The models in the repository typically include environment setup, dataset and pre-trained weights preparation, training scripts, and result descriptions, serving as a reference for developers to get started, validate, and migrate PyTorch models in the Ascend training environment. We will continue to add more representative networks and pre-trained models. If you have any needs or suggestions during use, feel free to submit an issue at ModelZoo-PyTorch/issues.

How to Contribute

Please read CONTRIBUTING_TRAIN before getting started with contributions. Thank you!

Version Notes

The version compatibility may vary across different models. It is recommended to use the version specified in the documentation of each model under the Maintenance Policy. If you wish to experience the latest version of Ascend, please refer to Latest Version Compatibility.

Quick Start

To get started with ModelZoo-PyTorch, follow the Quick Start guide and try the BERT-SQuAD example. This example uses BERT-base for reading comprehension on SQuAD v1.1 and covers environment setup, dataset and vocabulary preparation, pre-trained weights, and training scripts, making it a suitable reference for first-time users.

We recommend following the steps below:

  1. Follow the Installation Guide to install the base environment, including PyTorch, TorchNPU, and CANN.
  2. Navigate to the PyTorch/built-in/nlp/Bert-Squad_ID0470_for_PyTorch directory and install the model dependencies as described in the Quick Start guide.
  3. Create a v1.1 directory under the model directory, prepare the SQuAD v1.1 dataset and vocabulary (saved as vocab.txt) as described in the Quick Start guide, and obtain the bert_base.pt pre-trained weights.
  4. Run train_base_full_1p.sh or train_base_full_8p.sh in the test directory for single-node training with one or eight devices.

Through this use case, you can quickly become familiar with the model directory organization, dependency installation methods, and standard training workflow in ModelZoo-PyTorch. After completing the trial, you can choose other models for your specific scenarios.

Model Training

  1. ModelZoo-PyTorch contains various model use cases, and different models may differ in environment dependencies, dataset preparation, pre-trained weight acquisition, and training script usage. Therefore, for model training, please follow the instructions in the README.md file within each model directory.
  2. We recommend you to select a model to experience or train from the Models Evolving with Versions list below, click the corresponding link to enter the model directory, and then complete model training according to the model documents.

Model Migration and Tuning

You can perform model migration, precision debugging, and performance tuning by referring to the PyTorch Training Model Migration and Tuning Guide.

Maintenance Policy

💡 Models in ModelZoo-PyTorch are categorized into version-evolving models and non-version-evolving models.

  • For models that evolve with releases: please see the version compatibility table and choose the latest version for use.
  • For models that do not evolve with releases: these models no longer track the version evolution of PyTorch and PyTorch Extensions. You may choose the following strategies:
    • Select the corresponding PyTorch, PyTorch Extension, CANN, and HDK versions as specified in the model's README.
    • If you have a requirement to adapt this model to newer versions of PyTorch, PyTorch Extension, CANN, or HDK, please feel free to submit an issue at modelzoo/issues. We will address it in a timely manner.

Scope Definition

Models Evolving with Versions

See Version-Evolving Models.

Models Not Evolved with Versions

Except for the version-evolving models, all other models in ModelZoo-PyTorch are classified as models not evolved with versions.

Security Statement

Running User Recommendations

For security and the principle of least privilege, it is not recommended to use administrator-type accounts such as root.

File Permission Control

  1. It is recommended that users set the system umask value to 0027 or higher on the host (including the physical machine) and in containers, ensuring that the default maximum permission for newly created folders is 750 and for newly created files is 640.

  2. It is recommended that users properly manage permissions for sensitive content such as personal data, business assets, source files, and various files saved during training. Permission control can be configured by referring to Table 1.

    Table 1 Recommended maximum permission settings for files (folders) in various scenarios

    Type Maximum Linux Permission
    User home directory 750 (rwxr-x---)
    Program files (including script files, library files, etc.) 550 (r-xr-x---)
    Program file directories 550 (r-xr-x---)
    Configuration files 640 (rw-r-----)
    Configuration file directories 750 (rwxr-x---)
    Log files (recording completed or archived) 440 (r--r-----)
    Log files (currently recording) 640 (rw-r-----)
    Log file directories 750 (rwxr-x---)
    Debug files 640 (rw-r-----)
    Debug file directories 750 (rwxr-x---)
    Temporary file directories 750 (rwxr-x---)
    Maintenance and upgrade file directories 770 (rwxrwx---)
    Business data files 640 (rw-r-----)
    Business data file directories 750 (rwxr-x---)
    Key components, private keys, certificates, and ciphertext file directories 700 (rwx------)
    Key components, private keys, certificates, and encrypted ciphertext 600 (rw-------)
    Encryption/decryption interfaces and encryption/decryption scripts 500 (r-x------)

Runtime Safety Statement

It is recommended that you write training scripts that match the available resources of the runtime environment. If the training script does not align with the resource constraints — for example, dataset loading memory exceeding the memory capacity limit, or training scripts generating local data that exceeds disk space — errors may occur and cause unexpected process termination.

Public Network Address Statement

For details, see public_address_statement.md in each model directory.

Disclaimer

To ModelZoo Users

  1. The models provided by ModelZoo are intended solely for your non-commercial use.
  2. For each model, ModelZoo only suggests datasets that may be used for training. Huawei does not provide any datasets. If you use these datasets for training, please ensure that you comply with the corresponding dataset licenses. If any infringement disputes arise from your use of the datasets, Huawei assumes no liability.
  3. If you encounter any issues (including but not limited to functional or compliance issues) while using ModelZoo models, please submit an issue on GitCode. We will review and address it in a timely manner.

To Dataset Owners

If you do not wish for your dataset to be mentioned in the models within ModelZoo, or if you wish to update the description of your dataset in the models within ModelZoo, please submit an issue on GitCode. We will remove or update your dataset description in accordance with your issue request. We sincerely appreciate your understanding and contributions to ModelZoo.

License Statement

For models provided in Ascend ModelZoo, if a license exists in the model directory, that license shall prevail. If no license exists in the model directory, the model is licensed under the Apache 2.0 license, and the corresponding license text can be found in the root directory of Ascend ModelZoo.