Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 1 addition & 3 deletions QEfficient/transformers/models/modeling_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -2223,9 +2223,7 @@ def compile(
else:
specializations = lang_specs[:1]
qpc_key = "lang_prefill_qpc_path"
elif prefill_seq_len == 1 and not (
self.continuous_batching and full_batch_size is not None and full_batch_size != batch_size
):
elif prefill_seq_len == 1:
if self.comp_ctx_lengths_decode is not None:
specializations = lang_specs[-len(self.comp_ctx_lengths_decode) :]
else:
Expand Down
40 changes: 40 additions & 0 deletions tests/unit_test/models/test_model_quickcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -3481,6 +3481,46 @@ def test_layerwise_compile_hydrates_outer_qpc_paths(monkeypatch, tmp_path):
assert model.lang_model.qpc_path == qpc_path


@pytest.mark.llm_model
def test_dual_qpc_decode_only_continuous_batching_returns_decode_qpc_key(monkeypatch):
from QEfficient.transformers.models import modeling_auto
from QEfficient.transformers.models.modeling_auto import _QEffAutoModelForImageTextToTextDualQPC

model = object.__new__(_QEffAutoModelForImageTextToTextDualQPC)
model.continuous_batching = True
model.ccl_enabled = False
model.comp_ctx_lengths_prefill = None
model.comp_ctx_lengths_decode = None
model.transform = lambda **kwargs: None
model.model = type(
"Model",
(),
{
"config": type("Config", (), {"torch_dtype": torch.float32, "model_type": "test"})(),
"get_output_names": lambda self, **kwargs: {"vision": [], "lang": []},
"get_specializations": lambda self, **kwargs: ({"vision": [], "lang": [{"seq_len": 1}]}, {}),
},
)()
model.lang_model = type(
"LanguageModel",
(),
{"onnx_path": "language.onnx", "_compile": staticmethod(lambda **kwargs: "decode.qpc")},
)()

monkeypatch.setattr(modeling_auto, "_filter_custom_io_for_onnx", lambda custom_io, onnx_path: custom_io)

result = model.compile(
prefill_seq_len=1,
ctx_len=16,
batch_size=1,
full_batch_size=4,
skip_vision=True,
lang_onnx_path="language.onnx",
)

assert result == {"lang_decode_qpc_path": "decode.qpc"}


@pytest.mark.llm_model
def test_layerwise_compile_rejects_unsupported_model():
"""End-to-end smoke: invoking layerwise=True on llama bubbles the guard error."""
Expand Down
Loading