sionna icon indicating copy to clipboard operation
sionna copied to clipboard

Demapper doesn't work with Tensorflow versions 2.16.0+

Open jso8910 opened this issue 6 months ago • 1 comments

Due to a change in Tensorflow 2.16 (Keras3 no longer has support for complex data types for layers), Demapper is non-functional, returning the following error message (with the personally identifying absolute path removed):

Traceback (most recent call last):
  File "venv/lib/python3.12/site-packages/keras/src/dtype_policies/dtype_policy.py", line 86, in _parse_name
    dtype = backend.standardize_dtype(name)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "venv/lib/python3.12/site-packages/keras/src/backend/common/variables.py", line 521, in standardize_dtype
    raise ValueError(f"Invalid dtype: {dtype}")
ValueError: Invalid dtype: complex64

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "ldpc_test_sionna.py", line 16, in <module>
    demapper = mapping.Demapper("app", "qam", num_bits_per_symbol=1, dtype="complex64")
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "venv/lib/python3.12/site-packages/sionna/mapping.py", line 964, in __init__
    super().__init__(dtype=dtype, **kwargs)
  File "venv/lib/python3.12/site-packages/keras/src/layers/layer.py", line 249, in __init__
    Operation.__init__(self, dtype=dtype, name=name)
  File "/Users/jason/CS_EE_CODE/venv/lib/python3.12/site-packages/keras/src/ops/operation.py", line 26, in __init__
    self._dtype_policy = dtype_policies.get(dtype)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "venv/lib/python3.12/site-packages/keras/src/dtype_policies/__init__.py", line 100, in get
    return DTypePolicy(identifier)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "venv/lib/python3.12/site-packages/keras/src/dtype_policies/dtype_policy.py", line 64, in __init__
    self._compute_dtype, self._variable_dtype = self._parse_name(name)
                                                ^^^^^^^^^^^^^^^^^^^^^^
  File "venv/lib/python3.12/site-packages/keras/src/dtype_policies/dtype_policy.py", line 89, in _parse_name
    raise ValueError(
ValueError: Cannot convert 'complex64' to a mixed precision DTypePolicy. Valid policies include 'mixed_float16', 'mixed_bfloat16', and the name of any float dtype such as 'float32'.

Attempted (and functional) workaround:

  1. Downgrade to Python <= 3.11
  2. run "pip install tensorflow==2.15" (only 2.15 and lower work)

However this is a poor workaround. An immediately actionable fix would be to change requirements.txt to not support tensorflow 2.16 as well as removing Sionna from PyPi for Python 3.12 (which tensorflow 2.16 doesn't support).

There is already an issue on the tensorflow repo: https://github.com/tensorflow/tensorflow/issues/65306 There is also a feature request with confirmation that the maintainers of keras are working on it: https://github.com/keras-team/keras/issues/19860

jso8910 avatar Aug 09 '24 07:08 jso8910