Skip to content

Small DyAb bugfixes#107

Merged
ncfrey merged 4 commits intoprescient-design:mainfrom
tomyyyD:main
Jun 13, 2025
Merged

Small DyAb bugfixes#107
ncfrey merged 4 commits intoprescient-design:mainfrom
tomyyyD:main

Conversation

@tomyyyD
Copy link
Collaborator

@tomyyyD tomyyyD commented Jun 13, 2025

Some small modifications to the DyAb class

  • update diff_channel_1 option "sub" to "diff" becuase "sub" is not a valid operation in _resize_embeddings
  • add to(self.device) to embeddings, so that the model can be trained on a CUDA device. In my testing on pcluster, without this, there exists tensors on both CPU and CUDA, which cuases an exception to be raised.

@tomyyyD tomyyyD changed the title Small DyAb tweaks Small DyAb bugfixes Jun 13, 2025
@ncfrey ncfrey requested a review from Copilot June 13, 2025 22:14
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes an invalid default for diff_channel_1 and ensures embeddings are moved to the correct device before training, preventing tensor placement errors.

  • Changed diff_channel_1 default from "sub" to "diff" for consistency with _resize_embeddings
  • Added .to(self.device) when concatenating embeddings to avoid CPU/CUDA mismatch
Comments suppressed due to low confidence (2)

src/lobster/model/_dyab.py:222

  • Transferring each tensor individually inside the list comprehension can incur multiple device-to-device copies. Consider concatenating on CPU first and then moving the final tensor to the target device with a single .to(self.device) call.
embeddings1 = torch.concat([this.embedding_cache[seq].to(self.device) for seq in sequences1], dim=0)

src/lobster/model/_dyab.py:223

  • Similar to embeddings1, performing .to(self.device) on each tensor can be inefficient. It’s better to concat on CPU then call .to(self.device) once on the result.
embeddings2 = torch.concat([this.embedding_cache[seq].to(self.device) for seq in sequences2], dim=0)

@ncfrey ncfrey merged commit 902caa2 into prescient-design:main Jun 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants