← Hackathons

IndexedSparseAttention

Single-card indexed sparse attention: repeated indices count separately; all-invalid rows produce zeros

Operator definition

o = softmax(q dot k[idx] / sqrt(D), valid only) @ v[idx]

Interface

indexed_sparse_attention(Tensor q, Tensor k, Tensor v, Tensor idx) -> Tensor o

Data ranges

q:[Qn,D],k:[S,D],v:[S,Dv],idx:[Qn,R],o:[Qn,Dv]; Qn=1..1048576,S=1..16777216,R=1..4096,D,Dv in {64,128,256,512}

Single-die stress scale

One physical die only (nominal 64 GiB HBM). Functional cases remain small and exhaustive; the independent three-tier stress suite exercises large bandwidth, compute and random-access workloads. Input + output tensors must total <=48 GiB, candidate workspace <=8 GiB; reserve >=8 GiB for runtime. Shape bounds are not a Cartesian guarantee: combinations exceeding the byte budget are invalid. Pressure correctness compares complete offline binary standards outside timing. Public stress runs are debugging only; formal pressure scoring starts only after all functional checks pass. Host wall time includes CPU work, dispatch and device synchronization, not only kernel time. No other die or CPU computation fallback.

Value ranges and coverage

q, k: [-32, 32]; v: [-1024, 1024]; idx: -1 or [0, S). Finite inputs only. Coverage includes zero, small magnitudes down to 2^-12, large magnitudes, positive/negative-only data, mixed scales, sparse data and representable boundaries. Task-specific tests also cover cancellation, BF16 ties and saturated softmax. NaN/Inf are excluded; subnormal preservation is not required. Not every tensor must span the entire range.

Parameters

Inputs

Outputs

Attrs

Numerical and implementation requirements

Inputs are contiguous and on the same card. q and k have finite values in [-32, 32]; v has finite values in [-1024, 1024]. idx is NPU int32; -1 entries must not read K/V or contribute to the denominator. Repeated indices contribute once per occurrence. Use FP32 dot products, stable softmax and accumulation, then cast to BF16. All-invalid rows must be exactly zero. LSE, RoPE, multiple heads, quantization, paged caches and multi-card execution are not supported.

Outputs must remain on the input device, be contiguous, leave all inputs unchanged, and not alias any input. One physical die only; using the sibling die or multi-card communication is prohibited. Core computation, data movement and conversions must use custom NPU kernels. Built-in ACLNN operators, torch delegation, CPU fallback and cached answers are prohibited.

q, k: [-32, 32]; v: [-1024, 1024]; idx: -1 or [0, S). Finite inputs only. Coverage includes zero, small magnitudes down to 2^-12, large magnitudes, positive/negative-only data, mixed scales, sparse data and representable boundaries. Task-specific tests also cover cancellation, BF16 ties and saturated softmax. NaN/Inf are excluded; subnormal preservation is not required. Not every tensor must span the entire range.

One physical die only (nominal 64 GiB HBM). Functional cases remain small and exhaustive; the independent three-tier stress suite exercises large bandwidth, compute and random-access workloads. Input + output tensors must total <=48 GiB, candidate workspace <=8 GiB; reserve >=8 GiB for runtime. Shape bounds are not a Cartesian guarantee: combinations exceeding the byte budget are invalid. Pressure correctness compares complete offline binary standards outside timing. Public stress runs are debugging only; formal pressure scoring starts only after all functional checks pass. Host wall time includes CPU work, dispatch and device synchronization, not only kernel time. No other die or CPU computation fallback.

Scoring: accuracy 20%, performance 80%; compilation has no bonus. All accuracy checks must pass before pressure evaluation.