Skip to content

RuntimeWarning: nanobind: type '_Globals' was already registered! #14

@banach-space

Description

@banach-space

Hey,

I sadly I am unable to run examples from Lighthous, e.g. mlp_from_file.py. Here's a diff I need to apply for things to work on my AArch64 machine (*):

diff --git a/pyproject.toml b/pyproject.toml
index ba0cba7..b78aef5 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -10,7 +10,7 @@ dependencies = [
 # Additional "targets" which pull in optional dependencies -- use `uv sync --extra TARGET`
 ingress_torch_cpu = [
     "torch==v2.8.0+cpu",
-    "torch-mlir==20251003.589"
+    "torch-mlir==20251116.633"
 ]
 ingress_torch_nvidia = [
     "torch==2.8.0",  # Nvidia-enabled version of torch

Here's a mini Python repro:

from mlir import ir
from torch_mlir  import fx
print(ir.Context)

Copy that into Lighthouse checkout. Then,

$ uv venv
$ uv sync
$ uv sync --extra ingress-torch-cpu
$ uv run python temp.py
<frozen importlib._bootstrap>:488: RuntimeWarning: nanobind: type '_Globals' was already registered!

<frozen importlib._bootstrap>:488: RuntimeWarning: nanobind: type 'DiagnosticSeverity' was already registered!

Critical nanobind error: refusing to add duplicate key "ERROR" to enumeration "mlir._mlir_libs._mlir.ir.DiagnosticSeverity"!

IIUC, this error caused by some global state from MLIR Python bindings being registered twice.

Kind request, could somebody try this on X86? Thanks!

-Andrzej

(*) Updating torch-mlir version as the AArch64 releases are a fairly recent addition.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions