Skip to content

Feat: Onbaord PlamoForCausalLM Architecture #351

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from
Draft
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
3 changes: 3 additions & 0 deletions QEfficient/base/pytorch_transforms.py
Original file line number Diff line number Diff line change
@@ -107,6 +107,9 @@ def apply(cls, model: nn.Module) -> Tuple[nn.Module, bool]:
):
for orig_method_name, mapped_method in repl_method_map.items():
setattr(module, orig_method_name, MethodType(mapped_method, module))
# Handling the __init__ calls in the models
if hasattr(module, "__qeff_init__"):
module.__qeff_init__()
transformed = True

return model, transformed
1 change: 1 addition & 0 deletions QEfficient/transformers/models/modeling_auto.py
Original file line number Diff line number Diff line change
@@ -1304,6 +1304,7 @@ class QEFFAutoModelForCausalLM(QEFFBaseModel):
FP8DeQuantLinearToLinearTransform,
CustomOpsTransform,
KVCacheTransform,
KVCacheModuleMethodMapperTransform,
]
_onnx_transforms = [FP16ClipTransform, SplitTensorsTransform]

6 changes: 6 additions & 0 deletions QEfficient/transformers/models/plamo/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -----------------------------------------------------------------------------
#
# Copyright (c) 2025 Qualcomm Innovation Center, Inc. All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
#
# -----------------------------------------------------------------------------
449 changes: 449 additions & 0 deletions QEfficient/transformers/models/plamo/modeling_plamo.py

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions QEfficient/transformers/models/pytorch_transforms.py
Original file line number Diff line number Diff line change
@@ -245,6 +245,13 @@
QEffPhi3ForCausalLM,
QEffPhi3Model,
)
from QEfficient.transformers.models.plamo.modeling_plamo import (
QEffPlamoAttention,
QEffPlamoDecoder,
QEffPlamoDecoderLayer,
QEffPlamoForCausalLM,
QEffPlamoModel,
)
from QEfficient.transformers.models.qwen2.modeling_qwen2 import (
QEffQwen2Attention,
QEffQwen2DecoderLayer,
@@ -485,5 +492,10 @@ class KVCacheModuleMethodMapperTransform(ModuleMethodMapperTransform):
"get_qeff_language_decoder": QEffInternVLModel.get_qeff_language_decoder,
},
"InternVisionEmbeddings": {"forward": QEffInternVisionEmbeddings.forward},
"PlamoForCausalLM": {"forward": QEffPlamoForCausalLM.forward},
"PlamoModel": {"forward": QEffPlamoModel.forward},
"PlamoDecoder": {"forward": QEffPlamoDecoder.forward},
"PlamoDecoderLayer": {"forward": QEffPlamoDecoderLayer.forward},
"Attention": {"forward": QEffPlamoAttention.forward},
}
_match_class_replace_method = {}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@
- [04/2025] [Granite 3.0 and 3.1 Language MOE Models] (https://huggingface.co/ibm-granite/granite-3.0-1b-a400m-base)
- [09/2024] [AWQ](https://arxiv.org/abs/2306.00978)/[GPTQ](https://arxiv.org/abs/2210.17323) 4-bit quantized models are supported <br>
- [09/2024] Now we support [PEFT](https://huggingface.co/docs/peft/index) models
- [04/2025] Added support for [PLaMo] (https://huggingface.co/pfnet/plamo-13b-instruct)
- [01/2025] Added support for [Ibm-Granite] (https://huggingface.co/ibm-granite/granite-3.1-8b-instruct)
- [01/2025] Added support for [Ibm-Granite-Guardian] (https://huggingface.co/ibm-granite/granite-guardian-3.1-8b)
- [09/2024] Added support for [Gemma-2-Family](https://huggingface.co/collections/google/gemma-2-release-667d6600fd5220e7b967f315)<br>
1 change: 1 addition & 0 deletions tests/transformers/models/test_causal_lm_models.py
Original file line number Diff line number Diff line change
@@ -44,6 +44,7 @@
"neuralmagic/Qwen2-0.5B-Instruct-FP8", # fp8 quant method, static, with lm head ignored
"ibm-granite/granite-3.1-2b-instruct",
"ibm-granite/granite-guardian-3.1-2b",
"pfnet/plamo-13b-instruct",
]

test_models_qnn = [