[LLM runner] Align make_image_input HWC contract with runtime behavior
@fatih-uzlmz is already working on this.
Since Sep 16, 2026.
- Dominant language
- Python
- Stars
- 5k
- Forks
- 1.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 581
Description
Problem
The Python type stub and pybind docstring advertise HWC, 1xHWC, CHW, and 1xCHW image tensors. Runtime checks accept contiguous CHW and 1xCHW, but reject ordinary contiguous HWC and 1xHWC.
The implementation squeezes rank-4 input before checking ChannelsLast; PyTorch reports that memory format as false for the resulting rank-3 tensor, so the HWC branch is effectively unreachable. Direct tests with the built binding confirmed both CHW forms pass and both HWC forms fail.
The examples in #22620 document only the verified CHW behavior. Runtime and type-stub changes are intentionally excluded from that documentation-only PR.
Proposed resolution
Choose and enforce one contract:
- Implement real HWC and 1xHWC support with shape-aware conversion, or
- Remove the unreachable HWC path and narrow the pybind docstring and
_llm_runner.pyicontract to contiguous CHW and 1xCHW.
Test plan
Add positive and negative coverage for all four layouts, both supported dtypes, invalid batch size, and noncontiguous tensors.
cc @larryliu0820 @cccclai @helunwencser @jackzhxng @digantdesai
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.