{"record":{"id":"d052208b79f48181","repo":"google-research/timesfm","slug":"continuous-quantile-head-is-not-supported-for-hori-d05220","errorCode":null,"errorMessage":"Continuous quantile head is not supported for horizons > {self.model.os}.","messagePattern":"Continuous quantile head is not supported for horizons > (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/timesfm/timesfm_2p5/timesfm_2p5_torch.py","lineNumber":416,"sourceCode":"        new_context := math.ceil(fc.max_context / self.model.p) * self.model.p,\n      )\n      fc = dataclasses.replace(fc, max_context=new_context)\n    if fc.max_horizon % self.model.o != 0:\n      logging.info(\n        \"When compiling, max horizon needs to be multiple of the output patch\"\n        \" size %d. Using max horizon = %d instead.\",\n        self.model.o,\n        new_horizon := math.ceil(fc.max_horizon / self.model.o) * self.model.o,\n      )\n      fc = dataclasses.replace(fc, max_horizon=new_horizon)\n    if fc.max_context + fc.max_horizon > self.model.config.context_limit:\n      raise ValueError(\n        \"Context + horizon must be less than the context limit.\"\n        f\" {fc.max_context} + {fc.max_horizon} >\"\n        f\" {self.model.config.context_limit}.\"\n      )\n    if fc.use_continuous_quantile_head and (fc.max_horizon > self.model.os):\n      raise ValueError(\n        f\"Continuous quantile head is not supported for horizons > {self.model.os}.\"\n      )\n    self.forecast_config = fc\n\n    def _compiled_decode(horizon, inputs, masks):\n      if horizon > fc.max_horizon:\n        raise ValueError(\n          f\"Horizon must be less than the max horizon. {horizon} > {fc.max_horizon}.\"\n        )\n\n      inputs = (\n        torch.from_numpy(np.array(inputs)).to(self.model.device).to(torch.float32)\n      )\n      masks = torch.from_numpy(np.array(masks)).to(self.model.device).to(torch.bool)\n      batch_size = inputs.shape[0]\n\n      if fc.infer_is_positive:\n        is_positive = torch.all(inputs >= 0, dim=-1, keepdim=True)","sourceCodeStart":398,"sourceCodeEnd":434,"githubUrl":"https://github.com/google-research/timesfm/blob/331c6d33cb1ac2611de3056d0ac7164aab6301eb/src/timesfm/timesfm_2p5/timesfm_2p5_torch.py#L398-L434","documentation":"When forecast_config.use_continuous_quantile_head is enabled, quantiles can only be produced for horizons up to self.model.os (derived from output_quantile_len=1024 / output_patch_len=128, i.e. 8 output patches). A larger max_horizon with the continuous quantile head raises ValueError during compile().","triggerScenarios":"model.compile(ForecastConfig(use_continuous_quantile_head=True, max_horizon=N)) where N exceeds self.model.os — beyond roughly 1024 forecast steps for the 2.5 200M model.","commonSituations":"Enabling continuous quantiles with a very long horizon (e.g. 2048) for long-range forecasting; mixing the quantile-head flag with a horizon tuned for the default quantile path.","solutions":["Lower max_horizon to <= self.model.os (e.g. 1024) when use_continuous_quantile_head=True.","Set use_continuous_quantile_head=False if horizons beyond os are required.","Forecast iteratively: compile within the supported range and roll predictions forward.","Check TimesFM_2p5_200M_Definition.output_quantile_len and output_patch_len to compute the valid horizon cap."],"exampleFix":"// before\nfc = ForecastConfig(max_horizon=2048, use_continuous_quantile_head=True)  # ValueError\n// after\nfc = ForecastConfig(max_horizon=1024, use_continuous_quantile_head=True)\nmodel.compile(fc)","handlingStrategy":"validation","validationCode":"os_cap = 1024 // 128  # output_quantile_len / output_patch_len = 8\nif fc.use_continuous_quantile_head and fc.max_horizon > os_cap * 128:\n    fc = dataclasses.replace(fc, max_horizon=os_cap * 128, use_continuous_quantile_head=False)","typeGuard":null,"tryCatchPattern":"try:\n    model.compile(fc)\nexcept ValueError as e:\n    if \"Continuous quantile head\" in str(e):\n        fc = dataclasses.replace(fc, use_continuous_quantile_head=False)\n        model.compile(fc)\n    else:\n        raise","preventionTips":["Only enable use_continuous_quantile_head with max_horizon <= 1024 for the 2.5 200M model.","Check the definition's output_quantile_len/output_patch_len to derive the cap.","Iterate forecasts for longer horizons instead of raising max_horizon.","Centralize ForecastConfig creation in one validated factory function."],"tags":["configuration","value-error","quantiles","forecasting"],"backgroundTag":"config-combination-unsupported","analyzedSha":"331c6d33cb1ac2611de3056d0ac7164aab6301eb","analyzedAt":"2026-08-29T01:04:23.138Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}