Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ccuetom committed Nov 15, 2024
1 parent 13ec2ea commit 61343eb
Show file tree
Hide file tree
Showing 9 changed files with 1,143 additions and 2,925 deletions.
3 changes: 2 additions & 1 deletion stride/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,8 @@ def _dealloc(*args):
if nxt.name_idx in prev:
input_grad = await _maybe_sum(prev[nxt.name_idx], input_grad)

if not isinstance(input_grad, types.awaitable_types) and nxt.op.runtime_id != runtime.uid:
if not isinstance(input_grad, types.awaitable_types) \
and hasattr(nxt.op, 'runtime_id') and nxt.op.runtime_id != runtime.uid:
input_grad = await runtime.put(input_grad)
deallocs.append(input_grad)

Expand Down
6 changes: 1 addition & 5 deletions stride/optimisation/optimisation_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,11 +664,7 @@ def clear(self, **kwargs):
self._current_block = None
self.running_id = 0

load_kwargs = dict(path=self.problem.output_folder,
project_name=self.problem.name, version=0)
load_kwargs.update(kwargs)

self.remove_file(**load_kwargs)
self.remove_file(**kwargs)

def blocks(self, num, *iters, restart=False, restart_id=-1, **kwargs):
"""
Expand Down
1 change: 1 addition & 0 deletions stride/problem/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,7 @@ def __set_desc__(self, description, **kwargs):

inner = []
for each in description.inner:
each = [e.decode() if isinstance(e, bytes) else e for e in each]
inner.append(slice(
int(each[0]) if each[0] != 'None' else None,
int(each[1]) if each[1] != 'None' else None,
Expand Down
91 changes: 60 additions & 31 deletions stride_examples/tutorials/01_basics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,18 @@
"execution_count": 1,
"id": "manual-genius",
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"x"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from stride import Scalar\n",
"from stride_examples import f, g, h\n",
Expand Down Expand Up @@ -187,7 +198,18 @@
"execution_count": 2,
"id": "psychological-distributor",
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"scalar"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from stride import Operator, Scalar\n",
"\n",
Expand Down Expand Up @@ -266,10 +288,11 @@
"output_type": "stream",
"text": [
"Updating variable m,\n",
"\t grad before processing in range [-1.050360e+03, -1.050360e+03]\n",
"\t grad after processing in range [-1.050360e+03, -1.050360e+03]\n",
"\t variable range before update [-1.050360e+03, -1.050360e+03]\n",
"\t variable range after update [0.000000e+00, 0.000000e+00]\n"
"\t grad before processing in range [2.627646e-17, 2.627646e-17]\n",
"\t grad after processing in range [1.313823e-19, 1.313823e-19]\n",
"\t variable range before update [2.627646e-17, 2.627646e-17]\n",
"\t taking final update step of 1.000000e+00 [unclipped step of 1.000000e+00]\n",
"\t variable range after update [2.614507e-17, 2.614507e-17]\n"
]
},
{
Expand Down Expand Up @@ -313,35 +336,41 @@
"output_type": "stream",
"text": [
"Updating variable m,\n",
"\t grad before processing in range [-1.050360e+03, -1.050360e+03]\n",
"\t grad after processing in range [-1.050360e+03, -1.050360e+03]\n",
"\t variable range before update [0.000000e+00, 0.000000e+00]\n",
"\t variable range after update [1.050360e+03, 1.050360e+03]\n",
"\t grad before processing in range [5.242153e-17, 5.242153e-17]\n",
"\t grad after processing in range [1.307254e-19, 1.307254e-19]\n",
"\t variable range before update [2.614507e-17, 2.614507e-17]\n",
"\t taking final update step of 1.000000e+00 [unclipped step of 1.000000e+00]\n",
"\t variable range after update [2.601435e-17, 2.601435e-17]\n",
"Updating variable m,\n",
"\t grad before processing in range [1.050360e+03, 1.050360e+03]\n",
"\t grad after processing in range [1.050360e+03, 1.050360e+03]\n",
"\t variable range before update [1.050360e+03, 1.050360e+03]\n",
"\t variable range after update [0.000000e+00, 0.000000e+00]\n",
"\t grad before processing in range [7.843588e-17, 7.843588e-17]\n",
"\t grad after processing in range [1.300717e-19, 1.300717e-19]\n",
"\t variable range before update [2.601435e-17, 2.601435e-17]\n",
"\t taking final update step of 1.000000e+00 [unclipped step of 1.000000e+00]\n",
"\t variable range after update [2.588428e-17, 2.588428e-17]\n",
"Updating variable m,\n",
"\t grad before processing in range [1.050360e+03, 1.050360e+03]\n",
"\t grad after processing in range [1.050360e+03, 1.050360e+03]\n",
"\t variable range before update [0.000000e+00, 0.000000e+00]\n",
"\t variable range after update [-1.050360e+03, -1.050360e+03]\n",
"\t grad before processing in range [1.043202e-16, 1.043202e-16]\n",
"\t grad after processing in range [1.294214e-19, 1.294214e-19]\n",
"\t variable range before update [2.588428e-17, 2.588428e-17]\n",
"\t taking final update step of 1.000000e+00 [unclipped step of 1.000000e+00]\n",
"\t variable range after update [2.575486e-17, 2.575486e-17]\n",
"Updating variable m,\n",
"\t grad before processing in range [-1.050360e+03, -1.050360e+03]\n",
"\t grad after processing in range [-1.050360e+03, -1.050360e+03]\n",
"\t variable range before update [-1.050360e+03, -1.050360e+03]\n",
"\t variable range after update [0.000000e+00, 0.000000e+00]\n",
"\t grad before processing in range [1.300750e-16, 1.300750e-16]\n",
"\t grad after processing in range [1.287743e-19, 1.287743e-19]\n",
"\t variable range before update [2.575486e-17, 2.575486e-17]\n",
"\t taking final update step of 1.000000e+00 [unclipped step of 1.000000e+00]\n",
"\t variable range after update [2.562608e-17, 2.562608e-17]\n",
"Updating variable m,\n",
"\t grad before processing in range [-1.050360e+03, -1.050360e+03]\n",
"\t grad after processing in range [-1.050360e+03, -1.050360e+03]\n",
"\t variable range before update [0.000000e+00, 0.000000e+00]\n",
"\t variable range after update [1.050360e+03, 1.050360e+03]\n",
"\t grad before processing in range [1.557011e-16, 1.557011e-16]\n",
"\t grad after processing in range [1.281304e-19, 1.281304e-19]\n",
"\t variable range before update [2.562608e-17, 2.562608e-17]\n",
"\t taking final update step of 1.000000e+00 [unclipped step of 1.000000e+00]\n",
"\t variable range after update [2.549795e-17, 2.549795e-17]\n",
"Updating variable m,\n",
"\t grad before processing in range [1.050360e+03, 1.050360e+03]\n",
"\t grad after processing in range [1.050360e+03, 1.050360e+03]\n",
"\t variable range before update [1.050360e+03, 1.050360e+03]\n",
"\t variable range after update [0.000000e+00, 0.000000e+00]\n"
"\t grad before processing in range [1.811990e-16, 1.811990e-16]\n",
"\t grad after processing in range [1.274898e-19, 1.274898e-19]\n",
"\t variable range before update [2.549795e-17, 2.549795e-17]\n",
"\t taking final update step of 1.000000e+00 [unclipped step of 1.000000e+00]\n",
"\t variable range after update [2.537046e-17, 2.537046e-17]\n"
]
}
],
Expand Down Expand Up @@ -389,7 +418,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.5"
"version": "3.11.8"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion stride_examples/tutorials/02_problem_definition.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.5"
"version": "3.11.8"
}
},
"nbformat": 4,
Expand Down
269 changes: 153 additions & 116 deletions stride_examples/tutorials/03_acoustic_modelling.ipynb

Large diffs are not rendered by default.

Loading

0 comments on commit 61343eb

Please sign in to comment.