{"record":{"id":"a33c63cb4b2da484","repo":"jax-ml/jax","slug":"name-must-be-non-empty","errorCode":null,"errorMessage":"name must be non-empty","messagePattern":"name must be non-empty","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"warning","filePath":"jax/experimental/mosaic/gpu/utils.py","lineNumber":58,"sourceCode":"from jaxlib.mlir.dialects import vector\nimport numpy as np\n\nlogger = logging.getLogger(__name__)\n\nWARP_SIZE: int = 32\nWARPGROUP_SIZE: int = 128\nWARPS_IN_WARPGROUP: int = WARPGROUP_SIZE // WARP_SIZE\nDYNAMIC = -9223372036854775808\nDYNAMIC32 = -2147483648\nMBARRIER_BYTES = 8\n\n\ndef dump_to_file_or_stdout(\n    content: str, name: str, path: str\n) -> None:\n  \"\"\"Dumps content to path/name if path is non-empty, else to stdout.\"\"\"\n  if not name:\n    raise ValueError(\"name must be non-empty\")\n  if not path:\n    print(content)\n    return\n  filepath = os.path.join(path, name)\n  try:\n    with open(filepath, \"w\") as f:\n      f.write(content)\n      f.write(\"\\n\")\n  except OSError as e:\n    logger.error(\"Failed to write output to %s: %s\", filepath, e)\n    # TODO(bchetioui): revisit whether this default of writing to stdout is the\n    # right one. If we change it, we will have to change the corresponding C++\n    # implementation as well.\n    logger.error(\"Output will be written to stdout instead.\")\n    print(content)\n\n\ndef gpu_address_space_to_nvptx(address_space: gpu.AddressSpace) -> int:","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/experimental/mosaic/gpu/utils.py#L40-L76","documentation":"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.","triggerScenarios":"Calling utils.dump_to_file_or_stdout(content, name=\"\", path=...) directly, or configuring an MGPU lowering/dump option with an empty dump name string.","commonSituations":"Programmatically building dump filenames (e.g. f\"{kernel_name}_{'/'.join(passes)}\" that collapses to empty), or misconfigured dump flags in lower_mgpu_module.","solutions":["Pass a non-empty, filesystem-safe name (include kernel/pipeline identifier)","Sanitize generated names: fall back to a default like 'dump.mlir' when the computed name is empty","Check lower_mgpu_module dump options for empty strings"],"exampleFix":"# before\nname = f\"{prefix}{suffix}\"  # may be ''\ndump_to_file_or_stdout(content, name, path)\n# after\nname = f\"{prefix}{suffix}\" or \"dump.mlir\"\ndump_to_file_or_stdout(content, name, path)","handlingStrategy":"validation","validationCode":"if not name:\n    name = 'dump.mlir'\ndump_to_file_or_stdout(content, name, path)","typeGuard":"def is_valid_dump_name(name):\n    return isinstance(name, str) and bool(name.strip())","tryCatchPattern":null,"preventionTips":["Default generated dump names to a constant fallback","Validate dump options before calling lower_mgpu_module"],"tags":["mosaic","gpu","io","dump","argument-validation"],"backgroundTag":"empty-argument-validation","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}