Skip to main content

Lightweight flopscope client — drop-in replacement with no numpy dependency

Project description

flopscope-client

PyPI version Python 3.10+ License: MIT

Lightweight drop-in replacement for flopscope that proxies all operations to a remote flopscope-server over ZMQ + msgpack.

flopscope-client provides the same import flopscope Python module as the main flopscope distribution, but with no NumPy dependency — it forwards every counted operation to a flopscope-server process. Use this in constrained environments where you want flopscope's FLOP-counting API but cannot ship numpy + the full library (e.g. sandboxed participant containers in the ARC Whitebox Estimation Challenge).

Install instead of, not alongside

flopscope-client occupies the same flopscope Python import namespace as the main package. The two are mutually exclusive — installing both leads to file-overlap in flopscope/. Choose one:

# Lightweight: client-only, no numpy
pip install flopscope-client

# Heavy: full library on the local machine
pip install flopscope

# Server-side: both flopscope + flopscope-server, pinned together
pip install "flopscope[server]"

Quick start

The client connects to a flopscope-server instance specified by the FLOPSCOPE_SERVER_URL environment variable:

export FLOPSCOPE_SERVER_URL=tcp://flopscope-server.example.com:15555
# or for a local UNIX socket:
export FLOPSCOPE_SERVER_URL=ipc:///tmp/flopscope.sock

Then use flopscope normally — the import path and API are identical to the main distribution:

import flopscope as flops
import flopscope.numpy as fnp

with flops.BudgetContext(flop_budget=1_000_000):
    a = fnp.array([1.0, 2.0, 3.0])
    b = fnp.array([4.0, 5.0, 6.0])
    result = fnp.add(a, b)   # round-trips to the server, runs there
    flops.budget_summary()

On the first request, the client performs a version handshake with the server. A version mismatch raises ConnectionError with both versions in the error message — keep flopscope-server and flopscope-client on the same release.

Differences from NumPy

The API mirrors NumPy, with one semantic difference worth knowing up front: flopscope arrays are immutable (like JAX). Item assignment and indexed in-place updates raise TypeError:

arr[i] = value      # TypeError: flopscope arrays are immutable
arr[i] += value     # same error — desugars to arr[i] = arr[i] + value

Build results functionally instead — collect the pieces in a list and fnp.stack(...) them, or use a whole-array update (arr = arr + x, which rebinds rather than mutates). See the Immutable arrays guide for the accumulation recipe.

When to choose this over the main flopscope install

Scenario Install
You want flopscope's API in a process that has full NumPy + scientific stack pip install flopscope
You're shipping a sandboxed container that must not contain numpy / scipy pip install flopscope-client
You're running the server side that hosts computation for many clients pip install flopscope-server (brings flopscope along)
You're deploying both sides on one machine, version-pinned pip install "flopscope[server]"

Architecture overview

┌─────────────────────────────┐         ZMQ + msgpack         ┌──────────────────────────────┐
│  flopscope-client process   │ ───────────────────────────▶  │  flopscope-server process    │
│  (sandbox; no numpy)        │                                │  (full flopscope + numpy)    │
│  `import flopscope as flops`│ ◀───────────────────────────  │  Executes ops, tracks budget │
└─────────────────────────────┘                                └──────────────────────────────┘

The client serializes each operation (op name, args, kwargs) as msgpack, sends it over the ZMQ REQ/REP socket, and decodes the response. Budget tracking, symmetry-aware FLOP counting, and operation-cost analytics all happen on the server side; the client just relays calls.

Related

License

MIT

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

flopscope_client-0.8.0rc3.tar.gz (141.2 kB view details)

Uploaded Source

Built Distribution

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

flopscope_client-0.8.0rc3-py3-none-any.whl (67.2 kB view details)

Uploaded Python 3

File details

Details for the file flopscope_client-0.8.0rc3.tar.gz.

File metadata

  • Download URL: flopscope_client-0.8.0rc3.tar.gz
  • Upload date:
  • Size: 141.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for flopscope_client-0.8.0rc3.tar.gz
Algorithm Hash digest
SHA256 899c2c534a97c223ab13e26ab87943080bbff59b6da62a207e2105ed3de27e3f
MD5 bb140a6f6b21f9a7ee6a4a9a3b49daed
BLAKE2b-256 06f461fe0bf35ef6082dfeff1a6850d0bbadee82953572ffd0b6c8eaa02c9354

See more details on using hashes here.

Provenance

The following attestation bundles were made for flopscope_client-0.8.0rc3.tar.gz:

Publisher: pypi-publish.yml on AIcrowd/flopscope

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file flopscope_client-0.8.0rc3-py3-none-any.whl.

File metadata

File hashes

Hashes for flopscope_client-0.8.0rc3-py3-none-any.whl
Algorithm Hash digest
SHA256 e7d5a0221dcaf741c8e1b7c76c747e39e1d9310c77b3985a7e0681b9032bed3a
MD5 026c6bb5122812239d57088af1d274b5
BLAKE2b-256 8152275a524b2eafbc2057dfc358e24a8e28350ddaf26d8c1bc6c18a9c61dbf5

See more details on using hashes here.

Provenance

The following attestation bundles were made for flopscope_client-0.8.0rc3-py3-none-any.whl:

Publisher: pypi-publish.yml on AIcrowd/flopscope

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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