This section describes how to use the scripts in the MindIE Motor installation directory (examples/kubernetes_deploy_scripts) to deploy and uninstall a prefill-decode disaggregation cluster on MindIE in one-click mode. The cluster administrator can use Kubernetes kubectl to operate the cluster offline by referring to these scripts.
The cluster administrator only needs to compile the startup script, configure services and Kubernetes on the management node, and then call the deployment script to automatically deliver the service configuration and startup script, generate a global ranktable, and schedule pods to compute nodes.
To ensure that the Coordinator can reliably obtain the memory, the values of memory under the requests and limits fields should be the same (if possible). By default, the recommended memory specifications are as follows:
Maximum memory that can be occupied by the Coordinator = Value of body_limit x Value of max_requests x 120%
Directory structure of scripts:
├── boot_helper
│ ├── boot.sh
│ ├── gen_config_single_container.py
│ ├── get_group_id.py
│ ├── mindie_cpu_binding.py
│ ├── server_prestop.sh
│ └── update_mindie_server_config.py
├── chat.sh
├── conf
├── delete.sh
├── deploy.sh
├── deploy_ac_job.py
├── deployment
│ ├── controller_init.yaml
│ ├── coordinator_init.yaml
│ ├── mindie_ms_controller.yaml
│ ├── mindie_ms_coordinator.yaml
│ ├── mindie_server.yaml
│ ├── mindie_server_heterogeneous.yaml
│ ├── mindie_service_single_container.yaml
│ ├── mindie_service_single_container_base_A3.yaml
│ ├── server_init.yaml
│ └── single_container_init.yaml
├── gen_ranktable_helper
│ ├── gen_global_ranktable.py
│ └── global_ranktable.json
├── generate_stream.sh
├── log.sh
├── user_config.json
├── user_config_base_A3.json
└── utils
├── validate_config.py
└── validate_utils.py
The following table describes the key directories and files for multi-node prefill-decode disaggregation deployment.
Directory/File |
Description |
|---|---|
conf |
Main service configuration file of the cluster management component and Server, which is used to manage scheduling policies and model configurations in the prefill-decode disaggregation scenario. |
boot_helper |
Contains the container startup script boot.sh. It is used to obtain group IDs, update environment variables to the configuration file, and set environment variables of the startup program. You can adjust the log level as required. NOTE:
MindIE depends on the jemalloc.so library file. Do not install invalid SO files with the same name in the /usr/ directory, as this may introduce security risks such as arbitrary command execution. |
deployment |
Defines a Kubernetes deployment task and configures the NPU resource usage, number of instances, and image. |
gen_ranktable_helper |
Tool for generating the global_ranktable.json file. |
chat.sh |
Simple dialog example of using curl to send HTTPS requests to the inference service, which is applicable to the prefix cache scenario. |
generate_stream.sh |
Streaming response example for sending an HTTPS request to the inference service using curl. |
deploy.sh |
Deployment script, which is used to start all MindIE components in one-click mode. |
delete.sh |
Uninstallation script, which is used to uninstall all MindIE components in one-click mode. |
log.sh |
Queries the printed logs of all deployed pods. |
The LLaMA3-8B with four instances is used as an example, each instance configured with two NPUs. The following is a deployment example. Perform the following operations in the deployment script path.
The following steps do not distinguish homogeneous deployment from heterogeneous deployment. For heterogeneous deployment, the corresponding configuration is described separately.
kubectl create namespace mindie
For prefill-decode disaggregation deployment, set deploy_mode to pd_separate.
"deploy_mode": "pd_separate"
If heterogeneous deployment is required, set is_heterogeneous to true.
"is_heterogeneous": true
For prefill-decode disaggregation deployment, set deploy_mode to pd_separate.
"deploy_mode": "pd_separate"
Parameter |
Description |
|---|---|
modelName |
Model name, which is associated with the model weight file, for example, llama3-8b. |
modelWeightPath |
Path of the model weight file. By default, the script is mounted to the /data directory of the physical machine. modelWeightPath must be set to the model weight path in the /data directory to ensure that the cluster can schedule the Ascend compute node's model file existing in this path. |
worldSize |
Number of NPUs occupied by a prefill/decode instance. For example, if this parameter is set to 2, two NPUs are used. |
npuDeviceIds |
NPU ID, starting from 0. The total number of IDs is the same as the value of worldSize, for example, [[0,1]]. |
inferMode |
Set this parameter to dmi. |
tp |
Number of tensor parallel processes on the entire network. This number is the value of worldSize. This parameter is a supplementary parameter and needs to be configured under the ModelConfig field. |
tls_enable specifies whether to enable HTTPS. If the MindIE components in the cluster use the HTTPS interface, set tls_enable to true, import certificates to the container, and configure the corresponding certificate paths. To use the HTTP interface, set tls_enable to false. No certificate file is required.
You are advised to enable tls_enable to ensure communication security. If tls_enable is disabled, high network security risks exist.
Find the mindie_server.yaml, mindie_ms_coordinator.yaml, mindie_ms_controller.yaml, and mindie_server_heterogeneous.yaml (configured only in heterogeneous scenarios) files in the deployment directory among the deployment script directories.
kubectl label node xx_node hardware-type=xx_device
In heterogeneous scenarios, the parameter values must meet the following requirements:
The default value is 1, indicating that logs are written into a file. The value range is [false, true] or [0, 1].
The default value is 1, indicating that logs are printed. The value range is [false, true] or [0, 1].
The default value is INFO. The log levels are [CRITICAL, ERROR, WARN, INFO, DEBUG].
The default value is 1, indicating that logs are written into a file. The value range is [false, true] or [0, 1].
The default value is 1, indicating that logs are printed. The value range is [false, true] or [0, 1].
The default value is INFO. The log levels are [CRITICAL, ERROR, WARN, INFO, DEBUG].
kubectl label node xx_node hardware-type=xx_device2
In heterogeneous scenarios, the parameter values must meet the following requirements:
The default value is 1, indicating that logs are written into a file. The value range is [false, true] or [0, 1].
The default value is 1, indicating that logs are printed. The value range is [false, true] or [0, 1].
The default value is INFO. The log levels are [CRITICAL, ERROR, WARN, INFO, DEBUG].
Environment Variable |
Type |
Description |
|---|---|---|
MINDIE_INFER_MODE |
Prefill-decode disaggregation |
Inference mode, indicating whether prefill-decode disaggregation is enabled.
This environment variable is not included in the default boot.sh script configuration. If required, add it to the script. |
MINDIE_DECODE_BATCH_SIZE |
Public variable |
Maximum decode batch size. Value range: [1, 5000] This environment variable is not included in the default boot.sh script configuration. If required, add it to the script. |
MINDIE_PREFILL_BATCH_SIZE |
Public variable |
Maximum prefill batch size. Value range: [1, MINDIE_DECODE_BATCH_SIZE - 1] This environment variable is not included in the default boot.sh script configuration. If required, add it to the script. |
MINDIE_MAX_SEQ_LEN |
Public variable |
Maximum sequence length. Integer in the range of (0, 4294967295] This environment variable is not included in the default boot.sh script configuration. If required, add it to the script. |
MINDIE_MAX_ITER_TIMES |
Public variable |
Maximum output length. Integer in the range of [1, MINDIE_MAX_SEQ_LEN – 1] This environment variable is not included in the default boot.sh script configuration. If required, add it to the script. |
MINDIE_MODEL_NAME |
Public variable |
Model name. This environment variable is not included in the default boot.sh script configuration. If required, add it to the script. |
MINDIE_MODEL_WEIGHT_PATH |
Public variable |
Path of the model weight file. This environment variable is not included in the default boot.sh script configuration. If required, add it to the script. |
MINDIE_ENDPOINT_HTTPS_ENABLED |
Public variable |
Whether to enable HTTPS on the prefill/decode instance.
This environment variable is not included in the default boot.sh script configuration. If required, add it to the script. |
MINDIE_INTER_COMM_TLS_ENABLED |
Public variable |
Whether to enable TLS for communication between inference instances.
This environment variable is not included in the default boot.sh script configuration. If required, add it to the script. |
HCCL_RDMA_RETRY_CNT |
Public variable |
Number of retransmission times of the RDMA NIC. The value must be an integer ranging from 1 to 7. The default value is 7. |
HCCL_RDMA_TIMEOUT |
Public variable |
Retransmission timeout of the RDMA NIC. The formula for calculating the minimum retransmission timeout of the RDMA NIC is 4.096 μs * 2 ^ timeout. In the formula, timeout is the value of this environment variable, and the actual retransmission timeout is related to the user network status. Set this environment variable to an integer ranging from [5,20]. The default value is 18. |
HCCL_EXEC_TIMEOUT |
Public variable |
Synchronization wait time during task execution between devices. Within this configured time, each device process waits for other devices to perform communication synchronization. This variable is used to set the timeout interval of the first token. The value range is [0, 2147483647], in seconds. The default value is 60. The value 0 indicates that there is no timeout. |
HSECEASY_PATH |
Public variable |
Path of the dependency library of the KMC decryption tool. |
MINDIE_MS_CONTROLLER_CONFIG_FILE_PATH |
Public variable |
Configuration file path of the Controller component. |
MINDIE_MS_COORDINATOR_CONFIG_FILE_PATH |
Public variable |
Configuration file path of the Coordinator component. |
Note: For details about log-related environment variables, see Log Configuration. |
||
Configure the MindIE installation directory in the container. Change the value of MINDIE_USER_HOME_PATH based on the actual installation path during image creation. For example, if the installation path is /xxx/Ascend/mindie, set the value to /xxx.
export MINDIE_USER_HOME_PATH={Image installation path}
Before starting the service, you are advised to use the pre-check tool of MindStudio to verify the fields in the configuration file and check the validity of the configuration. For details, see Link.
Run the following command to start the cluster:
bash deploy.sh
After the command is executed, wait until global_ranktable.json is generated. If the generation is blocked for a long time, press Ctrl+C to interrupt the process, and check the pod status of the cluster for debugging.
The following is an example of global_ranktable.json. For details about the parameters, see Table 4.
{
"version": "1.0",
"server_group_list": [
{
"group_id": "2",
"server_count": "2",
"server_list": [
{
"server_id": "xxx.xxx.xxx.1",
"server_ip": "xxx.xxx.xxx.1",
"device": [
{
"device_id": "0",
"device_ip": "xxx.xxx.xxx.1",
"device_logical_id": "0"
}
],
"hardware_type": "800I A2(32G)"
},
{
"server_id": "xxx.xxx.xxx.2",
"server_ip": "xxx.xxx.xxx.2",
"device": [
{
"device_id": "1",
"device_ip": "xxx.xxx.xxx.2",
"device_logical_id": "1"
}
],
"hardware_type": "800I A2(64G)"
}
]
},
{
"group_id": "1",
"server_count": "1",
"server_list": [
{
"server_id": "xxx.xxx.xxx.1",
"server_ip": "xxx.xxx.xxx.1"
}
]
},
{
"group_id": "0",
"server_count": "1",
"server_list": [
{
"server_id": "xxx.xxx.xxx.1",
"server_ip": "xxx.xxx.xxx.1"
}
]
}
],
"status": "completed"
}
Parameter |
Type |
Description |
|---|---|---|
version |
String |
Version number of Ascend Operator. |
status |
String |
Cluster information status.
|
group_id |
String |
ID of each component.
|
server_count |
String |
Total number of nodes of each component. |
server_list |
JSON object array |
Node deployment information of each component.
|
server_id |
String |
Node host IP address of a component. |
server_ip |
String |
Node IP address of a component. |
device |
JSON object array |
NPU device information. Only Server has this attribute. The valid list length is [1, 128]. |
device_id |
String |
NPU device ID. |
device_ip |
String |
NPU IP address. |
device_logical_id |
String |
Logical ID of the NPU, that is, the sequence ID of the visible device in the pod where Server is located. |
hardware_type |
String |
Hardware type. This attribute is available only in heterogeneous mode.
|
syncFrequency: 5s
Restart kubelet:
swapoff -a systemctl restart kubelet.service systemctl status kubelet
After modifying the Docker configuration file on the compute node where the service is to be deployed, restart Docker.
vim /etc/docker/daemon.json
"log-opts":{"max-size":"500m", "max-file":"3"}
Parameters:
max-size=500m indicates that the maximum size of a container log file is 500 MB.
max-file=3 indicates that a container has a maximum of three log files. If the number of log files exceeds three, the log files are automatically rotated.
systemctl daemon-reload systemctl restart docker
To enable heterogeneous cluster inference, run the following command:
bash deploy.sh heter
kubectl get pods -n mindie
For example, if four Server instances are started, the following information is displayed:
1 2 3 4 5 6 7 | NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES mindie-ms-controller-7845dcd697-h4gw7 1/1 Running 0 145m xx.xx.xx.xx ubuntu10 <none> <none> mindie-ms-coordinator-6bff995ff8-l6fwz 1/1 Running 0 145m xx.xx.xx.xx ubuntu10 <none> <none> mindie-server-7b795f8df9-2xvh4 1/1 Running 0 145m xx.xx.xx.xx ubuntu <none> <none> mindie-server-7b795f8df9-j4z7d 1/1 Running 0 145m xx.xx.xx.xx ubuntu <none> <none> mindie-server-7b795f8df9-v2tcz 1/1 Running 0 145m xx.xx.xx.xx ubuntu <none> <none> mindie-server-7b795f8df9-vl9hv 1/1 Running 0 145m xx.xx.xx.xx ubuntu <none> <none> |
If the pod is in the Running status, the pod container has been successfully scheduled to a node and started. However, you need to further check whether the service program is started successfully.
bash log.sh
If heterogeneous cluster inference is configured, run the following command:
bash log.sh heter
kubectl logs mindie-server-7b795f8df9-vl9hv -n mindie
kubectl exec -it mindie-server-7b795f8df9-vl9hv -n mindie -- bash
kubectl logs mindie-ms-controller-7845dcd697-h4gw7 -n mindie | grep UpdateServerInfo
After the pod IP addresses of the prefill and decode nodes are queried, you can find the corresponding pods based on the IP addresses in the command output of the preceding command for querying the pod status.
bash generate_stream.sh
bash delete.sh mindie ./