Skip to main content

dynamic-batcher

Travis AppVeyor Coveralls Readthedocs PyPi Python39 Python310

Intro

dynamic_batcher is designed for inferencing DL models using GPU and enforces model’s concurrency.

Installation

pip install dynamic-batcher

Quickstart

Additional Requirements

pip install -r requirements-test.txt

Run

  • redis
    • RUN:

      docker run --rm -p 6379:6379 -e ALLOW_EMPTY_PASSWORD=yes bitnami/redis:latest
  • app
    • ENV:

      REDIS__HOST=localhost
      REDIS__PORT=6379
    • RUN:

      gunicorn e2e.app.main:app \
         -k=uvicorn.workers.UvicornWorker \
         --workers=4
  • batcher
    • ENV:

      REDIS__HOST=localhost
      REDIS__PORT=6379
      
      DYNAMIC_BATCHER__BATCH_SIZE=64
      DYNAMIC_BATCHER__BATCH_TIME=2
    • RUN:

      python -m dynamic_batcher e2e.batcher.run.add_1 --batch-size=64 --batch-time=2
  • locust
    • RUN:

      locust -f e2e/locust/locustfile.py

Test

  • swagger: http://localhost:8000
    • POST /items/batch/{item_id}

      curl -X POST http://localhost:8000/items/batch/1 \
      -H 'Content-Type: application/json' \
      -d '{
        "content": "string",
        "nested": {
          "key": "string",
          "values": [
            1,
            5,
            2
          ]
        }
      }'
    • result:

      {
        "data": {
          "content": "string",
          "nested": {
            "key": "string",
            "values": [
              1,
              5,
              2
            ],
            "result": [
              2,
              6,
              3
            ]
          },
          "name": "b0878740-47a8-4dd7-bfe8-9c5ed1fee4ea"
        },
        "elapsed_time": 2.551218032836914
      }
  • locust: http://localhost:8089

    locust-start locust-run

Explanation

when DYNAMIC_BATCHER__BATCH_SIZE=64 and DYNAMIC_BATCHER__BATCH_TIME=2 is set,

a running BatchProcessor waits to run a batch until the amount of requests received is met(requests count=64), for the batch_time(2 seconds). If the time is up, the partial amount of requests will be processed.

  • Startup log

    start test daemon
    BatchProcessor start: delay=0.001, batch_size=64, batch_time=2
  • Single request(concurrency=1)

    batch start: 2.001/2, 1/64
    batch start: 2,001/2, 1/64
    ...
  • Concurrent requests(concurrency=100)

    batch start: 1.653/2, 64/64
    batch start: 0.064/2, 64/64
    batch start: 0.064/2, 64/64
    batch start: 0.064/2, 64/64
    batch start: 0.064/2, 64/64
    batch start: 0.064/2, 64/64
    batch start: 0.064/2, 64/64
    batch start: 0.064/2, 64/64
    batch start: 0.064/2, 64/64
    batch start: 0.064/2, 64/64
    batch start: 0.064/2, 64/64
    batch start: 0.064/2, 64/64
    ...
    batch start: 2.001/2, 36/64

Concept

Ref.: NVIDIA Triton’s dynamic batching

dynamic_batching-triton

Metadata

Release files for dynamic-batcher 1.0.6.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for dynamic-batcher 1.0.6.1
File Interpreter ABI Platform Actions
dynamic_batcher-1.0.6.1-py3-none-any.whl Python 3 none any Details for dynamic_batcher-1.0.6.1-py3-none-any.whl

Release files / dynamic_batcher-1.0.6.1-py3-none-any.whl

Download URL dynamic_batcher-1.0.6.1-py3-none-any.whl
Size 13.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4a3a2550cb248f130385cc04152fd5b29b2c85cb69dbbfc890315b9907919f5e
BLAKE2b-256 checksum
How to use checksums
350d21dd6da29f25af1191ac1e1cd0a0a4d5a3e30598601f4a034eb459127af8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.11

Security for dynamic-batcher 1.0.6.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page