Skip to content

Conversation

@izdeby
Copy link
Contributor

@izdeby izdeby commented Jul 2, 2019

Stack from ghstack:

Differential Revision: D16083575

@pytorchbot pytorchbot added module: build Build system issues module: cuda Related to torch.cuda, and CUDA support in general module: internals Related to internal abstractions in c10 and ATen module: operators module: tests Issues related to tests (not the torch.testing module) labels Jul 2, 2019
@izdeby izdeby changed the title BFloat16 for cuda [WIP] BFloat16 for cuda Jul 2, 2019
BFloat16 for cuda

gh-metadata: pytorch pytorch 22428 gh/izdeby/13/head
@pytorchbot pytorchbot added the module: cpu CPU specific problem (e.g., perf, algorithm) label Jul 8, 2019
BFloat16 for cuda

gh-metadata: pytorch pytorch 22428 gh/izdeby/13/head
@izdeby izdeby changed the title [WIP] BFloat16 for cuda BFloat16 for cuda Jul 8, 2019
@izdeby izdeby requested review from VitalyFedyunin, bddppq, ezyang, gchanan, jerryzh168 and zou3519 and removed request for gchanan and jerryzh168 July 8, 2019 23:23
@izdeby izdeby changed the title BFloat16 for cuda Enable TestTorch tests for BFloat16 on cuda Jul 9, 2019
BFloat16 for cuda

gh-metadata: pytorch pytorch 22428 gh/izdeby/13/head
This was referenced Jul 9, 2019
backend_types['CUDA'].discard('BFloat16')
if not option.get('cuda_bfloat16', False):
if 'CUDA' in backend_types:
backend_types['CUDA'].discard('BFloat16')
Copy link
Contributor

Choose a reason for hiding this comment

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

Not really removed, eh? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

its coming soon :)

@ezyang
Copy link
Contributor

ezyang commented Jul 9, 2019

It's a pretty big patch but it all looks reasonable to me. Letting @gchanan take a look.

@izdeby
Copy link
Contributor Author

izdeby commented Jul 9, 2019

It's a pretty big patch but it all looks reasonable to me. Letting @gchanan take a look.

@ezyang, yeah i know its big. The problem is that there are a lot of inner dependencies from one thing to another. For example, i had to enable couple methods just to make test utils work with BFloat16 type as it is and without hacks.

izdeby added 2 commits July 9, 2019 14:08
BFloat16 for cuda

gh-metadata: pytorch pytorch 22428 gh/izdeby/13/head
≈BFloat16 for cuda

gh-metadata: pytorch pytorch 22428 gh/izdeby/13/head
cpu_bool: True
cuda_bool: True
cpu_bfloat16: True
cuda_bfloat16: True
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess this is more related to the CPU review, but I would have expected corresponding bfloat16 definitions everywhere there are bool definitions, e.g. for masked_fill. Is there a reason those aren't enabled?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This PR is already big enough. More functionality will come in next PRs.


void add_kernel_cuda(TensorIterator& iter, Scalar alpha_scalar) {
AT_DISPATCH_ALL_TYPES_AND(kHalf, iter.dtype(), "add_cuda", [&]() {
AT_DISPATCH_ALL_TYPES_AND2(kHalf, kBFloat16, iter.dtype(), "add_cuda", [&]() {
Copy link
Contributor

Choose a reason for hiding this comment

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

why are we doing math here? I thought this PR was for adding non-math support?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is needed for the test/common_utils.py. The way we compare two tensors requires some math ops.

LIST(APPEND extra_src "${CMAKE_CURRENT_SOURCE_DIR}/generated/THC${THC_FILE}Bool.cu")
endforeach()

foreach(THC_FILE TensorMathReduce TensorMathCompareT TensorMathCompare TensorMathPointwise)
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a reason these files are in different orders in the various lists? It makes it hard to quickly figure out what files are supported for which types.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorted

@izdeby izdeby changed the title Enable TestTorch tests for BFloat16 on cuda Enable test_torch.py tests for BFloat16 on cuda Jul 10, 2019
izdeby added 2 commits July 11, 2019 13:48
Enable test_torch BFloat16 tests for cuda

gh-metadata: pytorch pytorch 22428 gh/izdeby/13/head
Enable test_torch BFloat16 tests for cuda

gh-metadata: pytorch pytorch 22428 gh/izdeby/13/head
@izdeby izdeby requested a review from gchanan July 11, 2019 21:38
@izdeby izdeby closed this Jul 11, 2019
@facebook-github-bot facebook-github-bot deleted the gh/izdeby/13/head branch October 28, 2019 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module: build Build system issues module: cpu CPU specific problem (e.g., perf, algorithm) module: cuda Related to torch.cuda, and CUDA support in general module: internals Related to internal abstractions in c10 and ATen module: tests Issues related to tests (not the torch.testing module)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants