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

Complex number support ? #32

Open
AldoLamarre opened this issue Sep 16, 2020 · 4 comments
Open

Complex number support ? #32

AldoLamarre opened this issue Sep 16, 2020 · 4 comments
Labels
feature request New feature or request

Comments

@AldoLamarre
Copy link

Current complex numbers kernel appears to be run on the CPU when in eager execution and fails when run in non eager mode on GPU devices.

tensorflow.python.framework.errors_impl.InvalidArgumentError: Cannot assign a device for operation Complex_1: Could not >satisfy explicit device specification '/device:DML:2' because no supported kernel for DML devices is available.
Colocation Debug Info:
Colocation group had the following types and supported devices:
Root Member(assigned_device_name_index_=-1 requested_device_name_='/device:DML:2' assigned_device_name_='' >resource_device_name_='' supported_device_types_=[CPU] possible_devices_=[]
Complex: CPU

Colocation members, user-requested devices, and framework assigned devices, if any:
Complex_1 (Complex) /device:DML:2

Op: Complex
Node attrs: Tout=DT_COMPLEX64, T=DT_FLOAT
Registered kernels:
device='CPU'; T in [DT_FLOAT]; Tout in [DT_COMPLEX64]
device='CPU'; T in [DT_DOUBLE]; Tout in [DT_COMPLEX128]

Is gpu complex number support expected like in mainline TensorFlow ?

@jstoecker
Copy link
Contributor

Hi Aldo,

You're totally correct: DML devices in TF do not support DT_COMPLEX* types in any kernels at the moment. The reason is pretty simple: DirectML itself doesn't support complex numbers. This may be something we add in the future. Can share the model/script you were running that uses these types? Knowing the scenarios that people want to use DML for can help us prioritize future features.

Thanks!

@AldoLamarre
Copy link
Author

AldoLamarre commented Sep 17, 2020

I was testing with the quantum circuit learner I coded for my master's.

https://github.com/AldoLamarre/quantumcircuitlearning

For quantum machine learning or even basic quantum simulations complex numbers are required. I know you can do some tricks to emulate them like it was done for PyTorch but native support is much better.

@jstoecker jstoecker added the feature request New feature or request label Sep 17, 2020
@jstoecker
Copy link
Contributor

Thanks for sharing this -- it's really informative!

Emulation could definitely be a path forward, and we've taken a similar approach with int64 (not all DX hardware uniformly supports it). I suspect this feature won't make the cut in the near future, since we still have some bigger issues to address in the more traditional deep learning scenarios. That said, emulating the math using existing DML APIs should make it feasible for anyone to add this, which would be an awesome contribution.

@AldoLamarre
Copy link
Author

I understand that it is of low priority currently, as a brand new API you have a lot on your plate. In my defence, some classical deep learning algorithms are using complex numbers like unitary recurrent neural networks who still are the subject of new research today.

As a correction, It does appear that PyTorch now has beta complex number support which it is positive news to me.

For emulation, I had in mind a higher level emulation than the int64 emulation that you are describing. What was done for PyTorch and Theano before that was to use abstract real number tensors to mimic the linear algebra operations done by complex number tensors. This can take a lot time to make work which why I was using TensorFlow as it has native supports. I'm not an expert in GPU programming, but I do not think this of sort of emulation is right for TensorFlow. In TensorFlow, the interface for complex numbers is all there it just need lower level devices that understand complex numbers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants