{"record":{"id":"8556bf0620d8494c","repo":"jax-ml/jax","slug":"strides-must-contain-only-1s","errorCode":null,"errorMessage":"`strides` must contain only 1s.","messagePattern":"`strides` must contain only 1s\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"jax/experimental/mosaic/gpu/dialect_lowering.py","lineNumber":770,"sourceCode":"def _vector_shape_cast_op_lowering_rule(\n    _: LoweringContext, op: vector.ShapeCastOp\n) -> Sequence[ir.Value]:\n  [layout] = inference_utils.in_layouts(op)\n  out_vec_ty = ir.VectorType(op.result.type)\n  assert out_vec_ty.has_static_shape\n  a = _fragmented_array_from_ir(op.source, layout)\n  return [\n      fragmented_array_to_ir(a.reshape(tuple(out_vec_ty.shape)), out_vec_ty)\n  ]\n\n\n@_register_lowering(vector.ExtractStridedSliceOp)\ndef _vector_extract_strided_slice_op_lowering_rule(\n    ctx: LoweringContext, op: vector.ExtractStridedSliceOp\n) -> Sequence[ir.Value]:\n  del ctx\n  if any(ir.IntegerAttr(s).value != 1 for s in op.strides):\n    raise NotImplementedError(\"`strides` must contain only 1s.\")\n  [in_layout] = inference_utils.in_layouts(op)\n  [out_layout] = inference_utils.out_layouts(op)\n  assert in_layout == out_layout\n  out_vec_ty = ir.VectorType(op.result.type)\n  assert out_vec_ty.has_static_shape\n  a = _fragmented_array_from_ir(op.source, in_layout)\n  indices = tuple(\n      utils.DynamicSlice(\n          ir.IntegerAttr(offset).value, ir.IntegerAttr(length).value\n      )\n      for offset, length in zip(op.offsets, op.sizes, strict=True)\n  )\n  result = a[indices]\n  assert result.layout == layouts_lib.from_layout_attr(out_layout)\n  return [fragmented_array_to_ir(result, out_vec_ty)]\n\n\n@_register_lowering(vector.ExtractOp)","sourceCodeStart":752,"sourceCodeEnd":788,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/experimental/mosaic/gpu/dialect_lowering.py#L752-L788","documentation":"Mosaic's lowering of vector.extract_strided_slice only handles unit strides (a contiguous slice); strided extraction is not implemented.","triggerScenarios":"Emitting vector.extract_strided_slice with any stride attribute != 1 inside a Mosaic kernel.","commonSituations":"Trying to subsample a vector (take every other element) rather than a contiguous slice.","solutions":["Use unit strides and slice a contiguous range","For strided access, do it via loads/stores to memory or reshape/split ops instead","Combine extract with layout casts to get the elements you need"],"exampleFix":"// before\nvector.extract_strided_slice v[0:8:2]\n// after\nvector.extract_strided_slice v[0:8:1]","handlingStrategy":"validation","validationCode":"assert all(ir.IntegerAttr(s).value == 1 for s in op.strides), 'use unit strides'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use contiguous slices; do strided access via memory"],"tags":["jax","mosaic","gpu","vector","strides"],"backgroundTag":"unsupported-operation","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}