Skip to content

[Fix][DLight] Handle rank-one GEMV cache loads - #20158

Merged
tlopex merged 1 commit into
apache:mainfrom
SamJSui:fix/dlight-rank-one-gemv
Aug 18, 2026
Merged

tlopex merged 1 commit into
apache:mainfrom
SamJSui:fix/dlight-rank-one-gemv

Conversation

@SamJSui

@SamJSui SamJSui commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

DLight's GPU GEMV rule assumes that the final two loops around a local cache
read are both owned by the cache stage. Rank-one vector inputs create only one
cache loop, causing the rule to include the shared placement loop and attempt
to fuse an imperfect loop nest.

This change records the cache loop count before compute_at and recovers that
innermost suffix afterward. A single cache loop is used directly, while the
existing final-two-loop fusion is preserved for higher-rank inputs.

A focused regression verifies that rank-one GEMV scheduling completes and that
the local vector load remains vectorized.

Fixes #20118

Testing:

  • python -m pytest tests/python/s_tir/dlight/test_gpu_gemv.py -q — 14 passed
  • python -m pytest tests/python/relax/test_pipeline.py -q — 24 passed
  • Exact issue reproducer — passed
  • RTX 4070 Ti SUPER (SM89): FP32/FP16 widths 2, 3, 32, 33, and 128 — NumPy parity
  • pre-commit run --all-files — passed

The DLight GPU GEMV rule assumed that the final two loops around a local cache read were both owned by the cache stage. Rank-one vector inputs create only one cache loop, so the rule included the shared placement loop and attempted to fuse an imperfect nest.

Record the cache loop count before compute_at and recover that innermost suffix after placement. Use the sole cache loop directly for rank-one inputs while preserving the existing final-two-loop fusion for higher-rank inputs.

Add a focused regression that verifies rank-one GEMV scheduling and vectorized local loading.
@SamJSui
SamJSui marked this pull request as ready for review August 18, 2026 14:23

@tlopex tlopex left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for the fix!

@tlopex
tlopex merged commit d536d41 into apache:main Aug 18, 2026
5 checks passed
wodylm pushed a commit to wodylm/mcTVM that referenced this pull request Sep 15, 2026
DLight's GPU GEMV rule assumes that the final two loops around a local
cache
read are both owned by the cache stage. Rank-one vector inputs create
only one
cache loop, causing the rule to include the shared placement loop and
attempt
to fuse an imperfect loop nest.

This change records the cache loop count before `compute_at` and
recovers that
innermost suffix afterward. A single cache loop is used directly, while
the
existing final-two-loop fusion is preserved for higher-rank inputs.

A focused regression verifies that rank-one GEMV scheduling completes
and that
the local vector load remains vectorized.

Fixes apache#20118

Testing:

- `python -m pytest tests/python/s_tir/dlight/test_gpu_gemv.py -q` — 14
passed
- `python -m pytest tests/python/relax/test_pipeline.py -q` — 24 passed
- Exact issue reproducer — passed
- RTX 4070 Ti SUPER (SM89): FP32/FP16 widths 2, 3, 32, 33, and 128 —
NumPy parity
- `pre-commit run --all-files` — passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] dlight GPU GEMV scheduling crashes on Relax dataflow block due to imperfect loop nest after cache_read insertion

2 participants