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

Use int64 when calculating data size in split_acquisition_function #795

Merged
merged 3 commits into from
Nov 22, 2023

Conversation

khurram-ghani
Copy link
Collaborator

Related issue(s)/PRs: None

Summary

Use int64 to calculate the input tensor size when splitting acquisition functions. Otherwise, we overflow for large tensors, e.g. of shape [30000, 1000, 100].

It is tricky to add a unit test to cover the limit, as we run into memory issues. Using mocking or sparse-tensors gets a bit messy, so skipping unit testing for this simple change.

Fully backwards compatible: yes

PR checklist

  • The quality checks are all passing
  • The bug case / new feature is covered by tests
  • Any new features are well-documented (in docstrings or notebooks)

Copy link
Collaborator

@hstojic hstojic left a comment

Choose a reason for hiding this comment

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

see the comment...

@@ -48,7 +48,8 @@ def wrapper(x: TensorType) -> TensorType:
if length == 0:
return fn(x)

elements_per_block = tf.size(x) / length
# Use int64 to calculate the input tensor size, otherwise we can overflow for large tensors.
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is good but could you please add in the docstrings few sentences about memory requirements wrt scaling?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do you mean docstring for split_acquisition_function? Could you give an example please? I could say that the memory usage of tensor x is its flattened size times 8, but that is fairly obvious.
Or do you mean in the optimizer docstring?

Copy link
Collaborator

Choose a reason for hiding this comment

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

i think it would be more appropriate in the generate_continuous_optimizer docstring where tiled_candidates becomes very big - I was thinking of an additional note with a warning that using a large num_initial_samples with high dimensional search space and/or batch sizes will require a lot of memory.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have added a note.

@khurram-ghani khurram-ghani merged commit ae11f17 into develop Nov 22, 2023
12 checks passed
@khurram-ghani khurram-ghani deleted the khurram/split_ack_to_int64 branch November 22, 2023 17:43
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.

2 participants