Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add checkpointed_scan #60

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
more logging
dlwh committed Jan 21, 2024
commit ee7b32bbd8dd6edf1f63741134602e99488b89c5
4 changes: 3 additions & 1 deletion src/haliax/nn/scan.py
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@

import haliax
import haliax.util
from haliax.jax_utils import filter_checkpoint
from haliax.jax_utils import filter_checkpoint, named_call

from ..axis import Axis

@@ -90,6 +90,7 @@ def fn(*args, **kwargs):

return fn

@named_call(name="Stacked.scan")
def scan(self, init, *args, **kwargs):
if self.gradient_checkpointing:
do_block = filter_checkpoint(self._do_block, prevent_cse=self.prevent_cse)
@@ -105,6 +106,7 @@ def scan(self, init, *args, **kwargs):
else:
return haliax.scan(self._do_block, self.Block)(init, self.stacked, *args, **kwargs)

@named_call(name="Stacked.fold")
def fold(self, init, *args, **kwargs):
if self.gradient_checkpointing:
do_block = filter_checkpoint(self._do_block, prevent_cse=self.prevent_cse)