Skip to content

fix: support default_rng() across the flopscope client/server boundary#109

Merged
spMohanty merged 3 commits into
mainfrom
dev/flopscope-remote-generator
Jun 1, 2026
Merged

fix: support default_rng() across the flopscope client/server boundary#109
spMohanty merged 3 commits into
mainfrom
dev/flopscope-remote-generator

Conversation

@spMohanty
Copy link
Copy Markdown
Collaborator

Summary

fnp.random.default_rng(seed) returned a numpy Generator the server could not serialize (failed to serialize response: TypeError), so every estimator using the documented seeding scaffold (self._setup_rng = fnp.random.default_rng(...)) failed grading with SETUP_FAILED — surfacing to participants as a generic "Evaluation error".

Adds a RemoteGenerator handle mirroring RemoteArray:

  • server: Session.store_generator/get_generator; _pack_result returns {"gen_id": handle} for a np.random.Generator; Generator.<method> ops dispatch to the stored generator (method-allowlisted via _ALLOWED_GEN_METHODS); _resolve_arg learns {"__gen__": h}; validate_request lets Generator.* through.
  • client: RemoteGenerator proxy (uniform, standard_normal, integers, normal, random, …) dispatching Generator.<method> back; _result_from_response / _encode_arg wired.
  • Sampling runs + advances server-side → deterministic per seed, bit-identical to numpy, FLOP-counted.

Bumps 0.4.1 → 0.4.2 (patch) across all version_files — stays within the evaluator's flopscope-client>=0.4.1,<0.5 pin.

Test plan

  • New flopscope-client/tests/test_remote_generator_integration.py: default_rng().uniform(...) over the boundary + reproducibility
  • Determinism: standard_normal/uniform bit-identical to numpy.random.default_rng
  • scripts/check_version_sync.py → all 8 locations 0.4.2
  • test_full_integration.py (34 passed) + root suite (0 failed)
  • Reviewer: confirm _ALLOWED_GEN_METHODS covers the RNG surface participants need

Found while E2E-testing the starter-kit examples via whest submit (failed submission 309632). Does not tag/publish — release is gated.

default_rng() returned a numpy Generator the server could not serialize
("failed to serialize response: TypeError"), so every estimator using the
documented seeding scaffold (self._setup_rng = fnp.random.default_rng(...))
failed grading with SETUP_FAILED.

Add a RemoteGenerator handle, mirroring RemoteArray: the server stores the
Generator and returns {"gen_id": handle}; the client wraps it and dispatches
Generator.<method> ops back, so sampling runs + advances server-side
(deterministic per seed, bit-identical to numpy, FLOP-counted).
spMohanty added a commit to AIcrowd/whestbench that referenced this pull request Jun 1, 2026
flopscope 0.4.2 fixes fnp.random.default_rng() over the client/server
grader boundary (AIcrowd/flopscope#109). Floor kept at flopscope>=0.4.1
so the lock stays resolvable before 0.4.2 is published.
@spMohanty spMohanty force-pushed the dev/flopscope-remote-generator branch from 05330d9 to d92c3ad Compare June 1, 2026 16:13
@spMohanty spMohanty force-pushed the dev/flopscope-remote-generator branch from 14ba0d1 to d92c3ad Compare June 1, 2026 16:32
@spMohanty spMohanty merged commit 59b2b71 into main Jun 1, 2026
22 checks passed
@spMohanty spMohanty deleted the dev/flopscope-remote-generator branch June 1, 2026 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant