ascendc-localtensor-subviews

Diagnose and fix illegal LocalTensor subview offsets causing UB out-of-bounds errors in AscendC kernels.

6|1|Updated Apr 19, 2026
One-click install
npx skills add https://github.com/xchang1121/op-autoresearch --skill ascendc-localtensor-subviews-xchang1121
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: ascendc-localtensor-subviews
Source: https://github.com/xchang1121/op-autoresearch/tree/main/skills/ascendc/fundamentals/ascendc-localtensor-subviews
Command: npx skills add https://github.com/xchang1121/op-autoresearch --skill ascendc-localtensor-subviews-xchang1121

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? AscendC kernel developers frequently hit runtime UB out-of-bounds errors (errno 507035, VEC instruction error) because LocalTensor subview offsets computed at runtime are silently accepted by the compiler but rejected by vector intrinsics at execution. This Skill documents the compile-time offset invariant, legal subview sources, and safe rewrite patterns for multi-row batching and per-row processing. ## Core Features & Use Cases - Subview legality rules: Distinguishes compile-time constant offsets (constexpr, macros, unrolled loops) from illegal runtime offsets (tiling fields, block_idx, loop variables) for vector intrinsic operands. - Batched per-row rewrite patterns: Provides three legal alternatives for softmax/layernorm/RMSNorm batching: per-row Alloc/Free cycles, WholeReduceMax with mask/repeatTimes over flattened rows, and compile-time fixed batch sizes. - UB aliasing and failure diagnosis: Explains non-overlap requirements for intrinsic operands and maps symptoms (errno 507035, NaN corruption, flaky results) to root causes. - Use Case: When a batched softmax kernel crashes with 'ub address out of bounds' after introducing inLocal[r * paddedD], use this Skill to rewrite the loop with per-row queue cycles or a single WholeReduceMax call with repeatTimes. ## Quick Start Ask the assistant to review your AscendC kernel for illegal LocalTensor subviews and rewrite any runtime-offset slicing into the safe per-row or repeat-based patterns.

Frequently Asked Questions about ascendc-localtensor-subviews

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

FAQPage Schema
Why does my AscendC kernel fail with errno 507035 ub address out of bounds?▼

Errno 507035 occurs when a vector intrinsic receives a LocalTensor subview whose offset is a runtime variable, such as a tiling field, block_idx, or loop index. Vector intrinsics require compile-time known UB start addresses, so rewrite the code using per-row Alloc/Free cycles or repeat-based intrinsics.

How do I process multiple rows in one AscendC kernel launch?▼

Use WholeReduceMax or similar intrinsics with mask and repeatTimes so the hardware iterates over rows in a flattened buffer, avoiding any subview. Alternatively, run a full Alloc/EnQue/DeQue/Free cycle per row so each tensor starts at UB offset zero.

Which LocalTensor subview offsets are legal in AscendC?▼

Only compile-time constant offsets are legal: constexpr values, template parameters, macros, and indices from fully unrolled constant-bound loops. Offsets derived from tiling struct fields, GetBlockIdx(), or runtime loop variables compile fine but trigger UB out-of-bounds at execution.

Can vector intrinsic inputs and outputs overlap in UB memory?▼

No, source and destination operands of vector intrinsics must not overlap in UB. Overlap produces silent data corruption that surfaces later as NaN or precision errors rather than a compile-time or runtime fault.

Why does my AscendC kernel pass on one shape but fail on another?▼

A runtime-offset subview can appear to work when the offset happens to be zero for certain shapes, then fail when the offset becomes nonzero. Replace the pattern with per-row queue cycles or a repeat-based intrinsic to make behavior shape-independent.