jax-ml/jax · error · NotImplementedError

Only implemented for order='K'

Error message

Only implemented for order='K'

What it means

jnp.array implements only NumPy's default memory order 'K' (K-order). NumPy's order='C'/'F' contiguity semantics have no meaning for JAX arrays, which are immutable logical views managed by XLA, so any other order string raises NotImplementedError.

Source

Thrown at jax/_src/numpy/array_constructors.py:198

  .. _explicit sharding: https://docs.jax.dev/en/latest/parallel.html
  """
  if args:
    if len(args) > 3:
      raise TypeError(f"array() takes at most 5 positional arguments but {len(args) + 2} were given")

    for i, name in enumerate(["copy", "order", "ndmin"]):
      if i < len(args) and [copy, order, ndmin][i] != [True, "K", 0][i]:
        raise TypeError(f"array() got multiple values for argument '{name}'")
    copy, order, ndmin = (list(args) + [copy, order, ndmin][len(args):])[:3]

    deprecations.warn(
        "jax-array-positional-args",
        "Passing the copy, order, and ndmin arguments to jnp.array positionally "
        "is deprecated. Use keyword arguments instead.",
        stacklevel=2)

  if order is not None and order != "K":
    raise NotImplementedError("Only implemented for order='K'")

  # Fast path: if we're not actually doing any conversion, in many cases we
  # can call lax.stage to lift the value into the trace.
  if dtype is None and device is None and out_sharding is None and ndmin == 0:
    if isinstance(object, core.Tracer) and not core.is_concrete(object):
      return lax._array_copy(object) if copy else object
    if isinstance(object, (int, float, complex, np.number)):
      return lax.stage(object)
    if isinstance(object, np.ndarray) and not isinstance(object, np.ma.MaskedArray):
      return lax.stage(object)

  # check if the given dtype is compatible with JAX
  if dtype is not None:
    dtype = dtypes.check_and_canonicalize_user_dtype(dtype, "array")

  # Here we make a judgment call: we only return a weakly-typed array when the
  # input object itself is weakly typed. That ensures asarray(x) is a no-op
  # whenever x is weak, but avoids introducing weak types with something like

View on GitHub (pinned to 1e1c6a8fc0)

Solutions

  1. Drop the order argument — JAX arrays don't expose memory layout
  2. If contiguous NumPy layout is needed, convert with np.ascontiguousarray(jax_array) after transferring

Example fix

# before
a = jnp.array(x, order='F')
# after
a = jnp.array(x)
# if C-contiguous NumPy needed later:
n = np.ascontiguousarray(np.asarray(a))
Defensive patterns

Strategy: validation

Validate before calling

if order not in (None, 'K'):
    order = None  # or raise early in your wrapper

Type guard

null

Try / catch

null

Prevention

When it happens

Trigger: jnp.array(obj, order='C') or order='F' — any order other than None or 'K'.

Common situations: Reusing NumPy code that requests Fortran or C order for interoperability with BLAS routines or file I/O.

Related errors


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