Migrating from earlier Quadrants releases#

This guide covers changes to make when upgrading code that relies on earlier Quadrants behavior.

Augmented assignments are non-atomic#

Augmented assignments previously performed implicit atomic updates. In kernel and function scope, assignments such as +=, -=, &=, |=, and ^= perform ordinary read/modify/write updates. For example, a[i] += value has the same update semantics as a[i] = a[i] + value, while evaluating the target once.

Use augmented assignments for thread-local values and array elements owned by one thread. When parallel iterations update the same location, use an explicit atomic operation:

@qd.kernel
def sum_values(values: qd.types.ndarray(), total: qd.types.ndarray()):
    for i in range(values.shape[0]):
        qd.atomic_add(total[0], values[i])

Update your code: replace +=, -=, &=, |=, and ^= with qd.atomic_add, qd.atomic_sub, qd.atomic_and, qd.atomic_or, and qd.atomic_xor wherever concurrent updates must be preserved. This also applies to scalar accumulators declared outside a parallel loop. Multiplication, division, remainder, shifts, and exponentiation assignments already used ordinary updates.

Autodiff accumulation into fields and ndarrays also needs explicit qd.atomic_add or qd.atomic_sub, even when each parallel iteration owns a separate element. Ordinary augmented assignment introduces a read followed by a write instead of the accumulation operation expected by autodiff.

Specialized augmented-assignment APIs, such as sparse-matrix triplet insertion and tile outer-product subtraction, retain their own semantics. See atomic operations for the explicit atomic API.