tensorflow-metal problems (tf.random.normal) and disappointments

"Last year, I upgraded to an M2 Max laptop, expecting that tensorflow-metal would facilitate effective local prototyping utilizing the Apple Silicon's capabilities.

It has been quite some time since tensorflow-metal was last updated, and there appear to be several unresolved issues noted by the community here. I've personally observed the following behavior with my setup:

Without tensorflow-metal:

import tensorflow as tf

for _ in range(10):
    print(tf.random.normal((3,)).numpy())

[-1.4213976   0.08230731 -1.1260201 ]
[ 1.2913705  -0.47693467 -1.2886043 ]
[ 0.09144169 -1.0892165   0.9313669 ]
[ 1.1081179  0.9865657 -1.0298151]
[ 0.03328908 -0.00655857 -0.02662632]
[-1.002391  -1.1873596 -1.1168724]
[-1.2135247 -1.2823236 -1.0396363]
[-0.03492929 -0.9228362   0.19147137]
[-0.59353966  0.502279    0.80000925]
[-0.82247525 -0.13076428  0.99579334]

With tensorflow-metal:

import tensorflow as tf

for _ in range(10):
    print(tf.random.normal((3,)).numpy())

[ 1.0031303  0.8095635 -0.0610961]
[-1.3544159   0.7045493   0.03666191]
[-1.3544159   0.7045493   0.03666191]
[-1.3544159   0.7045493   0.03666191]
[-1.3544159   0.7045493   0.03666191]
[-1.3544159   0.7045493   0.03666191]
[-1.3544159   0.7045493   0.03666191]
[-1.3544159   0.7045493   0.03666191]
[-1.3544159   0.7045493   0.03666191]
[-1.3544159   0.7045493   0.03666191]

Given these observations, it seems there may be an issue with the randomness of tf.random.normal when using tensorflow-metal.

My current setup includes MacOS 14.5, tensorflow 2.14.1, and tensorflow-macos 2.14.1. I am interested in understanding if there are known solutions or workarounds for this behavior.

Furthermore, could anyone provide an update on whether tensorflow-metal is still being actively developed, or if alternative approaches are recommended for utilizing the GPU capabilities of this hardware?

For what it's worth, here's what's logged:

2024-07-21 13:02:39.605814: I metal_plugin/src/device/metal_device.cc:1154] Metal device set to: Apple M2 Max
2024-07-21 13:02:39.605835: I metal_plugin/src/device/metal_device.cc:296] systemMemory: 32.00 GB
2024-07-21 13:02:39.605840: I metal_plugin/src/device/metal_device.cc:313] maxCacheSize: 10.67 GB
2024-07-21 13:02:39.605869: I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:306] Could not identify NUMA node of platform GPU ID 0, defaulting to 0. Your kernel may not have been built with NUMA support.
2024-07-21 13:02:39.605883: I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:272] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 0 MB memory) -> physical PluggableDevice (device: 0, name: METAL, pci bus id: <undefined>)
tensorflow-metal problems (tf.random.normal) and disappointments
 
 
Q