All Products
Search
Document Center

Platform For AI:Use custom components

Last Updated:Jun 20, 2026

You can create custom components for specific use cases and use them in PAI-Designer to train models. This topic shows how to use custom components in PAI-Designer with an example of a PyTorch-based component whose code is stored in an OSS bucket.

Limitations

In PAI-Designer, you can run custom components only on the public resource group for general-purpose training.

Prerequisites

You have uploaded your execution code to an OSS bucket. For instructions, see Upload files. This example uses the sample code files main.py and requirements.txt.

Procedure

  1. Create a PyTorch-based custom component.

    Create a PyTorch-based custom component on the Create Component page. For detailed steps and more parameter configurations, see Create a custom component. The key configurations for this example are as follows.

    • Execution configuration

      Parameter

      Description

      Job type

      Select PyTorch.

      Image

      Select the Community Image pytorch-training:1.12-cpu-py39-ubuntu20.04.

      Execution code

      Set this to the OSS bucket path that contains your entrypoint files (main.py and requirements.txt).

      Command

      Set this to: python main.py $PAI_USER_ARGS --train $PAI_INPUT_TRAIN --test $PAI_INPUT_TEST --model $PAI_OUTPUT_MODEL --checkpoints $PAI_OUTPUT_CHECKPOINTS && echo "job finished".

    • Configure the following pipeline and parameter constraints: the range for param1 is [1,10], the range for param2 is (0,1), the enumerated values for param3 are test1/test2/test3, and the enumerated values for param5 are 1/2/4/8.

      Parameter

      Description

      Input

      Click image..png to configure two input pipelines:

      • Set Input name to train and test, respectively.

      • Set Input source to OSS.

      • Set Required to Yes and No, respectively.

      • Set Description to training data and test data, respectively.

      Output

      Click image..png to configure two output pipelines:

      • Set Output Name to model and checkpoints, respectively.

      • Set Storage to OSS.

      • Set Required to Yes.

      • Set Description to model data and algorithm checkpoints, respectively.

      Arguments

      Click image..png to configure five parameters:

      • Set Parameter Name to param1, param2, param3, param4, and param5, respectively.

      • Set Type to Int, Float, String, Bool, and Int, respectively.

      • Set Default Value to 6, 0.3, test1, true, and 2, respectively.

      • Constraint configuration: Click Constraints next to the default value to configure constraints for each parameter.

      • Set Required to Yes, Yes, Yes, No, and No, respectively.

    • Training constraints

      Parameter

      Description

      Enable training constraints

      Turn on the Enable Training Constraints switch.

      Instance type

      Select CPU and GPU.

      Support multiple instances

      Select Supported.

      Support multiple GPUs

      Select Not Supported.

  2. Create a blank workflow and double-click its name to open the workflow page. For details, see Create a workflow: Blank workflow.

  3. The component in this example is named component. You can use it like any built-in PAI-Designer algorithm component. Drag component(1.0) from the Custom Components directory in the component list to the canvas. The component's Parameter Settings panel opens on the right, displaying the configured parameters and their visual controls.

    Once created, the custom component appears in the algorithm tree for the current workspace in PAI-Designer.

    • PAI-Designer converts the input and output pipelines of the custom component into its input and output ports. After you drag it onto the canvas, the component displays input ports for training data and test data at the top, and output ports for model data and algorithm checkpoints at the bottom.

    • PAI-Designer converts the custom component's parameters into visual controls in the parameter settings panel on the right. Integer parameters, such as param1 (range [1,10], default value 6), appear as input boxes with range constraints. Floating-point parameters, such as param2 (range (0,1), default value 0.3), behave similarly. Enumerated parameters, such as param3 and param5, become drop-down lists. Boolean parameters, such as param4, appear as checkboxes. The panel also includes optional OSS path inputs for the model data and checkpoints, along with the OSS RAM role authorization status.

    • Each output pipeline corresponds to an OSS directory selection control for specifying an output path. For example, the model (model data) and checkpoints (algorithm checkpoints) output pipelines each have a dedicated OSS path input box in the output configuration section of the component's parameter panel.

    • PAI-Designer converts the custom component's training constraints into execution tuning settings. After selecting the custom component node on the canvas, click the Tuning tab in the properties panel on the right. You can then configure execution parameters such as the resource group (for example, the public resource group), instance type (CPU or GPU), number of instances, and maximum runtime (seconds).

If the custom component no longer suits your requirements, you can update its configuration or add a new version from the component list page. For more information, see Manage custom components.