From 19e4be56a527af3766c051b6c40a0b2f967bf5d6 Mon Sep 17 00:00:00 2001 From: thanay-sisir Date: Mon, 29 Dec 2025 09:37:45 -0800 Subject: [PATCH 1/3] compute_optimisation --- models/ctm.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/models/ctm.py b/models/ctm.py index 833451ba..073e1bdc 100644 --- a/models/ctm.py +++ b/models/ctm.py @@ -239,11 +239,9 @@ def compute_synchronisation(self, activated_state, decay_alpha, decay_beta, r, s selected_left = activated_state[:, neuron_indices_left] selected_right = activated_state[:, neuron_indices_right] - # Compute outer product of selected neurons - outer = selected_left.unsqueeze(2) * selected_right.unsqueeze(1) - # Resulting matrix is symmetric, so we only need the upper triangle - i, j = torch.triu_indices(n_synch, n_synch) - pairwise_product = outer[:, i, j] + # Compute pairwise products efficiently without intermediate tensor + i, j = torch.triu_indices(n_synch, n_synch, device=activated_state.device) + pairwise_product = selected_left[:, i] * selected_right[:, j] elif self.neuron_select_type == 'random-pairing': # For random-pairing, we compute the sync between specific pairs of neurons From a27496fa1d910c192efb1de396e044debfbc96d0 Mon Sep 17 00:00:00 2001 From: thanay-sisir Date: Sun, 4 Jan 2026 20:21:30 -0500 Subject: [PATCH 2/3] cross-platform path handling in zip_python_code --- utils/housekeeping.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/utils/housekeeping.py b/utils/housekeeping.py index b89c9974..1d040018 100644 --- a/utils/housekeeping.py +++ b/utils/housekeeping.py @@ -9,20 +9,18 @@ def zip_python_code(output_filename): """ - Zips all .py files in the current repository and saves it to the + Zips all .py files in the current repository and saves it to the specified output filename. Args: - output_filename: The name of the output zip file. + output_filename: The name of the output zip file. Defaults to "python_code_backup.zip". """ with zipfile.ZipFile(output_filename, 'w') as zipf: files = glob.glob('models/**/*.py', recursive=True) + glob.glob('utils/**/*.py', recursive=True) + glob.glob('tasks/**/*.py', recursive=True) + glob.glob('*.py', recursive=True) for file in files: - root = '/'.join(file.split('/')[:-1]) - nm = file.split('/')[-1] - zipf.write(os.path.join(root, nm)) + zipf.write(file, arcname=file) def set_seed(seed=42, deterministic=True): """ From 25072f72ad0ca24723bfd58e46c2f6b5c94f7de1 Mon Sep 17 00:00:00 2001 From: thanay-sisir Date: Sun, 4 Jan 2026 21:45:33 -0500 Subject: [PATCH 3/3] cross-platform path handling in zip_python_code --- utils/housekeeping.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/housekeeping.py b/utils/housekeeping.py index 1d040018..b63ee2d2 100644 --- a/utils/housekeeping.py +++ b/utils/housekeeping.py @@ -20,7 +20,7 @@ def zip_python_code(output_filename): with zipfile.ZipFile(output_filename, 'w') as zipf: files = glob.glob('models/**/*.py', recursive=True) + glob.glob('utils/**/*.py', recursive=True) + glob.glob('tasks/**/*.py', recursive=True) + glob.glob('*.py', recursive=True) for file in files: - zipf.write(file, arcname=file) + zipf.write(file, arcname=file.replace(os.sep, '/')) def set_seed(seed=42, deterministic=True): """