Python API

gpulayer

python
import gpulayer as gl
NameDescription
gl.connect(url, token, *, fingerprint=None, ca_file=None) -> Clientuse a GPUlayer server for this process; checks the connection immediately
gl.default_client() -> Clientthe client set by connect(), else one from $GPULAYER_URL, else the embedded control plane
gl.remote(fn=None, **options)decorator returning a RemoteFunction; see Python functions
gl.Client(...)explicit client, described below
gl.command(argv, **kw), gl.function(entrypoint, *args, **kw), gl.distributed(entrypoint, *, source, num_workers, procs_per_worker, **kw)build a JobSpec
gl.JobSpec, gl.ResourceRequest, gl.PlacementPolicy, gl.Accelerator, gl.ExecutionTarget, gl.JobStatecontracts; see JobSpec
gl.RemoteErrorraised when a remote run does not succeed; .job holds the Job

Client

python
gl.Client(url=None, token=None, *, home=None, ca_file=None, fingerprint=None,
local_worker=True, worker_python=None)

Without url (and without $GPULAYER_URL) the client runs an embedded control plane in $GPULAYER_HOME and starts in-process workers when jobs need them.

MethodDescription
submit(spec) -> Jobsubmit a JobSpec
submit_batch(specs) -> list[Job]independent jobs
run(spec, timeout=None) -> JobResultsubmit and wait
job(job_id) -> Job, jobs(limit=50), workers()look up
package(directory) -> ArtifactReferenceupload a source bundle
upload(path_or_bytes, name=""), download(ref) -> bytesartifacts
ensure_local_workers(n)embedded mode: run at least n in-process workers
close()stop in-process workers (also on with exit)

Job

MethodDescription
status() -> JobStatusstate, placement decision, tasks
wait(timeout=None) -> JobStatusblock until the job is finished
result() -> JobResultexit code, return value, outputs, costs
cancel()request cancellation (idempotent)
logs(after_seq=0), logs_text(), follow_logs()output lines
events()lifecycle events

gpulayer.pytorch

python
import gpulayer.pytorch as glt
NameDescriptionPage
glt.Modulenn.Module with training_step, validation_step, configure_optimizers, log, load_from_checkpointTrainer and Module
glt.Trainer(...)fit(model, train, val=None, ckpt_path=None), validate(model, loader)Trainer and Module
glt.launch(...) -> LaunchResult or Nonerun this script on GPUlayer workerslaunch()
glt.Runtime(accelerator, precision)device, DDP, sharding and precision helpersRuntime helpers
glt.is_launcher_process(), glt.in_gpulayer_job()where the code is running
glt.resolve_accelerator(name), glt.seed_everything(seed)utilities

gpulayer.pytorch imports torch; import gpulayer does not.