Skip to content

Commit 55cd023

Browse files
authored
minor rewording
1 parent c27c2a3 commit 55cd023

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

docs/source/tutorial/tutorial.advanced-topics.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -370,20 +370,19 @@ timer.result()
370370
## Custom parallelization using coroutines
371371

372372
Adaptive by itself does not implement a way of sharing partial results between function executions.
373-
Its implementation of parallel computation using executors is minimal by design.
374-
Instead the appropriate way to implement custom parallelization is by using coroutines (asynchronous functions).
373+
Instead its implementation of parallel computation using executors is minimal by design.
374+
The appropriate way to implement custom parallelization is by using coroutines (asynchronous functions).
375375

376376
We illustrate this approach by using `dask.distributed` for parallel computations in part because it supports asynchronous operation out-of-the-box.
377-
Let us consider a function `f(x)` which is composed by two parts.
378-
It has a slow part `g` which can be reused by multiple inputs and shared between workers.
379-
It has fast part `h` that will be computed for every `x`.
377+
Let us consider a function `f(x)` which is composed by two parts:
378+
a slow part `g` which can be reused by multiple inputs and shared across function evaluations and a fast part `h` that will be computed for every `x`.
380379

381380
```{code-cell} ipython3
382381
import time
383382
384383
def f(x):
385384
"""
386-
Integer part of `x` will be reused
385+
Integer part of `x` repeats and should be reused
387386
Decimal part requires a new computation
388387
"""
389388
return g(int(x)) + h(x % 1)
@@ -400,7 +399,7 @@ def h(x):
400399
return x**3
401400
```
402401

403-
We need to convert `f` into a dask graph by using `dask.delayed`.
402+
In order to combine reuse of values of `g` with adaptive, we need to convert `f` into a dask graph by using `dask.delayed`.
404403

405404
```{code-cell} ipython3
406405
from dask import delayed
@@ -432,15 +431,15 @@ async def f_parallel(x):
432431
return await future_f
433432
```
434433

435-
Finally we provide the asynchronous function to the `learner` and run it via `AsyncRunner`.
434+
To run the adaptive evaluation we provide the asynchronous function to the `learner` and run it via `AsyncRunner` without specifying an executor.
436435

437436
```{code-cell} ipython3
438437
learner = adaptive.Learner1D(f_parallel, bounds=(-3.5, 3.5))
439438
440439
runner = adaptive.AsyncRunner(learner, goal=lambda l: l.loss() < 0.01, ntasks=20)
441440
```
442441

443-
We await for the runner to finish, and then plot the result.
442+
Finally we await for the runner to finish, and then plot the result.
444443

445444
```{code-cell} ipython3
446445
await runner.task

0 commit comments

Comments
 (0)