JAX¶
JAX frontend for ZKDV.
Transaction ¶
Transaction(*, batch: Any, params: Any, opt_state: Any, overlap: Policy = UNCHECKED, _proof: Any | None = None)
Declare the pre- and post-update values inside a ZKDV.jit function.
Source code in zkdv/jax/transaction.py
ZKDV ¶
ZKDV(path: str | Path, config: ZKDVConfig | None = None, *, max_in_flight: int = 2, replay_snapshot_interval: int = 12)
Bases: Driver
Generate a verification tape around annotated JAX training functions.
Source code in zkdv/driver/jax.py
attest ¶
attest(function: Callable[..., Any] | None = None, /, *, in_shardings: Any = UNSPECIFIED, out_shardings: Any = UNSPECIFIED, static_argnums: int | Sequence[int] | None = None, static_argnames: str | Iterable[str] | None = None, donate_argnums: int | Sequence[int] | None = None, donate_argnames: str | Iterable[str] | None = None, keep_unused: bool = False, device: Any | None = None, backend: str | None = None, inline: bool = False, compiler_options: dict[str, Any] | None = None) -> Any
Register the exportable sampled-update program.
Source code in zkdv/driver/jax.py
jit ¶
jit(function: Callable[..., Any] | None = None, /, *, in_shardings: Any = UNSPECIFIED, out_shardings: Any = UNSPECIFIED, static_argnums: int | Sequence[int] | None = None, static_argnames: str | Iterable[str] | None = None, donate_argnums: int | Sequence[int] | None = None, donate_argnames: str | Iterable[str] | None = None, keep_unused: bool = False, device: Any | None = None, backend: str | None = None, inline: bool = False, compiler_options: dict[str, Any] | None = None) -> Any
Compile a transaction-annotated function with jax.jit semantics.
Source code in zkdv/driver/jax.py
index ¶
Select one scalar from a PyTree's logical flattened leaf order.
Source code in zkdv/_invoked_jax/index.py
contrib ¶
High-level JAX integrations built on the canonical ZKDV pipeline.
TrainState ¶
Bases: TrainState
Flax's ordinary TrainState with an implicit ZKDV update marker.
apply_gradients ¶
apply_gradients(*, grads: Any, **kwargs: Any) -> TrainState
Apply gradients exactly as Flax does and register the transition.
Source code in zkdv/jax/contrib/train_state.py
train_state ¶
A Flax TrainState whose optimizer transition is committed by ZKDV.
TrainState ¶
Bases: TrainState
Flax's ordinary TrainState with an implicit ZKDV update marker.
apply_gradients ¶
apply_gradients(*, grads: Any, **kwargs: Any) -> TrainState
Apply gradients exactly as Flax does and register the transition.
Source code in zkdv/jax/contrib/train_state.py
jit ¶
JAX compilation of symbolically annotated training functions.
CompiledFunction ¶
CompiledFunction(driver: Any, function: Callable[..., Any], *, in_shardings: Any = UNSPECIFIED, out_shardings: Any = UNSPECIFIED, static_argnums: int | Sequence[int] | None = None, static_argnames: str | Iterable[str] | None = None, donate_argnums: int | Sequence[int] | None = None, donate_argnames: str | Iterable[str] | None = None, keep_unused: bool = False, device: Any | None = None, backend: str | None = None, inline: bool = False, compiler_options: dict[str, Any] | None = None)
Bases: CompiledFunction
Compile one annotated function and submit its hidden pipeline evidence.
Source code in zkdv/jax/jit.py
lower ¶
Lower the fused executable without opening a transcript transaction.
Source code in zkdv/jax/jit.py
pipeline ¶
Canonical JAX transaction pipeline above the native protocol boundary.
Pipeline ¶
Pipeline(core: Any, program: Any, placement: Any, program_in_shardings: Any, queue: PipelineQueue, params: Any, opt_state: Any, batch: Any, *, snapshot_interval: int = 12)
Bases: Pipeline
Compile and submit the JAX fused update protocol.
Source code in zkdv/jax/pipeline.py
proto ¶
Publicly inheritable JAX protocols. Various library functions will ask for these prototypes.
F_u ¶
Bases: Protocol
Parameter Update Function
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
The model parameters. |
required | |
state
|
The optimizer state or any sidechannel info. |
required |
Notes
Should be pure AND have all seralizable state elements. In Jax, serializable means jax.export() can pack it into a flatbuffer. In torch, TODO.
We will be hashing the seralized version of this function into the commitment record.
replay ¶
JAX replay schemas and bounded checkpoints.
ArraySpec
dataclass
¶
One array's lossless representation in a packed uint32 batch.
ReplayCheckpoint ¶
ReplayCheckpoint(program: Callable[[Any, Any, Array], tuple[Any, Any]], params: Any, optimizer: Any, batch: Array, *, snapshot_interval: int = 12, snapshot_pool_size: int = 2)
Bound replay with asynchronous, donation-safe host snapshots.
Source code in zkdv/jax/replay/checkpoint.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
host_optimizer_shardings
property
¶
Compiler-addressable host placement for optimizer snapshots.
host_param_shardings
property
¶
Compiler-addressable host placement for parameter snapshots.
accept ¶
Record acceptance without copying the replay result back to host.
Source code in zkdv/jax/replay/checkpoint.py
activate ¶
Open a transaction and asynchronously copy its pre-state when due.
Source code in zkdv/jax/replay/checkpoint.py
close ¶
join ¶
Drain copies at an explicit pipeline synchronization boundary.
Source code in zkdv/jax/replay/checkpoint.py
pre_state ¶
Restore the newest eligible snapshot and replay only its short suffix.
Source code in zkdv/jax/replay/checkpoint.py
record ¶
Retain one independently owned host batch for a possible suffix.
Source code in zkdv/jax/replay/checkpoint.py
release ¶
Release one transaction; never fence a discarded host transfer.
ReplaySchema
dataclass
¶
ReplaySchema(tree: PyTreeDef, template: tuple[Any | None, ...], sources: tuple[int, ...], specs: tuple[ArraySpec, ...], params: InputBinding, opt_state: InputBinding, batch: InputBinding | None, arguments: tuple[int, ...], leaf_arguments: tuple[int, ...], static_args: tuple[tuple[int, Any], ...])
Rebuild one training call from challenged state and committed inputs.
pack ¶
Encode dynamic call inputs without adding work to the JIT executable.
Source code in zkdv/jax/replay/schema.py
program ¶
Expose the full transition used by checkpoint replay and checks.
Source code in zkdv/jax/replay/schema.py
training_stage ¶
Present parameter buffers separately so only they may be donated.
Source code in zkdv/jax/replay/schema.py
checkpoint ¶
Asynchronous JAX host snapshots for bounded checked replay.
At the beginning of a periodic update, a background host thread dispatches a JAX copy of the exact parameter and optimizer pre-state into compiler-addressable host memory (pinned where the backend provides it). The training executable is then dispatched immediately on the calling thread. JAX orders the copy before donated input storage can be reused, while the separate dispatcher prevents the host-valued result from stalling training dispatch. Unchecked flow retains the future without reading its destination.
The default interval of twelve copies the complete pre-state periodically and journals the intervening batches, so a check replays at most eleven earlier transitions before executing the challenged transition. An interval of one copies every step and executes exactly the challenged transition.
Snapshots taken from the training path are evidence, not trusted state. A checked replay still recomputes and validates the challenged update's pre/post parameter and optimizer commitments before it can be accepted.
ReplayCheckpoint ¶
ReplayCheckpoint(program: Callable[[Any, Any, Array], tuple[Any, Any]], params: Any, optimizer: Any, batch: Array, *, snapshot_interval: int = 12, snapshot_pool_size: int = 2)
Bound replay with asynchronous, donation-safe host snapshots.
Source code in zkdv/jax/replay/checkpoint.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
host_optimizer_shardings
property
¶
Compiler-addressable host placement for optimizer snapshots.
host_param_shardings
property
¶
Compiler-addressable host placement for parameter snapshots.
accept ¶
Record acceptance without copying the replay result back to host.
Source code in zkdv/jax/replay/checkpoint.py
activate ¶
Open a transaction and asynchronously copy its pre-state when due.
Source code in zkdv/jax/replay/checkpoint.py
close ¶
join ¶
Drain copies at an explicit pipeline synchronization boundary.
Source code in zkdv/jax/replay/checkpoint.py
pre_state ¶
Restore the newest eligible snapshot and replay only its short suffix.
Source code in zkdv/jax/replay/checkpoint.py
record ¶
Retain one independently owned host batch for a possible suffix.
Source code in zkdv/jax/replay/checkpoint.py
release ¶
Release one transaction; never fence a discarded host transfer.
schema ¶
Canonical JAX evidence and replay of a staged training function.
ArraySpec
dataclass
¶
One array's lossless representation in a packed uint32 batch.
ReplaySchema
dataclass
¶
ReplaySchema(tree: PyTreeDef, template: tuple[Any | None, ...], sources: tuple[int, ...], specs: tuple[ArraySpec, ...], params: InputBinding, opt_state: InputBinding, batch: InputBinding | None, arguments: tuple[int, ...], leaf_arguments: tuple[int, ...], static_args: tuple[tuple[int, Any], ...])
Rebuild one training call from challenged state and committed inputs.
pack ¶
Encode dynamic call inputs without adding work to the JIT executable.
Source code in zkdv/jax/replay/schema.py
program ¶
Expose the full transition used by checkpoint replay and checks.
Source code in zkdv/jax/replay/schema.py
training_stage ¶
Present parameter buffers separately so only they may be donated.
Source code in zkdv/jax/replay/schema.py
transaction ¶
Symbolic JAX transaction markers traced by :meth:ZKDV.jit.
Transaction ¶
Transaction(*, batch: Any, params: Any, opt_state: Any, overlap: Policy = UNCHECKED, _proof: Any | None = None)
Declare the pre- and post-update values inside a ZKDV.jit function.
Source code in zkdv/jax/transaction.py
TransactionSchema
dataclass
¶
TransactionSchema(batch: InputBinding | _AutomaticBatch, params: InputBinding, opt_state: InputBinding, overlap: InputBinding | Policy, proof: Any | None)
Locations of the pre-update values in an arbitrary function ABI.
TransactionTrace ¶
Collect one transaction while JAX traces a decorated function.
Source code in zkdv/jax/transaction.py
trees ¶
JAX pytree operations used by shared ZKDV mechanics.