weixin_62994174/General-Purpose-Audio
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

GPA-0.3B-preview (Ascend NPU Adapted)

Model Overview

GPA (General Purpose Audio) is a unified autoregressive transformer that combines three core speech tasks — Automatic Speech Recognition (ASR), Text-to-Speech (TTS), and Voice Conversion (VC) — into a single 0.31B parameter model based on the Qwen3 architecture. This repository provides the model adapted for Huawei Ascend 910 NPU.

  • Original Model: AutoArk/GPA
  • Architecture: Qwen3ForCausalLM (28 layers, 512 hidden, 16 attn heads, GQA)
  • Parameters: 0.31B
  • Tasks: ASR (Speech-to-Text), TTS (Text-to-Speech), VC (Voice Conversion)

Model Specs

AttributeValue
Parameters0.31B
ArchitectureQwen3ForCausalLM
Layers28 (full attention)
Hidden Size512
Intermediate Size3072
Attention Heads16 (8 KV heads, GQA)
Vocab Size180,445
Max Position Embeddings32,768
Precision (inference)float32 / bfloat16
Languageen, zh

NPU Adaptation

Hardware Environment

ComponentVersion/Model
NPUAscend 910 (2 cards)
CANN8.5.1
torch2.9.0
torch_npu2.9.0.post1
transformers4.57.6
Python3.11.14

Adaptation Details

  1. Device Migration: Model weights and computation moved to NPU via model.to(torch.device("npu:0")) using torch_npu
  2. Precision: float32 used for accuracy validation; bfloat16 used for inference throughput
  3. HuggingFace Compatible: Model loaded via AutoModelForCausalLM.from_pretrained() with trust_remote_code=True
  4. Custom Modeling: GPA uses custom modeling_qwen3.py and configuration_qwen3.py from the original checkpoint

Accuracy Evaluation

Methodology

NPU (float32) output logits are compared against CPU (float32) baseline across 8 diverse prompts. The comparison uses 4 complementary metrics:

  • Relative L2 Error: ||NPU - CPU||_2 / ||CPU||_2 * 100%
  • Cosine Similarity: Directional alignment of output vectors
  • Top-1 Accuracy: Whether NPU and CPU select the same next token
  • Top-5 Overlap: Overlap in the 5 highest-probability tokens

Results Summary

MetricValueThresholdStatus
Relative L2 Error0.0068%< 1.0%PASS
Cosine Similarity0.99998> 0.99PASS
Top-1 Accuracy100.0% (8/8)> 99%PASS
Top-5 Overlap5.0/5> 4/5PASS

Per-Prompt Detail

#Prompt (truncated)rel_L2 (%)cos_simtop1top5
0Hello, how are you doing today?0.00521.000095OK5/5
1The capital of France is Paris.0.00090.999924OK5/5
2Once upon a time in a land far away,0.00590.999999OK5/5
3Artificial intelligence is the future of0.03340.999993OK5/5
4The speed of light in vacuum is approx0.00070.999927OK5/5
5Machine learning models can be used for0.00640.999933OK5/5
6In recent years, deep learning has0.00121.000045OK5/5
7The most important thing in science is0.00050.999941OK5/5

Verdict: PASS — NPU inference is numerically equivalent to CPU baseline. All 8 prompts achieve perfect top-1 token match and top-5 overlap, with relative L2 error well below the 1% threshold at 0.0068%.

Performance Benchmark

Test Configuration

  • Device: Ascend 910 NPU (single card)
  • Precision: bfloat16
  • Max new tokens: 128 per generation
  • Iterations: 10 (after 2 warmup)
  • Decoding: Greedy (do_sample=False, temperature=1.0)

Results

MetricValue
Throughput26.1 tok/s
Avg Latency (128 tok)4.904 s
Median Latency4.874 s
P99 Latency5.287 s
Min Latency4.638 s
Max Latency5.314 s
NPU Memory (allocated)618.1 MB
NPU Memory (reserved)680.0 MB
Model Load Time1.9 s

Analysis

  • The model loads in under 2 seconds and fits comfortably in < 700 MB of NPU memory
  • Latency is stable with only 0.68s spread between min and max across 10 runs
  • P99 latency (5.29s) is only 8% above average (4.90s), indicating consistent performance
  • At 26.1 tok/s, the model can generate ~1,500 tokens per minute on a single NPU

Quick Start

1. Install Dependencies

pip install modelscope transformers torch torch_npu

2. Download Model

modelscope download --model AutoArk/GPA --local_dir ./GPA_model

3. Run Inference

import torch
import torch_npu
from transformers import AutoModelForCausalLM, AutoTokenizer

MODEL_DIR = "./GPA_model"
device = torch.device("npu:0")

model = AutoModelForCausalLM.from_pretrained(
    MODEL_DIR,
    torch_dtype=torch.bfloat16,
    trust_remote_code=True,
).to(device)
model.eval()

tokenizer = AutoTokenizer.from_pretrained(MODEL_DIR, trust_remote_code=True)

inputs = tokenizer("Hello, who are you?", return_tensors="pt").to(device)
outputs = model.generate(**inputs, max_new_tokens=128)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))

CLI Inference

# Text generation
python inference.py --task text --prompt "Hello!" --max_new_tokens 128

# Accuracy validation (NPU vs CPU)
python inference.py --task accuracy

# Performance benchmark
python inference.py --task benchmark --num_iters 10

# Full evaluation (accuracy + benchmark + demo)
python inference.py --task full --output eval_results.json

File Structure

.
├── inference.py              # NPU inference script (text/accuracy/benchmark/memory/full)
├── README.md                 # This documentation
├── results_accuracy.json     # Accuracy evaluation results (JSON)
├── results_benchmark.json    # Performance benchmark results (JSON)
├── results_text.json         # Text generation results (JSON)
└── GPA_model/               # Model files (downloaded from ModelScope)
    ├── config.json
    ├── model.safetensors
    ├── modeling_qwen3.py
    ├── configuration_qwen3.py
    ├── tokenizer.json
    ├── tokenizer_config.json
    ├── vocab.json
    ├── merges.txt
    ├── generation_config.json
    ├── chat_template.jinja
    ├── special_tokens_map.json
    ├── added_tokens.json
    ├── BiCodec/
    │   ├── config.json
    │   ├── model.safetensors
    │   └── wav2vec2-large-xlsr-53/
    └── glm-4-voice-tokenizer/
        ├── config.json
        ├── model.safetensors
        └── preprocessor_config.json

Limitations

  1. Text generation only: The current adaptation focuses on the LLM backbone (Qwen3ForCausalLM). Full audio pipeline (ASR/TTS/VC) with BiCodec and voice tokenizer requires the original GPA inference scripts
  2. Single NPU: Benchmarks run on a single Ascend 910 card; multi-NPU inference not tested
  3. bfloat16 inference: Production inference uses bfloat16 for optimal throughput; float32 is used for accuracy validation

Citation

@misc{gpa2026,
  title={Unifying Speech Recognition, Synthesis and Conversion with Autoregressive Transformer},
  author={Runyuan Cai, Yu Lin, Yiming Wang, Chunlin Fu and Xiaodong Zeng},
  year={2026},
  howpublished={\url{https://github.com/AutoArk/GPA}},
}

License

Apache License 2.0


Adapted for Ascend NPU on 2026-05-16