The model quantize component provides mainstream model quantization algorithms for you to compress and accelerate models. This way, high-performance inference can be implemented. This topic describes how to configure the model quantize component and provides an example on how to use the component.

Prerequisites

OSS is activated, and Machine Learning Studio is authorized to access OSS. For more information, see Activate OSS and Grant PAI the permissions to access OSS.

Limits

  • The model quantize component is available only in Machine Learning Designer of Machine Learning Platform for AI.
  • You can use the model quantize component based only on the computing resources of Deep Learning Containers (DLC) of Machine Learning Platform for AI.
  • If an object detection component is configured as an upstream component of the model quantize component, make sure that the model-related configurations and the dataset configurations for the two components are the same.

Configure the component in Machine Learning Designer

  • Input ports
    Input port (left-to-right)Data typeRecommended upstream componentRequired
    Input modelObject Storage Service (OSS)object detection or model pruneNo
    Training dataOSSRead File DataYes
    Test dataOSSRead File DataYes
    Category fileOSSRead File DataYes
  • Component parameters
    TabParameterDescription
    Fields Settingmodel typeThe type of the model to train. Valid values:
    • YOLOX
    • YOLOX_EDGE

    Default value: YOLOX_EDGE.

    oss dir to save modelThe OSS path in which the model and logs are stored during training.
    oss path to training tfrecordThe OSS path of the file that contains the training data. If a Read File Data component is configured as an upstream component of the model quantize component, you do not need to set this parameter.
    oss annotation path for training setThe OSS path of the file that contains the labeling results of the training dataset.
    oss path to evaluation tfrecordThe OSS path of the file that contains the test data. If a Read File Data component is configured as an upstream component of the model quantize component, you do not need to set this parameter.
    oss annotation path for validataion setThe OSS path of the file that contains the labeling results of the test dataset.
    oss path of class list fileThe OSS path of the category file. If a Read File Data component is configured as an upstream component of the model quantize component, you do not need to set this parameter.
    YOLOX data formatThe format of the datasets. Valid values:
    • COCO
    • DetSourcePAI

    Default value: COCO.

    oss path to pretrained modelThe OSS path in which your pre-trained model is stored. If you have a pre-trained model, set this parameter to the OSS path of your pre-trained model. This parameter is optional.
    Parameters SettingYOLOX edge model typeThe type of the YOLOX preset model. This parameter is required only if you set the model type parameter to YOLOX_EDGE on the Fields Setting tab.

    Default value: yolox-customized.

    YOLOX model typeThis parameter is required only if you set the model type parameter to YOLOX on the Fields Setting tab.
    Valid values:
    • yolox-s
    • yolox-m
    • yolox-l
    • yolox-x

    Default value: yolox-s.

    yolox_edge_model_depthThe depth of the YOLOX model. This parameter is required only if you set the model type parameter to YOLOX_EDGE on the Fields Setting tab.

    The value is a floating-point number. Default value: 1.0. Valid values: 0.01 to 1.0.

    yolox_edge_model_widthThe width of the YOLOX model. This parameter is required only if you set the model type parameter to YOLOX_EDGE on the Fields Setting tab.

    The value is a floating-point number. Default value: 1.0. Valid values: 0.01 to 1.0.

    YOLOX edge model activationThe type of the activation function for the YOLOX model. This parameter is required only if you set the model type parameter to YOLOX_EDGE on the Fields Setting tab.
    Valid values:
    • relu
    • lrelu
    • silu
    • hsilu

    Default value: relu.

    test confidence:[0.01,1.0]The confidence level of the test. This parameter is required only if you set the model type parameter to YOLOX_EDGE on the Fields Setting tab.

    The value is a floating-point number. Default value: 0.01. Valid values: 0.01 to 1.0.

    nms threshold:[0.01,1.0]The Non-Maximum Suppression (NMS) threshold. This parameter is required only if you set the model type parameter to YOLOX_EDGE on the Fields Setting tab.

    The value is a floating-point number. Default value: 0.65. Valid values: 0.01 to 1.0.

    num classesThe number of categories.
    image scaleThe resolution of resized images for YOLOX. The value is in the format of Height Width. Default value: 640 640.
    initial learning rateThe initial learning rate for model training. The value is a floating-point number. Default value: 0.01.
    train batch sizeThe size of a training batch. Specifically, this parameter specifies the number of data samples used for training in a single model iteration process. Default value: 16.
    eval batch sizeThe size of an evaluation batch. Specifically, this parameter specifies the number of data samples used for evaluation in a single model iteration process. Default value: 1.
    num epochsThe total number of training epochs. Default value: 20.
    warmup epochsThe number of epochs for the warm-up strategy. Default value: 5.
    last no augmented lr epochsThe number of epochs to complete after the learning rate is stable if the warm-up strategy is used. Default value: 5.
    save checkpoint epochThe interval at which a checkpoint is saved. The interval is measured in epochs. Default value: 1. The default value indicates that a checkpoint is saved every time an epoch is complete.
    Tuningio thread num for trainingThe number of threads that are used to read the training data.
    single worker or distributed on MaxCompute or DLCThe compute engine that is used to run the component. The system automatically sets this parameter based on the type of the training model that you select.
    number of workerThe number of workers used for distributed training. Default value: 1.
    gpu machine typeThe instance type of the GPU-accelerated instance to be used. Default value: 8vCPU+32GB Mem+1xv100-ecs.gn6v-c8g1.2xlarge.

Example

The following figure shows a sample pipeline in which the model quantize component is used. PipelineIn this example, the components are configured by performing the following steps:
  1. Perform data labeling by using iTAG. For more information, see iTAG.
  2. Use the Read File Data-1, Read File Data-2, and Read File Data-3 components to read the training dataset, test dataset, and category file. You can configure the dataset to be read for a Read File Data component by setting the OSS Data Path parameter to the OSS path of the training dataset, test dataset, or category file.
  3. Use the object detection-1 component to create an object detection model.
  4. Use the Read File Data-4, Read File Data-5, and Read File Data-6 components to read the training dataset, test dataset, and category file. You can configure the dataset to be read for a Read File Data component by setting the OSS Data Path parameter to the OSS path of the training dataset, test dataset, or category file.
  5. Connect the object detection-1, Read File Data-4, Read File Data-5, and Read File Data-6 components to the model quantize component and set the component parameters. For more information, see the "Configure the component in Machine Learning Designer" section of this topic.