{"record":{"id":"987f99ceb9352924","repo":"jax-ml/jax","slug":"missing-required-keyword-argument-in-layouts","errorCode":null,"errorMessage":"Missing required keyword argument: 'in_layouts'","messagePattern":"Missing required keyword argument: 'in_layouts'","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"jax/_src/pjit.py","lineNumber":2639,"sourceCode":"  elif type(l).__name__ == 'GPUTiledLayout':\n    return LayoutMode.PALLAS_GPU\n  else:\n    return LayoutMode.AUTO\n\n\ndef explicit_layout(f=None, /, *, in_layouts=None):\n  kwargs = dict(in_layouts=in_layouts)\n  if f is None:\n    return lambda g: _explicit_layout(g, **kwargs)\n  return _explicit_layout(f, **kwargs)\n\ndef _explicit_layout(fun, *, in_layouts):\n  def decorator(*args, **kwargs):\n    if in_layouts is None:\n      if \"in_layouts\" in kwargs:\n        _in_layouts = kwargs.pop(\"in_layouts\")\n      else:\n        raise TypeError(\"Missing required keyword argument: 'in_layouts'\")\n    else:\n      _in_layouts = in_layouts\n    args = relayout(args, _in_layouts)\n    mode = get_layout_mode_from_args(args)\n    with use_layout_mode(mode):\n      out = fun(*args)\n    return relayout(out, AutoLayout)\n  return decorator\n\n\ndef relayout(xs, out_layouts):\n  x_flat, treedef = tree_flatten(xs)\n  layouts_flat = flatten_axis_resources(\n      \"relayout out_layouts\", treedef, out_layouts, tupled_args=True)\n  out_flat = [relayout_p.bind(x, dst_layout=l)\n              for x, l in zip(x_flat, layouts_flat)]\n  return tree_unflatten(treedef, out_flat)\n","sourceCodeStart":2621,"sourceCodeEnd":2657,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/pjit.py#L2621-L2657","documentation":"The `explicit_layout` decorator requires an `in_layouts` specification; if it wasn't given at decoration time it must be passed as a keyword at call time. Without it JAX cannot relayout the arguments before invoking the function.","triggerScenarios":"Using `explicit_layout(fun)` or calling the decorated function without `in_layouts=...` in either place.","commonSituations":"Omitting the parameter when experimenting with the new layout API; refactoring away the layouts argument and forgetting call sites that pass it via kwargs.","solutions":["Pass `in_layouts=...` to the decorator","Or pass `in_layouts` as a keyword argument when calling the decorated function","Match the pytree structure of in_layouts to the function arguments"],"exampleFix":"# before\nf = explicit_layout(fun)\nf(x)\n# after\nf = explicit_layout(fun, in_layouts=Layout((1,0)))\nf(x)","handlingStrategy":"validation","validationCode":"assert in_layouts is not None or 'in_layouts' in call_kwargs, 'in_layouts required'","typeGuard":null,"tryCatchPattern":"try:\n    f(x)\nexcept TypeError as e:\n    if 'in_layouts' in str(e):\n        f(x, in_layouts=ly)\n    else:\n        raise","preventionTips":["Pass in_layouts at decoration time","Centralize explicit_layout usage in one helper that always sets layouts"],"tags":["jax","layout","missing-argument"],"backgroundTag":"missing-required-argument","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}