jax-ml/jax · error · ValueError
dtype argument to `pareto` must be a float dtype, got {dtype
Error message
dtype argument to `pareto` must be a float dtype, got {dtype} What it means
jax.random.pareto requires a floating-point output dtype; the sampler builds on jax.random.exponential (itself float-only) and then applies a power transform. Integer or complex dtypes raise ValueError. The dtype must also be safe to cast b to, checked separately by _check_all_safe_to_cast.
Source
Thrown at jax/_src/random/core.py:2572
jax_enable_x64 is true, otherwise float32).
out_sharding: Optional. Specifies how the output array should be sharded
across devices in multi-device computation. Can be a
:class:`~jax.sharding.NamedSharding`, a :class:`~jax.sharding.PartitionSpec`
(``P``), or ``None`` (default). When specified, the output will be sharded
according to the given sharding specification. Primarily used in explicit
sharding mode.
See the `explicit sharding tutorial <https://docs.jax.dev/en/latest/parallel.html>`_
for more details.
Returns:
A random array with the specified dtype and with shape given by ``shape`` if
``shape`` is not None, or else by ``b.shape``.
"""
key, _ = _check_prng_key("pareto", key)
dtype = dtypes.check_and_canonicalize_user_dtype(
float if dtype is None else dtype)
if not dtypes.issubdtype(dtype, np.floating):
raise ValueError(f"dtype argument to `pareto` must be a float "
f"dtype, got {dtype}")
shape = _check_broadcast_shapes("pareto", shape, b)
_check_all_safe_to_cast("pareto", dtype, b)
out_sharding = canonicalize_sharding_for_samplers(out_sharding, "pareto", shape)
return maybe_auto_axes(_pareto, out_sharding,
shape=shape, dtype=dtype)(key, b)
@jit(static_argnums=(2, 3))
def _pareto(key, b, shape, dtype) -> Array:
b = lax.convert_element_type(b, dtype)
e = exponential(key, shape, dtype)
return lax.exp(e / b)
def t(key: ArrayLike,
df: RealArray,
shape: Shape | None = None,
dtype: DTypeLikeFloat | None = None,View on GitHub (pinned to 1e1c6a8fc0)
Solutions
- Pass jnp.float32/jnp.float64 or omit dtype.
- Also ensure the shape b broadcasts (shape is checked via _check_broadcast_shapes) and b can be safely cast to dtype.
- Validate configurable dtypes against np.floating before calling.
Example fix
// before x = jax.random.pareto(key, b, dtype=jnp.int32) // after x = jax.random.pareto(key, b, dtype=jnp.float32)
Defensive patterns
Strategy: type-guard
Validate before calling
from jax._src import dtypes assert dtypes.issubdtype(dtypes.check_and_canonicalize_user_dtype(dtype or float), np.floating)
Type guard
def is_float_dtype(dtype) -> bool:
from jax._src import dtypes
import numpy as np
return dtypes.issubdtype(dtypes.check_and_canonicalize_user_dtype(dtype or float), np.floating) Prevention
- Also keep b castable to the chosen dtype to pass the safe-cast check.
When it happens
Trigger: jax.random.pareto(key, b, dtype=jnp.int32) or any dtype where dtypes.issubdtype(dtype, np.floating) is False.
Common situations: Heavy-tail noise generation configs with a single shared dtype; porting NumPy pareto code that has no dtype parameter; combining with int-based samplers in the same module.
Related errors
- dtype argument to `exponential` must be a float dtype, got {
- dtype argument to `gamma` must be a float dtype, got {dtype}
- dtype argument to `gumbel` must be a float dtype, got {dtype
- dtype argument to `laplace` must be a float dtype, got {dtyp
- dtype argument to `logistic` must be a float dtype, got {dty
AI-assisted analysis of jax-ml/jax@1e1c6a8fc0 (2026-08-27).
Data as JSON: /api/errors/95dd7ab3b33ed5ee.
Report an issue: GitHub.