Quick answer: Unity job throwing race condition writing to NativeParallelHashMap? The standard variant is single-writer - use NativeParallelHashMap.ParallelWriter for concurrent insertion.

Job runs fine single-threaded. Scheduled in parallel: InvalidOperationException: NativeParallelHashMap may not be written by multiple jobs.

Use ParallelWriter

public NativeParallelHashMap<int, float>.ParallelWriter writer;
public void Execute(int i) => writer.TryAdd(i, vals[i]);

Acquire via map.AsParallelWriter(). Concurrent inserts are lock-free; concurrent reads on the same map are not.

Don't share writers across jobs

Each scheduled batch needs its own writer instance. Reusing one across IJobParallelFor and IJobChunk still races.

Profile with the Jobs Debugger

Toggle Jobs > Leak Detection: Full. The debugger flags unsafe parallel access at runtime instead of letting it corrupt the table silently.

“NativeContainers are typed by their concurrency model. Reading the type name tells you what's safe.”

If your reduce step needs both read and write, split it into write-then-read jobs with a dependency between them.