{"record":{"id":"7994274b70b83e3e","repo":"sgl-project/sglang","slug":"vec-must-be-1d","errorCode":null,"errorMessage":"vec must be 1D","messagePattern":"vec must be 1D","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/models/schedulers/flow_match_pair.py","lineNumber":446,"sourceCode":"                    if self.reverse_sigmas:\n                        base = 1 - base\n\n                    if source == \"timesteps\":\n                        return base * self.num_train_timesteps\n                    return base\n\n                col0 = _build_column(visual_shift, visual_denoising_strength, visual_mu)\n                col1 = _build_column(audio_shift, audio_denoising_strength, audio_mu)\n                return torch.stack([col0, col1], dim=1)\n\n            _dual_sigma_shift._requires_source = True\n            self.set_pair_postprocess(_dual_sigma_shift)\n            return\n        raise ValueError(f\"Unknown pair_postprocess name: {name}\")\n\n    def _make_pairs_from_vector(self, vec: torch.Tensor) -> torch.Tensor:\n        if vec.ndim != 1:\n            raise ValueError(\"vec must be 1D\")\n        return torch.stack([vec, vec], dim=1)\n\n    def get_pairs(self, source: str = \"timesteps\") -> torch.Tensor:\n        if source == \"timesteps\":\n            if self.pair_timesteps is None:\n                self._refresh_pair_cache()\n            return self.pair_timesteps\n        if source == \"sigmas\":\n            if self.pair_sigmas is None:\n                self._refresh_pair_cache()\n            return self.pair_sigmas\n        raise ValueError(\"source must be 'timesteps' or 'sigmas'\")\n\n    def timestep_to_sigma(self, timestep: torch.Tensor | float) -> torch.Tensor:\n        \"\"\"Return sigma for a scalar timestep via nearest neighbor lookup.\n\n        Args:\n            timestep: Scalar timestep value.","sourceCodeStart":428,"sourceCodeEnd":464,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/models/schedulers/flow_match_pair.py#L428-L464","documentation":"_make_pairs_from_vector duplicates a 1D vector (timesteps or sigmas) into two stacked columns for the paired scheduler; a 2D+ tensor cannot be unambiguously paired. It is called internally by _refresh_pair_cache on self.timesteps/self.sigmas.","triggerScenarios":"Internal: timesteps or sigmas were set to a 2D tensor (e.g. via a custom postprocess or manual assignment) before _refresh_pair_cache runs (triggered by get_pairs or set_pair_postprocess).","commonSituations":"Assigning a batched schedule tensor directly to scheduler.timesteps; a custom set_timesteps override returning a 2D array.","solutions":["Ensure scheduler.timesteps and scheduler.sigmas remain 1D tensors","Flatten or index the tensor before assigning it to the scheduler","If pairing columns is needed, use the pair postprocess mechanism rather than 2D inputs"],"exampleFix":"# before\nsched.timesteps = timesteps_2d  # (B, T)\n# after\nsched.timesteps = timesteps_2d.flatten()  # or select sched.timesteps = timesteps_2d[0]","handlingStrategy":"type-guard","validationCode":"assert sched.timesteps is None or sched.timesteps.ndim == 1\nassert sched.sigmas is None or sched.sigmas.ndim == 1","typeGuard":"def is_1d(t: torch.Tensor) -> bool:\n    return isinstance(t, torch.Tensor) and t.ndim == 1","tryCatchPattern":null,"preventionTips":["Never assign 2D schedules to timesteps/sigmas","Flatten before assignment"],"tags":["scheduler","tensor-shape","validation"],"backgroundTag":"tensor-dimension-mismatch","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}