HyperGAN logo HyperGAN v2.2.0

Bounded observation for replicated CPU runs

The internal replicated run service supports periodic EMA previews and progress callbacks while keeping the numerical workers isolated from rendering and callback execution. The public execution commands use this preview service and a concrete bounded CLI output sink. Arbitrary Python callbacks retain the isolated-function contract below. Native Python callbacks and previews retain their existing behavior.

Previews#

Pass preview_every=N, preview_keep=K and preview_name=NAME to internal run_train or run_resume. Zero preview_every disables previews and zero preview_keep keeps every published preview; the default bound is 128 with thinned retention. A resume with omitted preview settings reuses the run's stored interval and sample name, and its stored bound only when preview_keep_source records it as explicit. Sample sequence reservations, immutable preview generations, the index and pruning use the shared observation contract.

After a complete update, the controller reserves a sequence and requests a snapshot from the workers. Rank zero copies EMA generator dependencies, the EMA prior and bounded conditioning from the last completed local batch. Snapshot capture preserves training RNG and operates on copied modules before invoking serialization hooks. A separate supervised process reconstructs and renders the snapshot without initializing a training process group. The isolated renderer publishes completed preview JSON and updates the index; the parent consumes its bounded receipt.

Snapshot files are limited to 1 GiB, allowing full-depth transformer generators and their position buffers. Preview conditioning/output uses the existing 16-sample, 65,536-element and 2 MiB JSON limits; counts may be reduced under that preview contract. These are checked artifact limits, not a process memory quota.

There is at most one pending preview. Its CPU rendering and artifact publication run asynchronously; busy schedules are skipped before snapshot capture. The rank-zero snapshot file handoff still copies, serializes, fsyncs and hashes state inside the capture command, before the next update. service_policy.preview_timeout defaults to 60 seconds and bounds isolated rendering; capture remains subject to the training command deadline. The training broker continues monitoring numerical worker health. Cleanup adds the supervisor's documented termination grace. Native training instead hands owned CPU state directly to its preview supervisor, so snapshot storage also runs off its update thread. These contracts do not bound arbitrary custom allocations or uninterruptible filesystem calls.

A renderer exception, hung forward or attempted collective is recorded as a preview observation error if the numerical workers remain healthy. A capture command or numerical-group failure is fatal. Failed previews leave reserved sequence gaps; they never rewind sample numbering. Preview failure does not delete checkpoints or final inference bundles. Final inference export currently retains its required, rank-zero command path and is not covered by optional preview failure handling.

Progress callbacks#

Define the callback as an importable module-level Python function, then pass it as on_event. The worker invokes callback(event) and ignores its return value. Keep its module lightweight and protect the driver's entrypoint with if __name__ == '__main__'. Closures, lambdas and callable instances are rejected before a new run is created or a resume attempt is published.

Events are submitted without waiting for the callback. A background dispatcher delivers accepted events in fresh supervised CPU processes without a training process group. One callback may be outstanding; notifications arriving while it is busy are dropped. The terminal observer_status event and progress_observation manifest field record accepted, completed, dropped and failed counts. Use the filesystem event log when every published event matters. Each encoded callback event is limited to 65,536 bytes. Callback globals do not persist across deliveries, and mutations do not reach the coordinator or numerical workers. Worker CUDA visibility is empty, numerical CPU threads are capped, and OS scheduling priority is lowered where supported.

service_policy.observer_timeout defaults to five seconds. Startup, callback execution and shutdown share a deadline starting at admission, with bounded supervisor cleanup grace. Callback stdout follows the worker service's redirection to stderr; control messages use separate sockets. Blocking output and native calls run in the callback process and can be terminated. The first runtime callback failure is collected asynchronously, records a progress observation error at its source event's step, and disables callbacks for the remainder of that attempt. Filesystem events continue. The error event itself is not sent back to the failing callback. Only explicit optional delivery errors receive this treatment; numerical execution and native RNG/thread-restoration failures remain fatal.

Training worker shutdown still precedes terminal status. Terminal delivery drains an outstanding callback and, unless disabled, invokes the terminal event's own bounded callback. Each has its own deadline; all managed callback workers are reaped before the Python API returns. Exceptional controller cleanup cancels an outstanding callback. There is no persistent child between deliveries. An abrupt coordinator death causes each independent broker to terminate and reap its managed worker, including a worker stuck in native code. Unmanaged descendants, guardian or host failure, and unkillable kernel operations remain outside that guarantee.

A cooperative stop signal also cancels callbacks during terminal draining, records their original source step and cancellation count, and reaps their workers without waiting for the configured observer timeout. Actual callback failures retain their failure status; an existing numerical failure remains the primary run error.

Native single-process Python on_event callbacks remain synchronous control hooks, including closures that intentionally interact with their caller. They retain RNG isolation and can delay the caller; the nonblocking callback guarantee above applies to replicated execution. The concrete CLI progress sink uses its own bounded output path in both adapters.

Policy and recovery#

Observer deadlines are operational policy, separate from numerical identity. Supply nondefault policy on each invocation; it is recorded for the attempt but not automatically reused by run_resume. Changing observer settings must preserve full current-run checkpoint state and strict fixed-topology recovery. No migration or compatibility support is required for checkpoints from older implementations.

This is CPU lifecycle qualification, not GPU, cluster, browser or image-quality qualification. Numeric previews remain the supported artifact; image grids and the optional local server are later work.