Mr Mustard trainer issue with backend

Hi
I am trying to run the map_trainer example, got following error:

--------------------------------------------------------------------------- RayTaskError(TypeError) Traceback (most recent call last) Cell In[1], line 18 15 return -fidelity(s, target) 17 # Use case 0: Calculate the cost of a randomly initialized circuit 5 times without optimizing it. —> 18 results_0 = map_trainer( 19 cost_fn=cost_fn, 20 tasks=5, 21 ) 23 # Use case 1: Run circuit optimization 5 times on randomly initialized circuits. 24 results_1 = map_trainer( 25 cost_fn=cost_fn, 26 device_factory=make_circ, (…) 29 symplectic_lr=0.05, 30 ) File ~/Photonic Neural Network/MrMustard/mrmustard/training/trainer.py:379, in map_trainer(trainer, tasks, pbar, unblock, num_cpus, **kwargs) 376 if not unblock: 377 # blocks and wait till all tasks complete to return the end results. 378 if pbar: → 379 results = list( 380 track( 381 _iter_futures(promises), 382 description=f"{len(promises)} tasks running…", 383 total=len(promises), 384 ) 385 ) 386 else: 387 results = ray.get(promises) File ~/anaconda3/envs/Xanadu/lib/python3.11/site-packages/rich/progress.py:175, in track(sequence, description, total, completed, auto_refresh, console, transient, get_time, refresh_per_second, style, complete_style, finished_style, pulse_style, update_period, disable, show_speed) 164 progress = Progress( 165 *columns, 166 auto_refresh=auto_refresh, (…) 171 disable=disable, 172 ) 174 with progress: → 175 yield from progress.track( 176 sequence, 177 total=total, 178 completed=completed, 179 description=description, 180 update_period=update_period, 181 ) File ~/anaconda3/envs/Xanadu/lib/python3.11/site-packages/rich/progress.py:1225, in Progress.track(self, sequence, total, completed, task_id, description, update_period) 1223 if self.live.auto_refresh: 1224 with _TrackThread(self, task_id, update_period) as track_thread: → 1225 for value in sequence: 1226 yield value 1227 track_thread.completed += 1 File ~/Photonic Neural Network/MrMustard/mrmustard/training/trainer.py:215, in _iter_futures(futures) 213 while futures: 214 done, futures = ray.wait(futures) → 215 yield ray.get(done[0]) File ~/anaconda3/envs/Xanadu/lib/python3.11/site-packages/ray/_private/auto_init_hook.py:21, in wrap_auto_init..auto_init_wrapper(*args, **kwargs) 18 @wraps(fn) 19 def auto_init_wrapper(*args, **kwargs): 20 auto_init_ray() —> 21 return fn(*args, **kwargs) File ~/anaconda3/envs/Xanadu/lib/python3.11/site-packages/ray/_private/client_mode_hook.py:103, in client_mode_hook..wrapper(*args, **kwargs) 101 if func.name != “init” or is_client_mode_enabled_by_default: 102 return getattr(ray, func.name)(*args, **kwargs) → 103 return func(*args, **kwargs) File ~/anaconda3/envs/Xanadu/lib/python3.11/site-packages/ray/_private/worker.py:2755, in get(object_refs, timeout) 2749 raise ValueError( 2750 f"Invalid type of object refs, {type(object_refs)}, is given. " 2751 "‘object_refs’ must either be an ObjectRef or a list of ObjectRefs. " 2752 ) 2754 # TODO(ujvl): Consider how to allow user to retrieve the ready objects. → 2755 values, debugger_breakpoint = worker.get_objects(object_refs, timeout=timeout) 2756 for i, value in enumerate(values): 2757 if isinstance(value, RayError): File ~/anaconda3/envs/Xanadu/lib/python3.11/site-packages/ray/_private/worker.py:906, in Worker.get_objects(self, object_refs, timeout, return_exceptions) 904 global_worker.core_worker.dump_object_store_memory_usage() 905 if isinstance(value, RayTaskError): → 906 raise value.as_instanceof_cause() 907 else: 908 raise value RayTaskError(TypeError): ray::train_device() (pid=3643480, ip=128.111.58.29) File “/home/rahul/Photonic Neural Network/MrMustard/mrmustard/training/trainer.py”, line 181, in train_device final_cost = cost_fn() ^^^^^^^^^ File “/tmp/ipykernel_3641918/1782703836.py”, line 14, in cost_fn File “/home/rahul/Photonic Neural Network/MrMustard/mrmustard/lab/abstract/state.py”, line 616, in rshift return other.primal(self) ^^^^^^^^^^^^^^^^^^ File “/home/rahul/Photonic Neural Network/MrMustard/mrmustard/lab/circuit.py”, line 63, in primal state = op.primal(state) ^^^^^^^^^^^^^^^^ File “/home/rahul/Photonic Neural Network/MrMustard/mrmustard/lab/abstract/transformation.py”, line 85, in primal new_state = self._transform_gaussian(state, dual=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/home/rahul/Photonic Neural Network/MrMustard/mrmustard/lab/abstract/transformation.py”, line 115, in _transform_gaussian X, Y, d = self.XYd(allow_none=False) if not dual else self.XYd_dual(allow_none=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/home/rahul/Photonic Neural Network/MrMustard/mrmustard/lab/abstract/transformation.py”, line 235, in XYd Y = math.zeros_like(X) if self.Y_matrix is None else self.Y_matrix ^^^^^^^^^^^^^^^^^^ File “/home/rahul/Photonic Neural Network/MrMustard/mrmustard/math/backend_manager.py”, line 1224, in zeros_like return self._apply(“zeros_like”, (array,)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/home/rahul/Photonic Neural Network/MrMustard/mrmustard/math/backend_manager.py”, line 111, in _apply return attr(*args) ^^^^^^^^^^^ File “/home/rahul/Photonic Neural Network/MrMustard/mrmustard/math/backend_numpy.py”, line 382, in zeros_like return np.zeros(np.array(array).shape, dtype=array.dtype) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: Cannot interpret ‘tf.float64’ as a data type

Hi @Rahps97 !

I actually cannot replicate your error. I get a different error instead :melting_face: . I’ve forwarded your question to the MrMustard developers. Note that they may take a few days to get back to you because of the holidays next week.

Isit some numpy related error? I got that in a new environment as well. Thanks, and Happy Holidays to you and developers.

Hi @Rahps97 ,

Yes, the error I got was related to Numpy but I think one of my colleagues was able to replicate your issue. We’re still not sure what’s the cause so we’ll get back to you in the new year.

Happy holidays to you too!