tff.framework.MergeableCompExecutionContext
Stay organized with collections
Save and categorize content based on your preferences.
Context which executes mergeable computations in subrounds.
Inherits From: SyncContext
tff.framework.MergeableCompExecutionContext(
async_contexts: Sequence[tff.framework.AsyncContext
],
compiler_fn: Optional[Callable[[_Computation], MergeableCompForm]] = None,
transform_args: Optional[Callable[[object], object]] = None,
transform_result: Optional[Callable[[object], object]] = None,
num_subrounds: Optional[int] = None
)
This context relies on retrying behavior of the underlying asynchronous
execution contexts to localize retries to these subrounds. That is, if a
subround fails, this subround is the only computation that is retried. This
allows MergeableCompExecutionContext
to execute larger rounds than a
runtime which retries the entire round in the case of e.g. a worker failure.
Args |
async_contexts
|
Sequence of TFF execution contexts. These contexts are
assumed to implement their invoke method as a coroutine function,
returning an awaitable.
|
compiler_fn
|
An optional callable which accepts a
tff.framework.ConcreteComputation and returns an instance of
MergeableCompForm . If not provided, this context will only execute
instances of MergeableCompForm directly.
|
transform_args
|
An Optional Callable used to transform the args before
they are passed to the computation.
|
transform_result
|
An Optional Callable used to transform the result
before it is returned.
|
num_subrounds
|
An optional integer, specifying total the number of
subrounds desired. If unspecified, the length of async_contexts will
determine the number of subrounds. If more subrounds are requested than
contexts are passed, invocations will be sequentialized.
|
Methods
invoke
View source
invoke(
comp: Union[tff.framework.MergeableCompForm
, tff.Computation
],
arg: Optional[object] = None
)
Invokes computation comp
with argument arg
.
Args |
comp
|
The computation being invoked. The Python type of comp expected
here (e.g., pb.Computation . tff.framework.ConcreteComputation , or
other) may depend on the context. It is the responsibility of the
concrete implementation of this interface to verify that the type of
comp matches what the context is expecting.
|
arg
|
The argument passed to the computation. If no argument is passed,
this will be None . Structural argument types will be normalized into
tff.structure.Struct s.
|
Returns |
The result of invocation, which is context-dependent.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-09-20 UTC.
[null,null,["Last updated 2024-09-20 UTC."],[],[],null,["# tff.framework.MergeableCompExecutionContext\n\n\u003cbr /\u003e\n\n|-------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/federated/blob/v0.87.0 Version 2.0, January 2004 Licensed under the Apache License, Version 2.0 (the) |\n\nContext which executes mergeable computations in subrounds.\n\nInherits From: [`SyncContext`](../../tff/framework/SyncContext) \n\n tff.framework.MergeableCompExecutionContext(\n async_contexts: Sequence[../../tff/framework/AsyncContext],\n compiler_fn: Optional[Callable[[_Computation], MergeableCompForm]] = None,\n transform_args: Optional[Callable[[object], object]] = None,\n transform_result: Optional[Callable[[object], object]] = None,\n num_subrounds: Optional[int] = None\n )\n\nThis context relies on retrying behavior of the underlying asynchronous\nexecution contexts to localize retries to these subrounds. That is, if a\nsubround fails, this subround is the only computation that is retried. This\nallows `MergeableCompExecutionContext` to execute larger rounds than a\nruntime which retries the entire round in the case of e.g. a worker failure.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|--------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `async_contexts` | Sequence of TFF execution contexts. These contexts are assumed to implement their `invoke` method as a coroutine function, returning an awaitable. |\n| `compiler_fn` | An optional callable which accepts a [`tff.framework.ConcreteComputation`](../../tff/framework/ConcreteComputation) and returns an instance of `MergeableCompForm`. If not provided, this context will only execute instances of `MergeableCompForm` directly. |\n| `transform_args` | An `Optional` `Callable` used to transform the args before they are passed to the computation. |\n| `transform_result` | An `Optional` `Callable` used to transform the result before it is returned. |\n| `num_subrounds` | An optional integer, specifying total the number of subrounds desired. If unspecified, the length of `async_contexts` will determine the number of subrounds. If more subrounds are requested than contexts are passed, invocations will be sequentialized. |\n\n\u003cbr /\u003e\n\nMethods\n-------\n\n### `invoke`\n\n[View source](https://github.com/tensorflow/federated/blob/v0.87.0\nVersion 2.0, January 2004\nLicensed under the Apache License, Version 2.0 (the) \n\n invoke(\n comp: Union[../../tff/framework/MergeableCompForm, ../../tff/Computation],\n arg: Optional[object] = None\n )\n\nInvokes computation `comp` with argument `arg`.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|--------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `comp` | The computation being invoked. The Python type of `comp` expected here (e.g., `pb.Computation`. [`tff.framework.ConcreteComputation`](../../tff/framework/ConcreteComputation), or other) may depend on the context. It is the responsibility of the concrete implementation of this interface to verify that the type of `comp` matches what the context is expecting. |\n| `arg` | The argument passed to the computation. If no argument is passed, this will be `None`. Structural argument types will be normalized into [`tff.structure.Struct`](../../tff/structure/Struct)s. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---|---|\n| The result of invocation, which is context-dependent. ||\n\n\u003cbr /\u003e"]]