jax-ml/jax · warning · ValueError

name must be non-empty

Error message

name must be non-empty

What it means

Raised by dump_to_file_or_stdout in Mosaic GPU utils, which dumps generated IR/text to path/name (or stdout when path is empty). An empty name would construct an invalid file path, so it rejects empty names up front. Callers typically reach this via lower_mgpu_module's dump options.

Source

Thrown at jax/experimental/mosaic/gpu/utils.py:58

from jaxlib.mlir.dialects import vector
import numpy as np

logger = logging.getLogger(__name__)

WARP_SIZE: int = 32
WARPGROUP_SIZE: int = 128
WARPS_IN_WARPGROUP: int = WARPGROUP_SIZE // WARP_SIZE
DYNAMIC = -9223372036854775808
DYNAMIC32 = -2147483648
MBARRIER_BYTES = 8


def dump_to_file_or_stdout(
    content: str, name: str, path: str
) -> None:
  """Dumps content to path/name if path is non-empty, else to stdout."""
  if not name:
    raise ValueError("name must be non-empty")
  if not path:
    print(content)
    return
  filepath = os.path.join(path, name)
  try:
    with open(filepath, "w") as f:
      f.write(content)
      f.write("\n")
  except OSError as e:
    logger.error("Failed to write output to %s: %s", filepath, e)
    # TODO(bchetioui): revisit whether this default of writing to stdout is the
    # right one. If we change it, we will have to change the corresponding C++
    # implementation as well.
    logger.error("Output will be written to stdout instead.")
    print(content)


def gpu_address_space_to_nvptx(address_space: gpu.AddressSpace) -> int:

View on GitHub (pinned to 1e1c6a8fc0)

Solutions

  1. Pass a non-empty, filesystem-safe name (include kernel/pipeline identifier)
  2. Sanitize generated names: fall back to a default like 'dump.mlir' when the computed name is empty
  3. Check lower_mgpu_module dump options for empty strings

Example fix

# before
name = f"{prefix}{suffix}"  # may be ''
dump_to_file_or_stdout(content, name, path)
# after
name = f"{prefix}{suffix}" or "dump.mlir"
dump_to_file_or_stdout(content, name, path)
Defensive patterns

Strategy: validation

Validate before calling

if not name:
    name = 'dump.mlir'
dump_to_file_or_stdout(content, name, path)

Type guard

def is_valid_dump_name(name):
    return isinstance(name, str) and bool(name.strip())

Prevention

When it happens

Trigger: Calling utils.dump_to_file_or_stdout(content, name="", path=...) directly, or configuring an MGPU lowering/dump option with an empty dump name string.

Common situations: Programmatically building dump filenames (e.g. f"{kernel_name}_{'/'.join(passes)}" that collapses to empty), or misconfigured dump flags in lower_mgpu_module.

Related errors


AI-assisted analysis of jax-ml/jax@1e1c6a8fc0 (2026-08-27). Data as JSON: /api/errors/a33c63cb4b2da484. Report an issue: GitHub.