Skip to main content

Zero-input-serialization, GIL-free parallel map.

Project description

scissiparity 🦠

Zero-input-serialization, GIL-free parallel map.

multiprocessing forces you to serialize data in both directions, so large or unpicklable inputs crash or blow up memory. scissiparity clones the interpreter with os.fork(), reads inputs for free through Copy-On-Write, and serializes only the results you yield.

uv add scissiparity

Usage

Write ordinary sequential logic over a chunk. The @fission decorator splits the iterable across your CPU cores, runs a forked process per chunk, and merges the yielded results into one lazy stream.

from collections.abc import Iterator

from scissiparity import fission

MASSIVE_UNPICKLABLE_STATE = load_everything_into_memory()


@fission
def process_users(user_ids: list[str]) -> Iterator[float]:
    for user_id in user_ids:
        state = MASSIVE_UNPICKLABLE_STATE[user_id]
        yield heavy_cpu_computation(state)


results = list(process_users(["user_1", "user_2", "user_3"]))

Properties

  • See-through types. @fission preserves the wrapped signature. Element and keyword-argument types survive the decoration, so type checkers infer process_users(...) -> Iterator[float] with no annotations lost.
  • Zero input serialization. Children read the parent's memory natively via Copy-On-Write; only yielded outputs are piped back (via dill). Unpicklable inputs are fine.
  • Exception teleportation. An exception in a child is serialized, piped back, and re-raised in the parent with its original traceback and chained causes intact (via tblib), so failures read exactly as they would in-process. One failure aborts the run.
  • Composes without fork-bombing. A @fission function called from inside another runs sequentially, so simple cells combine into larger pipelines.
  • Zero configuration. Parallelism is inferred from os.sched_getaffinity(0) (falling back to os.cpu_count()). There are no workers= knobs.

Results are streamed back in completion order, not input order.

PyTorch & transformer models

scissiparity is an excellent fit for CPU inference: os.fork() lets every worker share the loaded model weights through Copy-On-Write, so a multi-gigabyte model is loaded into memory once — not re-serialized or re-loaded per worker.

  • Load the model before applying @fission, and don't run tensor ops in the parent first. fork() duplicates only the calling thread, so a live BLAS/OpenMP thread pool can deadlock the children.
  • Set torch.set_num_threads(1) and TOKENIZERS_PARALLELISM=false so process-level and library-level parallelism don't oversubscribe your cores.

CUDA / GPU is not supported. A CUDA context cannot survive os.fork() (it raises Cannot re-initialize CUDA in forked subprocess), and GPU memory is not Copy-On-Write shareable, so the core advantage doesn't apply. Use spawn-based tooling such as torch.multiprocessing for GPU workloads.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scissiparity-2.0.0.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

scissiparity-2.0.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file scissiparity-2.0.0.tar.gz.

File metadata

  • Download URL: scissiparity-2.0.0.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"CachyOS Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for scissiparity-2.0.0.tar.gz
Algorithm Hash digest
SHA256 00d506a9a81baeec8c6ad722b3426f354b05049e84702ff6bf42ffa9b6fccb85
MD5 ca9df7f2ffe139e13948f0470ce693f3
BLAKE2b-256 e5eb11d12b732c1e24349437098ab356517869e29a2a839c95a33881e02bf47f

See more details on using hashes here.

File details

Details for the file scissiparity-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: scissiparity-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"CachyOS Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for scissiparity-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 685f99d780b142b11c882b11053ce0b71b819e034fb044389ab8e5206c6077cb
MD5 ed6d849f8e6b1353a4cb106208681660
BLAKE2b-256 2fc1ca4820fd6d7bec9d349e8c2de4135c381b246ed31fab0c2422c8432bf65d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page