{"record":{"id":"65c91a13a2062adb","repo":"jax-ml/jax","slug":"computation-failed-on-self-failed-thread-with-e","errorCode":null,"errorMessage":"Computation failed on {self._failed_thread} with exception:\\n\\n{failure_str}","messagePattern":"Computation failed on (.+?) with exception:\\\\n\\\\n(.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"jax/_src/pallas/mosaic/interpret/shared_memory.py","lineNumber":882,"sourceCode":"    # it will call `set_failed` with `top_level=True`.\n    if top_level:\n      self.clean_up_barrier.wait()\n\n  def check_failed(self):\n    with self.lock:\n      if self._failure is not None:\n        # __cause__ information is lost when an exception from a callback goes\n        # through XLA and back to Python, so we stuff the information into the\n        # exception message.\n        #\n        # TODO(jburnim): The top-level exception (that the user sees) will not\n        # always contain the original exception info/message.  It currently\n        # depends on which raise (the raise here or the raise in the thread\n        # that calls `set_failed`) happens first. (And maybe some other details\n        # in XLA.)  We should figure out how to reliably propagate the\n        # original exception.\n        failure_str = \"\".join(traceback.format_exception(self._failure))\n        raise RuntimeError(\n            f\"Computation failed on {self._failed_thread} with exception:\\n\\n{failure_str}\"\n        ) from None\n\n  def append_semaphore_task(\n      self,\n      semaphore_id: int,\n      global_core_id: int,\n      task: SemaphoreTask,\n  ):\n    \"\"\"Appends a task to be executed if the semaphore with the given sempahore ID is waiting to be signalled on the core with the given global core ID.\"\"\"\n    with self.lock:\n      sem = self._unsafe_get_semaphore(semaphore_id)\n    sem.enqueue_task(task, global_core_id)\n\n  def get_random_virtual_device_id(self) -> int:\n    # Virtual device IDs are needed for DMAs. Conceptually, each DMA runs on its\n    # own, independent device. Representing this precisely would require vector\n    # clocks to have sizes linear in the number of DMAs.","sourceCodeStart":864,"sourceCodeEnd":900,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/pallas/mosaic/interpret/shared_memory.py#L864-L900","documentation":"A worker thread in the interpret-mode parallel simulation raised an exception; the main thread re-raises it wrapped as 'Computation failed on <thread>' with the original traceback. This is a propagation wrapper, not the root cause — the underlying exception text follows.","triggerScenarios":"Any exception raised inside a kernel body running on one of the interpreter's simulated threads; detected by ComputationManager when wait()/wrapper checks failed state.","commonSituations":"Bugs in user kernel code (shape errors, OOB, dtype mismatch) surfacing through the multithreaded interpreter; the real traceback is embedded in the message after 'exception:'.","solutions":["Read the traceback embedded after 'with exception:' and fix that root-cause error","Run the same kernel single-threaded (num_cores_or_threads=1) for cleaner stack traces","Reproduce with smaller grid/sizes to isolate the failing block index"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    run_kernel_interpreted(...)\nexcept RuntimeError as e:\n    if 'Computation failed on' in str(e):\n        # the real traceback is embedded after 'with exception:'\n        log.error('root cause:\\n%s', e)  # fix the inner error, not this wrapper\n    raise","preventionTips":["Treat this as a wrapper: always inspect the embedded traceback for the root cause","Debug with num_cores_or_threads=1 for clean, single-threaded stack traces","Reproduce with a minimal grid to isolate the failing program index"],"tags":["jax","pallas","mosaic","interpret-mode","threading","error-propagation"],"backgroundTag":"wrapped-worker-exception","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}