Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
204 commits
Select commit Hold shift + click to select a range
7a7a4de
Fix FlashInfer CUDA graph memory accounting
lesj0610 Jun 26, 2026
941a7d3
Use FlashInfer workspace sizing helper
lesj0610 Jun 26, 2026
7c9a1aa
Bump FlashInfer Docker dependencies to 0.6.13
lesj0610 Jun 26, 2026
0fea8db
Tighten FlashInfer workspace sizing state
lesj0610 Jun 26, 2026
bf6aa1c
Use FlashInfer for pre-SM100 NVFP4 KV cache updates
lesj0610 Jun 24, 2026
3ceeb08
Support native FlashInfer NVFP4 KV planning
lesj0610 Jun 26, 2026
bce74cb
Bump FlashInfer dependency for NVFP4 slot mapping
lesj0610 Jun 26, 2026
24044a6
Cache FlashInfer NVFP4 slot mapping writer
lesj0610 Jun 26, 2026
1a2ee4a
Merge branch 'main' into lesj/flashinfer-nvfp4-kv-cache-20260624
lesj0610 Jun 27, 2026
42894da
Reserve FlashInfer workspace before CUDA graph capture
lesj0610 Jun 27, 2026
11e4793
Allow Gemma4 auto attention backend selection
lesj0610 Jun 27, 2026
d2534b5
Add FlashInfer NVFP4 paged prefill path
lesj0610 Jun 27, 2026
7ed11a9
Harden NVFP4 FA2 prefill path
lesj0610 Jun 28, 2026
fcfbea6
Warn on missing NVFP4 paged dequant
lesj0610 Jun 28, 2026
5a977a9
Guard NVFP4 FA2 prefill for mixed head dims
lesj0610 Jun 28, 2026
7efddfc
Guard NVFP4 FA2 prefill for large heads
lesj0610 Jun 28, 2026
20c2df7
Fix mixed-head NVFP4 split views
lesj0610 Jun 28, 2026
b3de160
Merge branch 'main' into lesj/flashinfer-nvfp4-kv-cache-20260624
lesj0610 Jun 28, 2026
0c32dda
Fix FlashInfer mixed-head KV cache typing
lesj0610 Jun 28, 2026
0aa1f83
Restore DiffusionGemma Triton fallback
lesj0610 Jun 29, 2026
773f117
Fix separate CUDA graph memory profiling sampling
lesj0610 Jun 30, 2026
fa497f3
Adapt CUDA graph memory profiling to accelerator API
lesj0610 Jun 30, 2026
186a1c9
Merge remote-tracking branch 'origin/main' into lesj/use-flashinfer-w…
lesj0610 Jun 30, 2026
3f77f18
Refactor separate CUDA graph profiling
lesj0610 Jun 30, 2026
ab613f9
Fix FlashInfer int workspace reservation
lesj0610 Jul 2, 2026
99c0875
Account V2 FlashInfer cudagraph workspace
lesj0610 Jul 2, 2026
733a786
Handle FlashInfer workspace size arrays
lesj0610 Jul 3, 2026
5a75fd7
Log V2 attention workspace reserve breakdown
lesj0610 Jul 3, 2026
1a2fbd6
Log FlashInfer wrapper workspace breakdown
lesj0610 Jul 3, 2026
0bb767b
Shrink FlashInfer int workspace to requested size
lesj0610 Jul 3, 2026
c62649d
Use exact FlashInfer int workspace for CUDA graphs
lesj0610 Jul 3, 2026
cc9b3c9
Merge origin/main into FlashInfer workspace sizing
lesj0610 Jul 3, 2026
24ad25c
Update FlashInfer workspace test q dtype fields
lesj0610 Jul 3, 2026
4017abe
Allow Gemma4 to use FlashInfer fallback
lesj0610 Jul 3, 2026
1f369a6
Gate NVFP4 query dtype on trtllm-gen
lesj0610 Jul 3, 2026
5646187
Drop Gemma4 selector copy from NVFP4 PR
lesj0610 Jul 3, 2026
b5585ad
Drop invalid FlashInfer version bump
lesj0610 Jul 3, 2026
399e1b7
Centralize attention KV cache shape helpers
lesj0610 Jul 3, 2026
762f0dc
Cache FlashInfer NVFP4 KV views
lesj0610 Jul 3, 2026
aaaf154
Tighten NVFP4 KV split stride checks
lesj0610 Jul 3, 2026
7bf65f2
Log NVFP4 FA2 prefill workspace reservation
lesj0610 Jul 3, 2026
25171d9
Merge origin/main into NVFP4 FlashInfer branch
lesj0610 Jul 4, 2026
5ee3d55
Merge remote-tracking branch 'origin/main' into lesj/flashinfer-nvfp4…
lesj0610 Jul 4, 2026
a5872ea
Move cache dtype selection to attention specs
lesj0610 Jul 4, 2026
3e80876
Warm up Qwen3-VL vision Triton kernels
lesj0610 Jul 5, 2026
a0fe330
Gate Qwen3-VL vision warmup on skipped MM profiling
lesj0610 Jul 5, 2026
c42b3f8
Avoid Qwen3-VL pos-embed shape-specialized JIT
lesj0610 Jul 5, 2026
645dc5e
Merge origin/main into FlashInfer NVFP4 KV cache PR
lesj0610 Jul 6, 2026
2c2bc0f
Merge remote-tracking branch 'origin/main' into lesj/flashinfer-nvfp4…
lesj0610 Jul 7, 2026
cd06010
Gate native NVFP4 updates on TRTLLM availability
lesj0610 Jul 8, 2026
da00dd5
Merge remote-tracking branch 'origin/main' into lesj/flashinfer-nvfp4…
lesj0610 Jul 8, 2026
3d4bd85
Merge remote-tracking branch 'origin/main' into lesj/flashinfer-nvfp4…
lesj0610 Jul 10, 2026
61d4ffa
Merge main into FlashInfer workspace sizing
lesj0610 Jul 12, 2026
98b299b
Merge remote-tracking branch 'origin/main' into lesj/use-flashinfer-w…
lesj0610 Jul 14, 2026
28f4d0b
Merge main into FlashInfer workspace sizing
lesj0610 Jul 15, 2026
dd02f6c
[Bugfix] Guard FlashInfer stacked KV cache layout contract
lesj0610 Jul 15, 2026
8941e04
[Bugfix] Preserve FlashInfer cascade KV cache contract
lesj0610 Jul 15, 2026
16e3e21
[Perf] Avoid full-context NVFP4 prefill scratch
lesj0610 Jul 15, 2026
b8ab5c5
[Core] Profile persistent attention workspace before KV sizing
lesj0610 Jul 15, 2026
2a66bab
[Bugfix] Allow neutral builders in workspace profiling
lesj0610 Jul 15, 2026
edb4741
Merge origin/main into FlashInfer NVFP4 KV cache
lesj0610 Jul 16, 2026
b02c2e7
Merge origin/main into FlashInfer workspace sizing
lesj0610 Jul 16, 2026
9556ba0
[Bugfix] Stop forcing deprecated use_fast for Qwen3.5
lesj0610 Jul 17, 2026
87eb6e0
Merge origin/main into FlashInfer workspace sizing
lesj0610 Jul 18, 2026
106938f
Merge upstream main into FlashInfer workspace sizing
lesj0610 Jul 21, 2026
b28448f
Merge origin/main into FlashInfer NVFP4 KV cache
lesj0610 Jul 21, 2026
663475b
Merge upstream main into FlashInfer workspace sizing
lesj0610 Jul 22, 2026
54108eb
Merge remote-tracking branch 'origin/main' into work/pr47637-shared-c…
lesj0610 Jul 22, 2026
966ab0b
[Kernel] Narrow Qwen3-VL interpolation specialization
lesj0610 Jul 22, 2026
771d0f8
Merge remote-tracking branch 'origin/main' into work/pr47637-shared-c…
lesj0610 Jul 22, 2026
d86329a
Merge upstream main into FlashInfer workspace sizing
lesj0610 Jul 28, 2026
7cbc1eb
Fix V2 profiling cleanup state
lesj0610 Jul 29, 2026
44ea853
Merge upstream main into FlashInfer workspace sizing
lesj0610 Jul 29, 2026
1ae56a5
[Bugfix][Attention] Use public FlashInfer workspace sizing API
lesj0610 Jul 29, 2026
805af67
Merge upstream main into NVFP4 KV cache PR
lesj0610 Aug 1, 2026
fcca548
Merge upstream main into workspace sizing PR
lesj0610 Aug 1, 2026
eda1f1a
Merge upstream main into workspace sizing PR
lesj0610 Aug 4, 2026
075b52e
Merge upstream main into workspace sizing PR
lesj0610 Aug 5, 2026
7f7fff7
Merge upstream main into NVFP4 KV cache PR
lesj0610 Aug 8, 2026
3c9a94d
Merge upstream main into Gemma4 FlashInfer selector
lesj0610 Aug 10, 2026
e505363
Reject NVFP4 scale-search dtypes without native store
lesj0610 Aug 8, 2026
fb1ba33
Merge upstream main into workspace sizing PR
lesj0610 Aug 10, 2026
e739b9d
[CI] Fix V2 capture workspace test for encoder-only flag
lesj0610 Aug 10, 2026
bffa2c6
Merge upstream main into workspace sizing PR
lesj0610 Aug 12, 2026
3fab113
Merge upstream main into NVFP4 KV cache PR
lesj0610 Aug 12, 2026
25ff9fa
Merge upstream main into workspace sizing PR
lesj0610 Aug 14, 2026
c5599fd
Merge upstream main into NVFP4 KV cache PR
lesj0610 Aug 14, 2026
a73fc95
Merge upstream main into workspace sizing PR
lesj0610 Aug 15, 2026
3e70b1f
Merge upstream main into NVFP4 KV cache PR
lesj0610 Aug 15, 2026
7daad07
Merge upstream main into NVFP4 KV cache PR
lesj0610 Aug 22, 2026
53d3cac
Merge upstream main into workspace sizing PR
lesj0610 Aug 22, 2026
f8028c3
[Bugfix][Build] Guard fused GDN decode declaration by its own macro
lesj0610 Aug 20, 2026
ae490e7
[Bugfix] Gate CUTLASS FP8 linear kernel on SM89+
Aug 22, 2026
69811f0
[Bugfix] Scale block size before padding a unified KV page
lesj0610 Aug 22, 2026
d165855
Merge branch 'main' into lesj/flashinfer-nvfp4-kv-cache-20260624
lesj0610 Aug 23, 2026
42bf857
Merge branch 'main' into lesj/use-flashinfer-workspace-sizing-20260626
lesj0610 Aug 23, 2026
78c78b5
Merge branch 'main' into lesj/gemma4-flashinfer-selector
lesj0610 Aug 23, 2026
16d1ed1
Merge branch 'main' into lesj/qwen3-vl-vision-warmup
lesj0610 Aug 23, 2026
4c9b6db
Merge branch 'main' into agent/qwen35-processor-backend
lesj0610 Aug 23, 2026
d88ae33
Merge branch 'main' into lesj/fused-gdn-decode-ops-guard-20260816
lesj0610 Aug 23, 2026
931c36f
Merge branch 'main' into lesj/cutlass-fp8-capability-gate-20260822
lesj0610 Aug 23, 2026
3191327
Merge branch 'main' into lesj/unify-page-scale-block-20260822
lesj0610 Aug 23, 2026
cd31a80
[Perf] Bound M-RoPE cache by certified position ranges
Aug 23, 2026
851e400
[Bugfix] Scale the padded unify branch from the natural page size
lesj0610 Aug 24, 2026
c0f1268
[Bugfix] Base the divisible unify branch on the natural page size too
lesj0610 Aug 24, 2026
98326de
[Bugfix] Keep MLA on the aligned-page scaling base
lesj0610 Aug 24, 2026
e499bf2
[Attention] Rebuild FlashInfer mm-prefix on a mask-owning JIT variant
lesj0610 Aug 24, 2026
10a9c2e
[Attention] Gate mm-prefix page sizes and probe per-group JIT variants
lesj0610 Aug 24, 2026
b328057
[Attention] Pin mm-prefix kernel block-size advertising
lesj0610 Aug 24, 2026
045b0a6
test: zip strict=True in the FlashInfer mm-prefix e2e setup
lesj0610 Aug 24, 2026
8b1c2bc
Merge remote-tracking branch 'lesj0610/lesj/cutlass-fp8-capability-ga…
lesj0610 Aug 24, 2026
edb6f69
Merge remote-tracking branch 'lesj0610/lesj/fused-gdn-decode-ops-guar…
lesj0610 Aug 24, 2026
cc8d494
Merge remote-tracking branch 'lesj0610/lesj/unify-page-scale-block-20…
lesj0610 Aug 24, 2026
c6adf96
Merge remote-tracking branch 'lesj0610/agent/mrope-cache-position-bou…
lesj0610 Aug 24, 2026
f55bb82
Merge remote-tracking branch 'lesj0610/agent/qwen35-processor-backend…
lesj0610 Aug 24, 2026
66ef39d
Merge remote-tracking branch 'lesj0610/lesj/qwen3-vl-vision-warmup' i…
lesj0610 Aug 24, 2026
1e7dd59
Merge remote-tracking branch 'lesj0610/lesj/gemma4-flashinfer-selecto…
lesj0610 Aug 24, 2026
b763adb
Merge remote-tracking branch 'lesj0610/lesj/flashinfer-nvfp4-kv-cache…
lesj0610 Aug 24, 2026
a150dfd
Merge remote-tracking branch 'lesj0610/lesj/use-flashinfer-workspace-…
lesj0610 Aug 24, 2026
7159ba5
Merge remote-tracking branch 'lesj0610/lesj/flashinfer-mm-prefix' int…
lesj0610 Aug 24, 2026
0996cfb
[Integration] Graft PR 102 workspace profiling onto main's profiling …
lesj0610 Aug 24, 2026
b84ba0c
Merge origin/main into FlashInfer workspace sizing
lesj0610 Aug 24, 2026
68f9d37
Merge remote-tracking branch 'lesj0610/lesj/use-flashinfer-workspace-…
lesj0610 Aug 24, 2026
222cae9
Merge remote-tracking branch 'origin/main' into lesj/integration-2026…
lesj0610 Aug 24, 2026
db9cfe8
Merge remote-tracking branch 'origin/main' into lesj/integration-2026…
lesj0610 Aug 24, 2026
cb22052
[Bugfix][Spec Decode] Restore DFlashQwen3Model.decoder_layer_cls hook
lesj0610 Aug 24, 2026
f5b22bf
[Bugfix][Attention] Keep native FlashInfer output dtype for NVFP4 KV
lesj0610 Aug 24, 2026
9946370
Merge remote-tracking branch 'lesj0610/lesj/use-flashinfer-workspace-…
lesj0610 Aug 24, 2026
70fae81
Merge remote-tracking branch 'origin/main' into lesj/use-flashinfer-w…
Aug 26, 2026
ce6ad7c
Merge remote-tracking branch 'origin/main' into lesj/flashinfer-nvfp4…
Aug 26, 2026
f7b8cdc
test: adapt NVFP4 FlashInfer tests to upstream layout and sinks contr…
Aug 26, 2026
aa20081
Merge remote-tracking branch 'lesj0610/lesj/use-flashinfer-workspace-…
lesj0610 Aug 26, 2026
8014376
Merge remote-tracking branch 'lesj0610/lesj/flashinfer-nvfp4-kv-cache…
lesj0610 Aug 26, 2026
0f08c66
Merge remote-tracking branch 'origin/main' into lesj/integration-2026…
lesj0610 Aug 26, 2026
2fb3dc6
Merge remote-tracking branch 'origin/main' into lesj/gemma4-flashinfe…
Aug 26, 2026
5ecfd38
Merge remote-tracking branch 'lesj0610/lesj/gemma4-flashinfer-selecto…
lesj0610 Aug 26, 2026
33bee72
Merge remote-tracking branch 'origin/main' into lesj/integration-2026…
lesj0610 Aug 26, 2026
efd1477
[Attention] Serve mm-prefix on a packed NVFP4 KV cache
lesj0610 Aug 26, 2026
2aa11b1
Merge commit 'efd1477e77' into lesj/integration-20260824
lesj0610 Aug 26, 2026
29d1132
[Attention] Route NVFP4 scale factors through the mm-prefix variant
lesj0610 Aug 26, 2026
dd10e28
Merge remote-tracking branch 'lesj0610/lesj/flashinfer-mm-prefix' int…
lesj0610 Aug 26, 2026
c9ba46e
Merge remote-tracking branch 'origin/main' into lesj/integration-2026…
lesj0610 Aug 26, 2026
41ce5a4
Merge remote-tracking branch 'origin/main' into lesj/integration-2026…
lesj0610 Aug 27, 2026
2e18657
Merge remote-tracking branch 'origin/main' into lesj/use-flashinfer-w…
Aug 27, 2026
5ef2be5
Merge remote-tracking branch 'lesj0610/lesj/use-flashinfer-workspace-…
lesj0610 Aug 27, 2026
2f2cde1
Merge branch 'main' into lesj/flashinfer-mm-prefix
lesj0610 Aug 27, 2026
8e8bc18
Merge remote-tracking branch 'lesj0610/lesj/flashinfer-mm-prefix' int…
lesj0610 Aug 27, 2026
3d2034f
test: satisfy mypy in the mm-prefix tests
lesj0610 Aug 27, 2026
f79b319
Merge remote-tracking branch 'lesj0610/lesj/flashinfer-mm-prefix' int…
lesj0610 Aug 27, 2026
427b9f5
Merge remote-tracking branch 'origin/main' into lesj/use-flashinfer-w…
Aug 27, 2026
4d52133
Merge remote-tracking branch 'lesj0610/lesj/use-flashinfer-workspace-…
lesj0610 Aug 27, 2026
db8d6ab
Merge remote-tracking branch 'origin/main' into lesj/integration-2026…
lesj0610 Aug 27, 2026
10d6a3e
Merge remote-tracking branch 'origin/main' into lesj/flashinfer-mm-pr…
lesj0610 Aug 29, 2026
c1dbef4
Merge remote-tracking branch 'origin/main' into lesj/clean-115-20260829
lesj0610 Aug 29, 2026
181638d
Merge remote-tracking branch 'origin/main' into lesj/integration-2026…
lesj0610 Sep 1, 2026
f789270
Merge branch 'main' into lesj/integration-20260824
lesj0610 Sep 1, 2026
2156789
Merge branch 'main' into lesj/integration-20260824
lesj0610 Sep 1, 2026
54d8ff8
Merge remote-tracking branch 'origin/main' into lesj/integration-2026…
lesj0610 Sep 1, 2026
90c4603
Merge remote-tracking branch 'origin/main' into lesj/integration-2026…
lesj0610 Sep 2, 2026
e425e5b
Merge remote-tracking branch 'origin/main' into lesj/integration-2026…
lesj0610 Sep 4, 2026
3b20cfc
[Bugfix][Attention] Rebind the DCP prefill wrapper's inner workspaces
lesj0610 Sep 4, 2026
7a2fc62
[Bugfix][Attention] Lock the workspace on every warmup path
lesj0610 Sep 4, 2026
de4bd7d
Merge branch 'main' into lesj/integration-20260824
lesj0610 Sep 4, 2026
075e076
Merge remote-tracking branch 'origin/main' into lesj/integration-2026…
lesj0610 Sep 5, 2026
b896965
[Bugfix][Attention] Lock the workspace after the late warmups, not be…
lesj0610 Sep 5, 2026
c2080eb
revert(qwen3-vl): drop specialization override
lesj0610 Sep 5, 2026
d90e6f3
Merge remote-tracking branch 'origin/main' into lesj/integration-2026…
lesj0610 Sep 9, 2026
e725565
Merge remote-tracking branch 'origin/main' into lesj/integration-2026…
lesj0610 Sep 9, 2026
8bc37e1
Merge remote-tracking branch 'origin/main' into lesj/integration-2026…
lesj0610 Sep 9, 2026
308aa20
Merge branch 'main' into lesj/flashinfer-mm-prefix
lesj0610 Sep 12, 2026
8726cdc
Merge remote-tracking branch 'origin/main' into lesj/integration-2026…
lesj0610 Sep 12, 2026
5551ba3
Merge remote-tracking branch 'origin/main' into lesj/integration-2026…
lesj0610 Sep 12, 2026
04b861b
[Bugfix][Attention] Reserve FlashInfer mm-prefix workspace before lock
lesj0610 Sep 12, 2026
d0e599b
Merge remote-tracking branch 'origin/main' into lesj/integration-2026…
lesj0610 Sep 12, 2026
6739813
[Attention] Explain the mm-prefix NVFP4 rejection as a kernel constraint
lesj0610 Sep 12, 2026
db20eaf
[Attention] Correct why mm-prefix rejects an NVFP4 cache
lesj0610 Sep 12, 2026
4564ce7
Merge remote-tracking branch 'origin/main' into lesj/integration-2026…
lesj0610 Sep 12, 2026
bc15be3
Merge remote-tracking branch 'origin/main' into sync/lesj/integration…
lesj0610 Sep 12, 2026
236d16b
[Attention] Use FlashInfer's bidirectional-ranges wrapper
lesj0610 Sep 13, 2026
5ba94d0
Merge branch 'main' into lesj/flashinfer-mm-prefix
lesj0610 Sep 13, 2026
d565bc2
[Attention] Offer FlashInfer before the composite on mm-prefix
lesj0610 Sep 13, 2026
026d495
[Attention] Make the selector fixtures actually mock FA availability
lesj0610 Sep 13, 2026
0dadb38
[Core] Reserve the FlashInfer attention workspace during profiling
lesj0610 Sep 14, 2026
137861d
[Core] Share the workspace state, not just the buffer, across a compo…
lesj0610 Sep 14, 2026
57c447a
Merge remote-tracking branch 'origin/main' into lesj/115-cherry-20260914
lesj0610 Sep 14, 2026
9b6104b
Merge commit '026d4952d6edaa3feaa481bc8b3b160ab714f45c' into lesj/115…
lesj0610 Sep 14, 2026
e7cfb1c
Merge commit '137861d966204893d83899cc853155b826078d47' into lesj/115…
lesj0610 Sep 14, 2026
afd0676
Merge remote-tracking branch 'origin/main' into sync/lesj/integration…
lesj0610 Sep 14, 2026
8e7795f
[Core] Profile FlashInfer's persistent attention workspace before KV …
lesj0610 Sep 15, 2026
d90f87a
[Core] Profile FlashInfer's persistent attention workspace before KV …
lesj0610 Sep 15, 2026
af5243e
[Attention] Shrink the FlashInfer reservation to a proven workspace b…
lesj0610 Sep 15, 2026
a6a70a5
[Attention] Refuse a workspace bound that was not answered in integers
lesj0610 Sep 15, 2026
257ec5b
[Attention] Close two paths that would outgrow a bounded workspace arena
lesj0610 Sep 15, 2026
f5bea65
[Attention] Keep the reservation when the workspace bound stands down
lesj0610 Sep 15, 2026
f1a67af
[Attention] Make the workspace GPU tests reach the code they test
lesj0610 Sep 15, 2026
2c83c48
[Core] Do not close the profiling lifecycle on a model flag alone
lesj0610 Sep 15, 2026
fc08405
[Attention] Keep the default arena where a later wrapper can ask for it
lesj0610 Sep 15, 2026
2c766c8
Merge the rebuilt FlashInfer workspace reservation into the integrati…
lesj0610 Sep 16, 2026
61ec99a
[Attention] Give a wrapper an arena it can plan against when nothing …
lesj0610 Sep 16, 2026
412ecc9
Realign the integration branch on the fixed workspace upper-bound branch
lesj0610 Sep 16, 2026
668291f
Merge remote-tracking branch 'origin/main' into sync/lesj/integration…
lesj0610 Sep 16, 2026
41b36b0
[Attention] Align FlashInfer MM-prefix window semantics
lesj0610 Sep 16, 2026
8b11a7b
Merge the realigned mm-prefix window semantics into the integration b…
lesj0610 Sep 16, 2026
8538b81
Merge remote-tracking branch 'origin/main' into sync/lesj/integration…
lesj0610 Sep 16, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 103 additions & 0 deletions tests/config/test_mrope_cache_bound_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
"""``ModelConfig.mrope_cache_max_position`` resolution.

The bound is only handed to the RoPE layer when the concrete model class
certifies its unpruned positions and no config-dependent transform can push a
position past the sequence length. It also participates in the model
compilation hash, so a compiled artifact built with one bound is never reused
for another.
"""

import types

import pytest

from vllm.config.model import ModelConfig


def _model_config(certified: bool, pruning_rate: float | None) -> ModelConfig:
"""Build the smallest object that exercises the property's branches."""
config = ModelConfig.__new__(ModelConfig)
object.__setattr__(
config,
"_model_info",
types.SimpleNamespace(mrope_positions_are_sequence_bounded=certified),
)
if pruning_rate is None:
multimodal_config = None
else:
multimodal_config = types.SimpleNamespace(
is_multimodal_pruning_enabled=lambda: pruning_rate > 0
)
object.__setattr__(config, "multimodal_config", multimodal_config)
object.__setattr__(config, "max_model_len", 262144)
return config


def test_certified_model_without_pruning_gets_the_sequence_bound():
config = _model_config(certified=True, pruning_rate=None)

assert config.mrope_cache_max_position == 262144


def test_uncertified_model_keeps_the_legacy_cache():
config = _model_config(certified=False, pruning_rate=None)

assert config.mrope_cache_max_position is None


@pytest.mark.parametrize("pruning_rate", [0.0, 0.5])
def test_pruning_falls_back_to_the_legacy_cache(pruning_rate):
"""Pruned positions can exceed the reduced sequence length."""
config = _model_config(certified=True, pruning_rate=pruning_rate)

expected = 262144 if pruning_rate == 0.0 else None
assert config.mrope_cache_max_position == expected


def test_uncertified_model_ignores_pruning_state():
config = _model_config(certified=False, pruning_rate=0.5)

assert config.mrope_cache_max_position is None


def test_bound_participates_in_the_model_hash(monkeypatch):
"""A compiled artifact built for one bound must not be reused for another."""
import vllm.config.utils as config_utils

monkeypatch.setattr(
config_utils,
"get_hash_factors",
lambda _config, _ignored: {"base": "unchanged"},
)
monkeypatch.setattr(config_utils, "hash_factors", lambda factors: repr(factors))

unbounded = _model_config(certified=False, pruning_rate=None)
bounded = _model_config(certified=True, pruning_rate=None)

unbounded_hash = unbounded.compute_hash()
bounded_hash = bounded.compute_hash()

assert "mrope_cache_max_position" in unbounded_hash
assert unbounded_hash != bounded_hash


def test_get_rope_accepts_the_bound_from_model_config():
"""The value handed to the RoPE factory is the property, unmodified.

``Qwen3NextAttention`` builds its projections before calling ``get_rope``,
so constructing it needs a distributed environment; the hand-off is pinned
here at the boundary instead, and `test_mrope_cache_bounds.py` covers the
factory's own behaviour for both values.
"""
import inspect

from vllm.model_executor.layers.rotary_embedding import get_rope

parameter = inspect.signature(get_rope).parameters["mrope_cache_max_position"]

assert parameter.default is None
assert _model_config(
certified=True, pruning_rate=None
).mrope_cache_max_position == (262144)
Loading