{"record":{"id":"3bc9bfc2cc24b684","repo":"jax-ml/jax","slug":"scope-self-trace-scope-not-supported","errorCode":null,"errorMessage":"Scope {self.trace_scope} not supported","messagePattern":"Scope (.+?) not supported","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"jax/experimental/mosaic/gpu/profiler.py","lineNumber":214,"sourceCode":"    if dump_path == \"sponge\":\n      self.dump_path = os.getenv(\n          \"TEST_UNDECLARED_OUTPUTS_DIR\", tempfile.gettempdir()\n      )\n    else:\n      self.dump_path = dump_path\n    if trace_scope not in (ThreadSubset.WARP, ThreadSubset.WARPGROUP):\n      raise ValueError(f\"Unsupported trace scope: {trace_scope}\")\n    self.trace_scope = trace_scope\n\n  def _num_traces(\n      self, grid: tuple[int, ...], block: tuple[int, ...]\n  ) -> int:\n    if self.trace_scope == ThreadSubset.WARP:\n      scope_size = WARP_SIZE\n    elif self.trace_scope == ThreadSubset.WARPGROUP:\n      scope_size = WARPGROUP_SIZE\n    else:\n      raise NotImplementedError(f\"Scope {self.trace_scope} not supported\")\n\n    if math.prod(block) % scope_size:\n      raise ValueError(f\"Block size is not a multiple of {scope_size}\")\n    return math.prod(grid) * math.prod(block) // scope_size\n\n  def mlir_buffer_type(\n      self, grid: tuple[int, ...], block: tuple[int, ...]\n  ) -> ir.MemRefType:\n    return ir.MemRefType.get(\n        (self._num_traces(grid, block) * self.entries_per_warpgroup,),\n        ir.IntegerType.get_signless(32),\n    )\n\n  def jax_buffer_type(\n      self, grid: tuple[int, ...], block: tuple[int, ...]\n  ) -> jax.ShapeDtypeStruct:\n    return jax.ShapeDtypeStruct(\n        (self._num_traces(grid, block) * self.entries_per_warpgroup,),","sourceCodeStart":196,"sourceCodeEnd":232,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/experimental/mosaic/gpu/profiler.py#L196-L232","documentation":"A defensive NotImplementedError inside ProfilerSpec._num_traces: after __init__ validates the scope, any scope other than WARP/WARPGROUP reaching here means an inconsistent state (e.g. a manually mutated spec.trace_scope).","triggerScenarios":"Assigning spec.trace_scope = ThreadSubset.BLOCK after construction and then calling spec.dump(...), spec.mlir_buffer_type(...), or spec.smem_i32_elements(...).","commonSituations":"Mutable spec objects shared between kernels; bypassing the constructor check by attribute mutation.","solutions":["Create a new ProfilerSpec with the desired scope instead of mutating trace_scope","Never mutate spec.trace_scope after construction"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never mutate spec.trace_scope after construction","Create a new ProfilerSpec per scope"],"tags":["profiling","mosaic","gpu","immutability"],"backgroundTag":"illegal-state-mutation","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}