triton-ascend-reduce

Optimize reduce-style operators on Ascend hardware with two-stage delayed reduction.

258|48|Updated Jun 22, 2020
One-click install
npx skills add https://github.com/mindspore-ai/akg --skill triton-ascend-reduce-mindspore-ai
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: triton-ascend-reduce
Source: https://github.com/mindspore-ai/akg/tree/main/akg_agents/python/akg_agents/op/resources/skills/triton-ascend/guides/triton-ascend-reduce
Command: npx skills add https://github.com/mindspore-ai/akg --skill triton-ascend-reduce-mindspore-ai

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This guide helps developers optimize reduce-style operators on Ascend devices by avoiding costly per-iteration reductions and enabling efficient multi-dimensional reductions in kernel code.

Core Features & Use Cases

  • Delayed reduction pattern: accumulate with per-element operations inside the loop and perform a single final reduction, improving throughput for reductions like sum, max, min, softmax, and layernorm.
  • Multi-dimensional indexing without host-side permute/reshape: operate directly on tensors with non-last-dimension reductions using in-kernel indexing.
  • Two-stage reduction workflow: stage 1 computes intermediate statistics or partial results, stage 2 applies normalization or final reduction, ensuring correctness and performance across B, F, D1, D2 shapes.

Quick Start

Follow the two-stage delayed-reduction approach in your kernel to outperform standard reduce operations.

Frequently Asked Questions about triton-ascend-reduce

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I optimize reduce ops on Ascend when the reduction dimension is not the last axis?▼

Optimize reduce ops on Ascend by using in-kernel multi-dimensional indexing to operate directly on non-last-dimension tensors, bypassing costly host-side permute or reshape operations.

Why does my Triton kernel slow down from frequent tl.sum calls during large-tensor normalization?▼

Frequent tl.sum calls slow down large-tensor normalization by triggering per-iteration reductions. Implement a delayed reduction pattern to accumulate per-element operations and perform a single final reduction.

What's the best way to handle multi-axis reductions in Triton for mixed-precision pooling tasks?▼

The best way to handle multi-axis reductions for mixed-precision pooling is a two-stage reduction workflow, where stage 1 computes intermediate statistics and stage 2 applies final normalization.

Can I use PyTorch normalization semantics for multi-axis reductions directly in Ascend kernels?▼

Yes, you can satisfy PyTorch normalization semantics for multi-axis reductions in Ascend kernels by combining delayed accumulation with a two-stage reduction workflow across B, F, D1, D2 shapes.

Does the delayed reduction pattern work for both softmax and layernorm operators on Ascend?▼

Yes, the delayed reduction pattern works for softmax and layernorm operators on Ascend by accumulating per-element operations inside the loop and executing a single final reduction to improve throughput.