You need to enable JavaScript to run this app.
Elastic Compute Service

Elastic Compute Service

Copy page
Download PDF
AIGC practices
Deploying optimized WDL inference models on g4i instances
Copy page
Download PDF
Deploying optimized WDL inference models on g4i instances
This topic describes how to deploy and optimize Wide & Deep Learning (WDL) models on ECS instances of the of the ecs.g4i type. By leveraging hardware acceleration, this approach enhances inference efficiency and speeds up the inference process.​
Feature highlights​
This practice uses the 4th-generation ECS instances of Volcano Engine, specifically the General-purpose g4i type. This instance type adopts the latest self-developed DPU architecture of Volcano Engine and is equipped with the 6th-generation Intel® Xeon® Scalable processor (Granite Rapids). This instance type also leverages next-generation hardware AI acceleration instructions: AMX-BF16 and AMX-FP16 (Intel Advanced Matrix Extensions). These features deliver system-level optimization and improve the inference efficiency of WDL models.​
Background​
A WDL model is a hybrid architecture that combines the Wide linear model and the Deep neural network. Primarily used for click-through rate (CTR) prediction, it is widely applied in recommendation systems, search ranking, online advertising, and numerous other fields. In a WDL model, the Wide component primarily processes highly sparse features, which requires minimal computation and is not computationally intensive. Notably, CPUs excel at handling both sparse features and irregular memory access patterns. In small and medium-scale inference scenarios, deploying an optimized WDL inference model on CPU instances delivers better cost-effectiveness than using GPU instances.​
  • Wide model: Excels at memorizing high-frequency feature combinations but lacks the ability to generalize to unseen feature interactions.​
  • Deep model: Generalizes low-frequency features via embedding vectors but exhibits low learning efficiency for high-frequency feature combinations.​
Procedure​
  1. Purchase an ecs.g4i instance. In the example provided in this topic, the following instance configurations are used.​
  • Instance type: ecs.g4i.16xlarge​
  • Image: Ubuntu 22.04 64 bit​
  • Network: an assigned EIP​
  1. Execute the following command to install dependencies.​
  • ​
    apt update​
    apt install docker.io​
    ​
  1. Execute the following command to obtain the WDL model image optimized for the ecs.g4i instance type.​
  • ​
    China (Beijing)
    China (Shanghai)
    China (Guangzhou)
    Asia Pacific (Johor)
    ​
    ​
    wget https://iaas-debug-beijing.tos-cn-beijing.ivolces.com/tool/cpu-serving/saved_model.tar​
    ​
    ​
    ​
  1. (Optional) Modify the batch processing parameter for model inference based on your business requirements. In the example provided in this topic, the default value is used.​
  1. Execute the following command to open the batching_config.txt file.​
  1. Press the i key to enter edit mode, and modify the batch processing parameter based on your business requirements.​
  • ​
    max_batch_size { value: 4096 } ​
    batch_timeout_micros { value: 5000 } ​
    num_batch_threads { value: 64 } ​
    max_enqueued_batches { value: 204800 }​
    ​
  • Parameter descriptions:​
  • max_batch_size: The maximum number of samples per batch. The default value is 4096.​
  • batch_timeout_micros: The batch processing timeout period in microseconds. The default value is 5000.​
  • num_batch_threads: The number of batch processing threads. The default value is 64.​
  • max_enqueued_batches: The maximum number of enqueued batches. The default value is 204800.​
  1. Press the Esc key to exit the edit mode, enter :wq, and then press Enter to save the changes and exit the file.​
  1. Execute the following command to run the image.​
  • ​
    docker run -t --name server \​
    --rm --network host \​
    -v /data00/saved_model:/models/wdl \​
    -v /data:/data \​
    cr-for-diting-nodelete-cn-beijing.cr.volces.com/practice-images/tensorflow-serving:tf2.15-cpu-fp16 \​
    --model_name=wdl \​
    --model_base_path=/models/wdl \​
    --enable_batching=true \​
    --batching_parameters_file=/models/wdl/batching_config.txt \​
    --grpc_channel_arguments=grpc.max_concurrent_streams=5000000 \​
    --enable_profiler=true \​
    --grpc_max_threads=1000 \​
    --rest_api_num_threads=1000 \​
    --mixed_precision=bfloat16​
    ​
tip​
  • Change /data00/saved_model to the actual storage path of the WDL model.​
  • --rest_api_num_threads: Used to specify the maximum number of threads for the REST API service. In the example provided in this topic, this parameter is set to 1000.​
  • --mixed_precision: The mixed precision computation type. When FP16 (float16) or BF16 (bfloat16) is specified as data precision, you can enable the Advanced Matrix Extensions (AMX) instruction set of the CPU to improve inference performance. In the example provided in this topic, this parameter is set to bfloat16.​
  1. Perform a stress test.​
  1. Execute the following command to create a stress test script.​
  • ​
    vim grpc_client.py​
    ​
  1. Press the i key to enter edit mode, and then copy the following content into the script file.​
  • Script content​
    ​
  1. Press the Esc key to exit edit mode, enter :wq, and then press Enter to save and exit the file.​
  1. Execute the following command to perform a stress test.​
  • ​
    python3 grpc_client.py \​
    --request-rate 80 \​
    --duration 30 \​
    --num-requests 6000 \​
    --max-concurrency 90 \​
    --batch-size 2048 \​
    --server 192.168.0.2:8500 ​
    ​
Test conclusion​
This topic demonstrates how to deploy and run a WDL model on an ecs.g4i.16xlarge instance, and provides the maximum throughput of the model before and after AMX acceleration is enabled.​
​
Number of batch processing threads​
Data precision​
​
​
BF16 (AMX acceleration enabled)​
FP32 (AMX acceleration not enabled)​
2,048​
161.23​
16.18​
1,024​
390.91​
86.43​
512​
824.03​
226.61​
​
In scenarios where cost-effectiveness and abundant instance resources are prioritized, you can use instance types equipped with the 6th-generation Intel® Xeon® Scalable processor (Granite Rapids), such as the General-purpose g4i instances, as an alternative to GPU instances. This way, you can obtain the most cost-effective WDL model inference service by leveraging system-level acceleration solutions.​
Last updated: 2026.06.18 17:48:27