Deterministic multiprocessing pipelines

From XuShuwenn/RedAct · View interactive version

Deterministic multiprocessing pipelines is an AI agent skill from the GitHub repository XuShuwenn/RedAct. Parallelize CPU-bound Python pipelines (e.g., TF-IDF indexing/search) with multiprocessing while preserving sequential results exactly and achieving real speedups.

How to use this skill

Skill file

Deterministic Multiprocessing Pipelines

A reusable workflow for converting a sequential, CPU-bound Python pipeline (e.g., TF‑IDF indexing and batch search) into a correct, deterministic, and efficient multiprocessing implementation that achieves practical speedups without altering outputs.

When to Use

Use this skill when you need to:

Examples: search engines (TF‑IDF/keyword), similarity ranking, feature extraction, per-item computations with a reduction/merge phase.

Core Workflow

Use a structured, phase-based approach. Design each phase for parallel safety, deterministic merging, and minimal inter-process communication (IPC).

1) Map the Pipeline Phases

2) Design Data Flow to Minimize IPC

3) Implement Workers at Module Level

4) Parallel Index Building (TF‑IDF Example)

5) Parallel Batch Search

6) Chunking & Batching Heuristics

7) Ordering & Determinism

8) Performance Measurement

Verification

Always validate the parallel outputs against the sequential baseline before claiming speedups.

Checks to perform:

Recommended tolerances: <= 1e-10 for scores when your baseline uses the same arithmetic order. If tiny ordering differences arise from float associativity, enforce deterministic iteration to eliminate drift.

Common Pitfalls and How to Avoid Them

Optional Script Usage

The scripts/parallel_utils.py utility offers reusable helpers for chunking, batching, stable top‑K, order restoration, and a generic global-initializer pattern for multiprocessing pools.

Example patterns:

Use these helpers to standardize parallelization across phases.

Success Criteria

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.