{"record":{"id":"bd1e5e0971a07aea","repo":"jax-ml/jax","slug":"number-of-cores-or-threads-must-be-at-least-1-but","errorCode":null,"errorMessage":"Number of cores or threads must be at least 1, but got {self.num_cores_or_threads}.","messagePattern":"Number of cores or threads must be at least 1, but got (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/pallas/mosaic/interpret/params.py","lineNumber":94,"sourceCode":"      number of cores.\n      This should be left at/set to `None` for interpreting GPU kernels. (For\n      GPU kernels, the number of vector clocks is determined by the number of\n      devices, `num_cores_or_threads`, and `num_tma_threads_per_device`.)\n      Default: None.\n    logging_mode: Logging mode for the kernel interpreter.\n  \"\"\"\n\n  detect_races: bool = False\n  out_of_bounds_reads: Literal[\"raise\", \"uninitialized\"] = \"raise\"\n  skip_floating_point_ops: bool = False\n  uninitialized_memory: Literal[\"nan\", \"zero\"] = \"nan\"\n  num_cores_or_threads: int = 1\n  vector_clock_size: int | None = None\n  logging_mode: LoggingMode | None = None\n\n  def __post_init__(self):\n    if self.num_cores_or_threads < 1:\n      raise ValueError(\n          \"Number of cores or threads must be at least 1, but got\"\n          f\" {self.num_cores_or_threads}.\"\n      )\n    if self.vector_clock_size is not None and self.vector_clock_size < 1:\n      # Further validation is done in `get_vector_clock_size` below.\n      raise ValueError(\n          \"Vector clock size must be at least 1, but got\"\n          f\" {self.vector_clock_size}.\"\n      )\n\n  def get_vector_clock_size(self, num_devices) -> int:\n    \"\"\"Returns the number of vector clocks to use for TPU interpret mode.`\"\"\"\n    num_cores_or_threads = num_devices * self.num_cores_or_threads\n    if self.vector_clock_size is not None:\n      if num_cores_or_threads >= self.vector_clock_size:\n        raise ValueError(\n            f\"Vector clock size ({self.vector_clock_size}) must be greater than\"\n            f\" the total number of cores/threads ({num_cores_or_threads}).\"","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/pallas/mosaic/interpret/params.py#L76-L112","documentation":"The TPU interpret-mode parameters dataclass (mosaic interpret params) validates that num_cores_or_threads is at least 1; passing 0 or a negative value raises this ValueError at construction in __post_init__.","triggerScenarios":"Constructing interpret-mode CompilerParams (e.g., via interpret options) with num_cores_or_threads=0 or negative — often derived from a computed core/thread count that can be zero.","commonSituations":"Setting simulated core count from len(devices) or a user config that is empty; multiplying/dividing to compute thread counts that underflow to 0; CLI-config override typos.","solutions":["Pass an explicit positive integer (default 1) for num_cores_or_threads","Guard computed values: max(1, computed_cores)","Validate user-facing config for core/thread settings before constructing params"],"exampleFix":"# before\nparams = interpret_params(num_cores_or_threads=len(tpu_chips))  # 0 if empty\n# after\nparams = interpret_params(num_cores_or_threads=max(1, len(tpu_chips)))","handlingStrategy":"validation","validationCode":"assert isinstance(num_cores_or_threads, int) and num_cores_or_threads >= 1, 'num_cores_or_threads must be >= 1'","typeGuard":"def is_valid_core_count(n) -> bool:\n    return isinstance(n, int) and not isinstance(n, bool) and n >= 1","tryCatchPattern":"try:\n    params = InterpretParams(num_cores_or_threads=n)\nexcept ValueError as e:\n    if 'at least 1' in str(e):\n        params = InterpretParams(num_cores_or_threads=max(1, n))","preventionTips":["Clamp computed core/thread counts with max(1, x)","Default to 1 when device lists are empty","Validate config before constructing interpret params"],"tags":["jax","pallas","tpu","config-validation","interpret-mode"],"backgroundTag":"invalid-configuration","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}