# thinking-machines-lab/batch_invariant_ops

Repository: https://github.com/thinking-machines-lab/batch_invariant_ops
Canonical: https://ross.abutalabs.com/products/batch_invariant_ops
Language: Python
License: MIT
License Family: permissive
Last push: 2025-11-04T05:08:17+00:00

## Health v2 (maintenance only)
Score: 40/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 50, release rhythm 35, longevity 25
- inputs: {"age_days": 358, "days_push": 302, "days_rel": null, "gap_med": null, "n_releases_24m": 0}
- flags: no_releases
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 1067, forks 84 (observed 2026-08-28T04:03:27.176448+00:00)

## What it is
A Python library that replaces standard PyTorch CUDA kernels with batch-invariant versions, ensuring identical results regardless of batch size. It accompanies Thinking Machines' blog on defeating nondeterminism in LLM inference and includes a proof-of-concept for deterministic vLLM inference.

## Use cases
- make llm inference deterministic regardless of batch size
- get reproducible pytorch gpu results
- eliminate nondeterminism in vllm serving
- ensure matrix multiplication gives same output for different batch sizes
- debug floating point nondeterminism in cuda kernels

## When to choose
- you need bit-exact reproducible GPU inference results
- you run vLLM and want deterministic completions
- you're debugging batch-size-dependent numerical differences in PyTorch

## When to avoid
- you need maximum inference throughput and can tolerate nondeterminism
- you rely on operations not covered (only mm, addmm, log_softmax, mean are supported)
- you're not using CUDA GPUs

## Facets
- artifact type: library
- maturity: experimental
- function: machine-learning, llm-inference, gpu-computing
- domain: deep-learning, large-language-models, performance
- platform: python
- tags: determinism, pytorch, kernels, vllm, reproducibility, gpu, linux

## Member repositories
- thinking-machines-lab/batch_invariant_ops (main) score 40

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:03:27.176448+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T06:55:12.071885+00:00, confidence not recorded.
  - readme: https://github.com/thinking-machines-lab/batch_invariant_ops (fetched 2026-08-28T04:03:27.176448+00:00, sha 314d09d5122a)
- Data as of 2026-08-30T08:39:29.467469+00:00.
