Skip to content
This repository was archived by the owner on Oct 31, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions trax/optimizers/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,9 +445,11 @@ def _free_accelerators(self, exceptions=(), keep_constants=True):
logging.info('Deleting %d live buffers.', len(live_buffers))
exceptions_buffers = []
for x in fastmath.tree_flatten(exceptions):
if hasattr(x, 'device_buffer'): # DeviceArray
if hasattr(x, 'addressable_shards'): # Array
exceptions_buffers.extend(shard.data for shard in x.addressable_shards)
elif hasattr(x, 'device_buffer'): # DeviceArray
exceptions_buffers.append(x.device_buffer)
if hasattr(x, 'device_buffers'): # ShardedDeviceArray
elif hasattr(x, 'device_buffers'): # ShardedDeviceArray
exceptions_buffers.extend(x.device_buffers)
for b in live_buffers:
should_delete = True
Expand Down