{"record":{"id":"b4356ce486a1c21e","repo":"sgl-project/sglang","slug":"in-ps-version-v1-the-height-and-width-have-not","errorCode":null,"errorMessage":"In ps_version 'v1', the height and width have not been swapped back, which results in a transposed image.","messagePattern":"In ps_version 'v1', the height and width have not been swapped back, which results in a transposed image\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"python/sglang/srt/models/internvl.py","lineNumber":607,"sourceCode":"        }\n\n        self.model = self.language_model.model\n\n    def pixel_shuffle(self, x, scale_factor=0.5):\n        n, w, h, c = x.size()\n        # N, W, H, C --> N, W, H * scale, C // scale\n        x = x.view(n, w, int(h * scale_factor), int(c / scale_factor))\n        # N, W, H * scale, C // scale --> N, H * scale, W, C // scale\n        x = x.permute(0, 2, 1, 3).contiguous()\n        # N, H * scale, W, C // scale --> N, H * scale, W * scale, C // (scale ** 2)\n        x = x.view(\n            n,\n            int(h * scale_factor),\n            int(w * scale_factor),\n            int(c / (scale_factor * scale_factor)),\n        )\n        if self.ps_version == \"v1\":\n            logger.warn(\n                \"In ps_version 'v1', the height and width have not been swapped back, \"\n                \"which results in a transposed image.\"\n            )\n        else:\n            x = x.permute(0, 2, 1, 3).contiguous()\n        return x\n\n    def extract_feature(self, pixel_values):\n        if self.select_layer == -1:\n            vit_embeds = self.vision_model(\n                pixel_values=pixel_values, output_hidden_states=False, return_dict=True\n            ).last_hidden_state\n        else:\n            vit_embeds = self.vision_model(\n                pixel_values=pixel_values, output_hidden_states=True, return_dict=True\n            ).hidden_states[self.select_layer]\n        vit_embeds = vit_embeds[:, 1:, :]\n","sourceCodeStart":589,"sourceCodeEnd":625,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/models/internvl.py#L589-L625","documentation":"This is a warning emitted by InternVL's pixel_shuffle vision projection when ps_version='v1'. In v1, the height/width swap performed during the pixel-unshuffle reshape is intentionally NOT undone (no permute back), so the resulting feature map is transposed relative to the input image. The model was trained this way, so v1 checkpoints reproduce correct behavior only with the transpose left in place; the log line exists so users know the geometry differs from v2.","triggerScenarios":"Loading an InternVL model whose vision config sets ps_version='v1' (older InternVL checkpoints) and running a forward pass that reaches extract_feature -> pixel_shuffle. Any multimodal request (image input) to an InternVL model triggers it once per vision forward.","commonSituations":"Serving older InternVL / InternVL2 variants with ps_version='v1' in the vision config; users comparing v1 vs v2 behavior or debugging 'rotated/transposed image' visual embeddings; upgrading SGLang versions where the warning was added for clarity.","solutions":["If your model config genuinely specifies ps_version='v1', this is expected — no action needed; suppress or ignore the log line","Verify you passed the correct model/config (a v2 checkpoint misconfigured as v1 produces wrong spatial layout): check the ps_version field in config.json of the vision tower","If you actually want non-transposed features, set ps_version='v2' (only valid for checkpoints trained with v2) so the permute-back branch runs","Downgrade log noise via logging config if the warning floods logs in production"],"exampleFix":"// config.json (vision tower)\n// before\n\"ps_version\": \"v1\"\n// after (only for v2-trained checkpoints)\n\"ps_version\": \"v2\"","handlingStrategy":"validation","validationCode":"ps = model.config.vision_config.ps_version\nif ps == \"v1\":\n    logging.getLogger(__name__).info(\"InternVL v1 pixel shuffle: transposed features expected\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pin the correct model revision with the intended ps_version","Treat the warning as informational for v1 checkpoints; do not 'fix' it by swapping dims yourself"],"tags":["internvl","vision-encoder","pixel-shuffle","multimodal","deprecation"],"backgroundTag":"model-config-mismatch","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}