# TypeError: tir.Schedule is not registered via TVM\_REGISTER\_NODE\_TYPE when using multiprocessing

**URL:** <https://discuss.tvm.apache.org/t/typeerror-tir-schedule-is-not-registered-via-tvm-register-node-type-when-using-multiprocessing/16430>\
**Category:** Troubleshooting\
**Created:** [February 24, 2024, 12:56pm UTC](https://discuss.tvm.apache.org/t/typeerror-tir-schedule-is-not-registered-via-tvm-register-node-type-when-using-multiprocessing/16430 "2024-02-24T12:56:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![felix\_ro](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/felix_ro/32/5319_2.png) [@felix\_ro](https://discuss.tvm.apache.org/u/felix_ro)\
**Post date:** [February 24, 2024, 12:56pm UTC](https://discuss.tvm.apache.org/t/typeerror-tir-schedule-is-not-registered-via-tvm-register-node-type-when-using-multiprocessing/16430/1 "2024-02-24T12:56:34Z")

</div>

I have been playing around with different tuning approaches and wanted to use multiprocessing.

I am trying to have multiple processes work on a list of schedules. I implemented the following, and it works fine when using a `ThreadPoolExecutor` instead of a `ProcessPoolExecutor`. It takes a Schedule from a list of Schedules, sends it to a tuning function, and returns the tuned Schedule.

The code I am using:

```auto
with ProcessPoolExecutor(max_workers=self.context.num_threads) as executor:
    futures = [executor.submit(self._tune_schedule, tune_schedules[id], id)
               for id in range(num_sch_to_tuner)]

    for future in as_completed(futures):
        tuned_schedule, id = future.result()
        tune_schedules[id] = tuned_schedule

```

The error I get:

```auto
Process SpawnProcess-1:
Traceback (most recent call last):
  File "/Users/felix/anaconda3/envs/tvm-llvm/lib/python3.10/multiprocessing/process.py", line 314, in _bootstrap
    self.run()
  File "/Users/felix/anaconda3/envs/tvm-llvm/lib/python3.10/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/felix/anaconda3/envs/tvm-llvm/lib/python3.10/concurrent/futures/process.py", line 240, in _process_worker
    call_item = call_queue.get(block=True)
  File "/Users/felix/anaconda3/envs/tvm-llvm/lib/python3.10/multiprocessing/queues.py", line 122, in get
    return _ForkingPickler.loads(res)
  File "/Users/felix/Documents/Projects/ACS-Project/tvm/python/tvm/runtime/object.py", line 101, in __setstate__
    self. __init_handle_by_constructor__ (_ffi_node_api.LoadJSON, handle)
  File "/Users/felix/Documents/Projects/ACS-Project/tvm/python/tvm/_ffi/_ctypes/object.py", line 145, in __init_handle_by_constructor__
    handle = __init_by_constructor__ (fconstructor, args)
  File "/Users/felix/Documents/Projects/ACS-Project/tvm/python/tvm/_ffi/_ctypes/packed_func.py", line 262, in __init_handle_by_constructor__
    raise_last_ffi_error()
  File "/Users/felix/Documents/Projects/ACS-Project/tvm/python/tvm/_ffi/base.py", line 481, in raise_last_ffi_error
    raise py_err
TypeError: Traceback (most recent call last):
  File "/Users/felix/Documents/Projects/ACS-Project/tvm/src/node/reflection.cc", line 158
TypeError: tir.Schedule is not registered via TVM_REGISTER_NODE_TYPE

```

I have seen that the typical suggestion for this problem is to rebuild TVM, which I have done, but it did not resolve the issue. I am likely doing something wrong in creating the schedule copy for the new process. I would be thankful if someone could help me figure out the proper approach to this.

---

<div class="post-metadata">

**Author:** ![LeiWang1999](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/leiwang1999/32/6064_2.png) [@LeiWang1999](https://discuss.tvm.apache.org/u/LeiWang1999)\
**Post date:** [February 24, 2024, 1:55pm UTC](https://discuss.tvm.apache.org/t/typeerror-tir-schedule-is-not-registered-via-tvm-register-node-type-when-using-multiprocessing/16430/2 "2024-02-24T13:55:03Z")

</div>

I’d encountered the same issue and the solution I applied is using sch.mod as parameters for subprocesses, instead of tir.Schedule

---

<div class="post-metadata">

**Author:** ![felix\_ro](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/felix_ro/32/5319_2.png) [@felix\_ro](https://discuss.tvm.apache.org/u/felix_ro)\
**Post date:** [February 25, 2024, 12:09pm UTC](https://discuss.tvm.apache.org/t/typeerror-tir-schedule-is-not-registered-via-tvm-register-node-type-when-using-multiprocessing/16430/3 "2024-02-25T12:09:39Z")

</div>

Thank you for the advice; that fixed it for me. I have been trying to pass the IRModule and Trace to the process to reconstruct the Schedule there. However, accessing the trace in the subprocess leads to a segmentation fault. Have you run into this issue as well?

---

<div class="post-metadata">

**Author:** ![felix\_ro](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/felix_ro/32/5319_2.png) [@felix\_ro](https://discuss.tvm.apache.org/u/felix_ro)\
**Post date:** [February 25, 2024, 12:22pm UTC](https://discuss.tvm.apache.org/t/typeerror-tir-schedule-is-not-registered-via-tvm-register-node-type-when-using-multiprocessing/16430/4 "2024-02-25T12:22:22Z")

</div>

Serializing the trace as JSON resolves it.
