# caas-cli **Repository Path**: du0898/caas-cli ## Basic Information - **Project Name**: caas-cli - **Description**: 为什么需要 CaaS? 随着美国对 NVIDIA 高端芯片出口管制持续升级,国产 AI 芯片(昇腾、寒武纪、海光等)正在加速替代。然而,迁移成本是摆在每个团队面前的现实问题: 🐌 人工迁移一个中等规模项目需要 数周到数月 🧩 CUDA 与国产芯片之间的算子不兼容,API 差异巨大 📉 迁移后性能回退,缺乏诊断手段 📚 新硬件 SDK(CANN、Neuware、DTK)学习曲线陡峭 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2026-07-21 - **Last Updated**: 2026-07-28 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # CaaS — CUDA as a Service **Migrate your CUDA code to domestic AI chips in minutes, not months.** [![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/) [![License](https://img.shields.io/badge/license-Apache%202.0-green.svg)](LICENSE) --- ## The Problem NVIDIA GPU export controls are accelerating the shift to domestic AI chips — but migration is painful: - 🐌 Manual code conversion takes **weeks to months** - 🧩 Operator incompatibilities between CUDA and domestic platforms - 📉 Performance regression with no clear diagnosis path - 📚 Steep learning curve for new hardware SDKs (CANN, Neuware, DTK) ## The Solution **CaaS** is an open-source CLI tool that automatically analyzes and converts CUDA code for domestic AI chip platforms. It provides: | Feature | Description | |---------|-------------| | 🔍 **Static Analysis** | Parse CUDA / PyTorch source, identify all operators and APIs | | 🔄 **Auto Conversion** | Generate equivalent code for Ascend CANN, Cambricon BANG C, Hygon HIP | | 📊 **Compatibility Report** | Instant compatibility assessment with actionable migration guidance | | 📝 **Code Skeletons** | Auto-generate Ascend C kernel stubs for unsupported operators | ## Quick Start ### Installation ```bash pip install caas-cli ``` ### 1. Analyze a PyTorch Model ```bash caas analyze model.py --target ascend ``` Output: ``` ╔══════════════════════════════════════════════════════════╗ ║ CaaS Migration Analyzer v0.1.0 ║ ║ Target: Huawei Ascend 910B (CANN 7.0) ║ ╠══════════════════════════════════════════════════════════╣ ║ File: model.py ║ ║ Model: ResNet18 ║ ║ Total Operators: 18 ║ ║ ║ ║ ✅ Direct Map: 15 (83.3%) ║ ║ ⚠️ Decompose: 2 (11.1%) ║ ║ 🔧 Fallback: 1 (5.6%) ║ ║ ❌ Unsupported: 0 (0.0%) ║ ║ ║ ║ Compatibility: 83.3% ║ ║ Pattern: ResNet-like CNN ║ ╚══════════════════════════════════════════════════════════╝ ``` ### 2. Convert CUDA Source Code ```bash caas convert kernel.cu --target cann --output kernel_cann.cpp ``` Automatically maps: - `cudaMalloc` → `aclrtMalloc` - `cudaMemcpy` → `aclrtMemcpy` - `<<>>` → `aclLaunchKernel` - cuBLAS → ACL NN equivalents - And 100+ more API mappings ### 3. Generate Markdown Report ```bash caas analyze model.py --target ascend --output report.md ``` ## Supported Targets | Chip | Vendor | Software Stack | Status | |------|--------|---------------|--------| | Ascend 910B | Huawei | CANN 7.0 | ✅ Full support | | MLU 590 | Cambricon | Neuware 5.0 | ✅ Full support | | DCU K100 | Hygon | DTK 22.10 | ✅ Full support | ## How It Works ``` ┌─────────────┐ ┌──────────────┐ ┌─────────────────┐ ┌──────────────┐ │ CUDA/C++ │────▶│ CUDA Parser │────▶│ Operator Mapper │────▶│ Code Generator│ │ /PyTorch │ │ (AST/Regex) │ │ (3-chip DB) │ │ (CANN/BANG) │ └─────────────┘ └──────────────┘ └─────────────────┘ └──────────────┘ │ │ │ ▼ ▼ ▼ ┌──────────────┐ ┌─────────────────┐ ┌──────────────┐ │ Source Info │ │ Compatibility │ │ Converted │ │ (functions, │ │ Report + Risk │ │ Source Code │ │ APIs, etc) │ │ Assessment │ │ + Stubs │ └──────────────┘ └─────────────────┘ └──────────────┘ ``` ## CLI Reference ```bash # Analyze PyTorch model compatibility caas analyze --target {ascend,cambricon,hygon} [--output report.md] # Convert CUDA source to target framework caas convert --target {cann,bang,hip} [--output converted.cpp] # Show supported chips and mappings caas info # Show version caas --version ``` ## Development ```bash git clone https://github.com/caas-cli/caas.git cd caas pip install -e ".[dev]" pytest ``` ## Roadmap - [ ] Support for Kunlun Xin (BiSheng) - [ ] ONNX model import and conversion - [ ] Performance profiling integration - [ ] Batch conversion for large codebases - [ ] Interactive migration wizard ## License Apache License 2.0. See [LICENSE](LICENSE).