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

64-bit indexing Adam #1786

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

64-bit indexing Adam #1786

wants to merge 1 commit into from

Conversation

cdm114514
Copy link

@cdm114514 cdm114514 commented Mar 21, 2024

Issues:

  1. Incomplete Testing in testLargeTensor Method:
    Location: tests/L0/run_optimizers/test_adam.py.
    Description: The method aimed to compare the correctness of FusedAdam by applying the step() function to two large tensors with same gradient(another one using torch.optim.adam). However, the test only invoked step() on the first optimizer.

  2. Type Overflow in TensorListMetadata:
    Location: csrc/multi_tensor_apply.cuh
    Description: The data structures sizes[] and block_to_chunk[] within TensorListMetadata were statically typed as integers. This led to overflow when managing tensors with lengths surpassing INT_MAX.

Solution:

  • Added an optimizer step to optimizer2 within testLargeTensor of tests/L0/run_optimizers/test_adam.py for accurate testing of large tensor operations.

  • Refactored TensorListMetadata in csrc/multi_tensor_apply.cuh:
    A modification of the template to accommodate either int32_t or int64_t sizes, ensuring backward compatibility with the existing declaration method (TensorListMetadata)

  • Added multi_tensor_apply64 to specifically handle int64_t size indexing for Adam. This new function mirrors the functionality of multi_tensor_apply but incorporates checks against depth_to_max_tensors64 for enhanced large tensor support.

  • Modifications have been made in csrc/multi_tensor_adam.cu to invoke multi_tensor_apply64 and utilize the specified data structure according to index_t.

- Added an optimizer step to `optimizer2` within `testLargeTensor` of `tests/L0/run_optimizers/test_adam.py` for accurate testing of large tensor operations.

- Refactored `TensorListMetadata` in `csrc/multi_tensor_apply.cuh`:
  - Introduced `depth_to_max_tensors64` for `int64` size support.
  - Modified the template to accommodate `int32_t` or `int64_t` sizes.

- Added `multi_tensor_apply64` for `int64_t` size indexing adam.
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.

1 participant