Re-engineering for better results: The Huawei AI stack

Huawei’s Advanced AI Learning System: A New Contender in AI Hardware

Huawei has introduced an innovative AI training platform that leverages clusters of Ascend 910C processors interconnected through high-speed optical links. This distributed design enables the system to surpass conventional GPU-based hardware configurations, particularly excelling in resource efficiency and on-chip processing time, despite each Ascend chip individually having lower raw power compared to some competitors.

By launching this cutting-edge framework, Huawei positions itself as a significant competitor to Nvidia’s dominant market presence, even amid ongoing US trade restrictions.

Transitioning AI Workflows: From PyTorch and TensorFlow to MindSpore

Unlike Nvidia’s ecosystem, which primarily revolves around PyTorch and TensorFlow optimized for CUDA, Huawei’s Ascend processors achieve peak performance when paired with MindSpore, a proprietary deep learning framework developed by Huawei. This shift requires data scientists and engineers to adapt their existing models and workflows.

For teams with pre-existing models built in PyTorch or TensorFlow, migrating to MindSpore involves re-engineering efforts. This is necessary because operator implementations differ between frameworks-for example, variations in convolution padding techniques and default weight initialization methods can affect model behavior and training outcomes.

Deploying Models with MindIR: Huawei’s Intermediate Representation Format

MindSpore utilizes MindIR (MindSpore Intermediate Representation), which functions similarly to Nvidia’s NIM format. After training a model in MindSpore, developers can export it into MindIR using the mindspore.export utility. This format facilitates streamlined deployment and inference on Ascend hardware.

Inference typically involves loading the MindIR model and executing predictions through MindSpore’s dedicated APIs, which manage model deserialization, memory allocation, and execution. MindSpore distinctly separates training and inference workflows more explicitly than PyTorch or TensorFlow, necessitating careful alignment of preprocessing steps and optimization of static graph execution.

For enhanced performance tuning, Huawei recommends leveraging resources such as the Ascend Model Zoo, which offers hardware-specific optimizations and pre-trained models.

Understanding CANN: Huawei’s Compute Architecture for Neural Networks

Huawei’s CANN (Compute Architecture for Neural Networks) serves as the foundational software layer for Ascend processors, analogous to Nvidia’s CUDA platform. CANN provides essential tools for profiling, debugging, and optimizing AI models to maximize performance on Ascend hardware.

Developers are encouraged to utilize CANN’s comprehensive suite of utilities to monitor resource usage and fine-tune model execution, ensuring efficient deployment in production environments.

Execution Modes in MindSpore: Balancing Development and Performance

MindSpore offers two distinct execution modes tailored to different stages of AI model development:

  • GRAPH_MODE: This mode compiles the entire computation graph before running, enabling advanced optimizations and faster execution. It is ideal for production deployment where performance is critical.
  • PYNATIVE_MODE: Executes operations immediately, facilitating easier debugging and iterative development. This mode is well-suited for early-stage experimentation and troubleshooting.

For efficient workflow management, developers typically start with PYNATIVE_MODE during model prototyping and switch to GRAPH_MODE for final deployment to harness Ascend hardware’s full capabilities. It is important to adapt code accordingly, avoiding native Python control flows in GRAPH_MODE to ensure compatibility.

Huawei ModelArts: A Comprehensive Cloud Platform for AI Development

Huawei’s ModelArts platform offers an integrated cloud environment designed to streamline the entire AI lifecycle-from data labeling and preprocessing to model training, deployment, and monitoring. Optimized for Ascend processors and MindSpore, ModelArts provides APIs and a user-friendly web interface, making it comparable to services like AWS SageMaker and Google Vertex AI, but with a focus on Huawei’s hardware ecosystem.

This platform enables organizations to accelerate AI projects while maintaining tight integration with Huawei’s AI infrastructure.

Key Considerations for Migrating to Huawei’s AI Ecosystem

Transitioning to MindSpore and CANN requires a learning curve, especially for teams accustomed to Nvidia’s CUDA-based tools. Engineers must familiarize themselves with new compilation processes, optimization techniques, and APIs specific to Ascend hardware. Additionally, existing automation pipelines and tooling may need significant adjustments to accommodate Huawei’s frameworks.

While Huawei’s AI tools are rapidly advancing, they currently lack the extensive maturity and ecosystem support enjoyed by PyTorch and CUDA. Nevertheless, Huawei aims to offer a viable alternative that reduces dependency on US-based Nvidia technology.

It is important to note that Ascend processors have limited availability outside Huawei’s primary markets, which may pose challenges for global teams in testing and deployment. However, partner platforms like ModelArts provide remote access options to mitigate these limitations.

Huawei supports this transition with comprehensive migration guides, technical support, and developer resources to facilitate adoption.

More from this stream

Recomended