{"record":{"id":"1272fab9e4046974","repo":"jax-ml/jax","slug":"attempting-to-store-into-allocation-with-key-key","errorCode":null,"errorMessage":"Attempting to store into allocation with key `{key}` that is not a `Buffer`.","messagePattern":"Attempting to store into allocation with key `(.+?)` that is not a `Buffer`\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/pallas/mosaic/interpret/shared_memory.py","lineNumber":596,"sourceCode":"      thread: The thread writing into the buffer.\n      increment_clock: Whether to increment the given thread's vector clock.\n      logging_info: Information about the source of the store.\n\n    Returns:\n      - True if the store was entirely in bounds, False otherwise (i.e. if the\n        store was at least partially out of bounds).\n      - The shape and dtype of the full content array of the buffer.\n      - The incremented vector clock for the given thread.\n        None if race detection is not enabled or if `increment_clock` is False.\n    \"\"\"\n    clock = None\n    with self.lock:\n      if self.detect_races and increment_clock:\n        clock = self.incr_clock(thread, take_lock=False)\n\n      buff = self.mem[key]\n      if not isinstance(buff, Buffer):\n        raise ValueError(\n            f\"Attempting to store into allocation with key `{key}` that is not\"\n            \" a `Buffer`.\"\n        )\n      shape_and_dtype = ShapeAndDtype(buff.logical_shape, buff.dtype)\n\n      assert buff.dtype == value.dtype  # TODO(jburnim): Catch this statically.\n\n      try:\n        buff[rnge] = value\n        is_in_bounds = True\n      except IndexError:\n        # `buf` was accessed with `rnge` at least partially out of bounds.\n        is_in_bounds = False\n\n      if self.enable_logging and logging_info is not None:\n        self._log(\n            logging_info.format(\n                f\"{key=}, {rnge=},\"","sourceCodeStart":578,"sourceCodeEnd":614,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/pallas/mosaic/interpret/shared_memory.py#L578-L614","documentation":"store_buffer_content looked up a memory key whose stored object is not a Buffer. Stores need a Buffer to check dtype/shape and update race-detection clocks.","triggerScenarios":"Calling SharedMemManager.store (or ops routed through it) with a key that maps to a semaphore/non-Buffer allocation.","commonSituations":"Same family as the get variant: key collisions between fixed-ID semaphores and buffer keys, or passing a semaphore key to a store operation in a custom kernel interpretation.","solutions":["Verify the key refers to a Buffer allocation before storing","Eliminate collisions between fixed-ID semaphore IDs and buffer keys","Check that store ops reference the memory returned by allocation, not semaphore handles"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":"def is_buffer_key(mgr, key):\n    with mgr.lock:\n        return isinstance(mgr.mem.get(key), Buffer)","tryCatchPattern":"try:\n    mgr.store(key, value, ...)\nexcept ValueError as e:\n    if 'not a `Buffer`' in str(e):\n        raise KeyError(f'{key} is not a buffer allocation') from e\n    raise","preventionTips":["Store only through keys returned by allocate_buffer","Check value.dtype matches the allocation dtype before storing"],"tags":["jax","pallas","mosaic","shared-memory","key-collision","interpret-mode"],"backgroundTag":"invalid-key-type","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}