Skip to content

[QEff. Finetune]: Adding base class and HF class#658

Merged
quic-swatia merged 4 commits intoquic:ft_experimentalfrom
quic-swatia:model_classes_exp
Dec 25, 2025
Merged

[QEff. Finetune]: Adding base class and HF class#658
quic-swatia merged 4 commits intoquic:ft_experimentalfrom
quic-swatia:model_classes_exp

Conversation

@quic-swatia
Copy link
Copy Markdown
Contributor

@quic-swatia quic-swatia commented Dec 9, 2025

  • Added Base Model class and HF model class.
  • Base Model class will support FT for any custom model and will be a common skeleton for any model, including HF.
  • Added unit tests for these.

Signed-off-by: Swati Allabadi <sallabad@qti.qualcomm.com>
Signed-off-by: Swati Allabadi <sallabad@qti.qualcomm.com>
Copy link
Copy Markdown
Contributor

@quic-meetkuma quic-meetkuma left a comment

Choose a reason for hiding this comment

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

Please use your reference code wisely. The implementation lacks main functionalities. The tests are not extensive and implemented in naive manner. Please correct them as well.

Reference code: https://github.com/quic-meetkuma/LightningLLMs/blob/hf_trainer/LightningLLM/components/model.py

Comment thread QEfficient/finetune/experimental/core/model.py Outdated
Comment thread QEfficient/finetune/experimental/core/model.py Outdated
return self._model

@property
def tokenizer(self) -> Any:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is applicable for NLP models. We can't put it in BaseClass. Better to create an abstract method called "preprocessor" which defines generic preprocessing function applicable for the model. There wont be any implementation here but the children class should implement that. In case of LLMs, this method should return tokenizer.

Comment thread QEfficient/finetune/experimental/core/model.py
@abstractmethod
def load_model(self) -> nn.Module:
"""Create and return the underlying torch.nn.Module."""
...
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

use "pass" as it is explicit.

Copy link
Copy Markdown
Contributor Author

@quic-swatia quic-swatia Dec 19, 2025

Choose a reason for hiding this comment

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

Updated in latest, doesn't make any difference though. Both syntax are valid.


# get_input_embeddings: underlying model lacks method, should warn and return None
with mock.patch("QEfficient.finetune.experimental.core.model.logger.info") as mocked_log:
assert m.get_input_embeddings() is None
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

create a proper dummy model which returns some embeddings rather than None. Your test should use HFModel class instead of some dummy class.

raising=False,
)

m = HFModel.create("hf-name")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No need to call individual class's create method. There is a reason to use a registry functionality.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Purpose of create is different than component_registry. Explained in another comment.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Move it to ComponentFactory and then instantiate from there.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Replied above.

tok = m.load_tokenizer()

# tokenizer was loaded and pad token inserted
model.AutoTokenizer.from_pretrained.assert_called_once_with("hf-name")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Dont write such tests filled with assert_called_once etc.. We have written such tests in past but that was not an appropriate thing. It was a makeshift arrangement because of monolith structure of code. Write extensive and proper tests. If a function has made some changes to the model's structure then use that to test rather then counting how many times the function gets called.

Comment thread QEfficient/finetune/experimental/tests/test_model.py


@registry.model("hf")
class HFModel(BaseModel):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We need to load the model based on configuration as well. That is mainly for testing purpose. In integration tests we will not load an entire model consists of 32 layers. But we will only load the same model with 2 or 4 layers and do further testing. For that purpose config should be used to load the model. Check huggingface documentation on how to do that.

Signed-off-by: Swati Allabadi <sallabad@qti.qualcomm.com>
@quic-swatia quic-swatia marked this pull request as draft December 19, 2025 10:43
@quic-swatia quic-swatia force-pushed the model_classes_exp branch 3 times, most recently from dddb4e7 to a963119 Compare December 25, 2025 01:01
Signed-off-by: Swati Allabadi <sallabad@qti.qualcomm.com>
@quic-swatia quic-swatia marked this pull request as ready for review December 25, 2025 01:07
@quic-swatia quic-swatia merged commit 866a140 into quic:ft_experimental Dec 25, 2025
3 checks passed
quic-dhirajku pushed a commit that referenced this pull request Jan 2, 2026
-  Added Base Model class and HF model class.
- Base Model class will support FT for any custom model and will be a
common skeleton for any model, including any HF model. 
- Added unit tests for these.

---------

Signed-off-by: Swati Allabadi <sallabad@qti.qualcomm.com>
Co-authored-by: Swati Allabadi <sallabad@qti.qualcomm.com>
tchawada pushed a commit to tchawada/QEff_tanisha that referenced this pull request Jan 16, 2026
-  Added Base Model class and HF model class.
- Base Model class will support FT for any custom model and will be a
common skeleton for any model, including any HF model. 
- Added unit tests for these.

---------

Signed-off-by: Swati Allabadi <sallabad@qti.qualcomm.com>
Co-authored-by: Swati Allabadi <sallabad@qti.qualcomm.com>
tchawada pushed a commit to tchawada/QEff_tanisha that referenced this pull request Feb 4, 2026
-  Added Base Model class and HF model class.
- Base Model class will support FT for any custom model and will be a
common skeleton for any model, including any HF model. 
- Added unit tests for these.

---------

Signed-off-by: Swati Allabadi <sallabad@qti.qualcomm.com>
Co-authored-by: Swati Allabadi <sallabad@qti.qualcomm.com>
tchawada pushed a commit to tchawada/QEff_tanisha that referenced this pull request Feb 4, 2026
-  Added Base Model class and HF model class.
- Base Model class will support FT for any custom model and will be a
common skeleton for any model, including any HF model. 
- Added unit tests for these.

---------

Signed-off-by: Swati Allabadi <sallabad@qti.qualcomm.com>
Co-authored-by: Swati Allabadi <sallabad@qti.qualcomm.com>
tchawada pushed a commit to tchawada/QEff_tanisha that referenced this pull request Feb 4, 2026
-  Added Base Model class and HF model class.
- Base Model class will support FT for any custom model and will be a
common skeleton for any model, including any HF model. 
- Added unit tests for these.

---------

Signed-off-by: Swati Allabadi <sallabad@qti.qualcomm.com>
Co-authored-by: Swati Allabadi <sallabad@qti.qualcomm.com>
tchawada pushed a commit to tchawada/QEff_tanisha that referenced this pull request Feb 4, 2026
-  Added Base Model class and HF model class.
- Base Model class will support FT for any custom model and will be a
common skeleton for any model, including any HF model. 
- Added unit tests for these.

---------

Signed-off-by: Swati Allabadi <sallabad@qti.qualcomm.com>
Co-authored-by: Swati Allabadi <sallabad@qti.qualcomm.com>
tchawada pushed a commit to tchawada/QEff_tanisha that referenced this pull request Feb 5, 2026
-  Added Base Model class and HF model class.
- Base Model class will support FT for any custom model and will be a
common skeleton for any model, including any HF model. 
- Added unit tests for these.

---------

Signed-off-by: Swati Allabadi <sallabad@qti.qualcomm.com>
Co-authored-by: Swati Allabadi <sallabad@qti.qualcomm.com>
tchawada pushed a commit to tchawada/QEff_tanisha that referenced this pull request Feb 5, 2026
-  Added Base Model class and HF model class.
- Base Model class will support FT for any custom model and will be a
common skeleton for any model, including any HF model. 
- Added unit tests for these.

---------

Signed-off-by: Swati Allabadi <sallabad@qti.qualcomm.com>
Co-authored-by: Swati Allabadi <sallabad@qti.qualcomm.com>
quic-swatia added a commit to quic-swatia/efficient-transformers that referenced this pull request Feb 9, 2026
-  Added Base Model class and HF model class.
- Base Model class will support FT for any custom model and will be a
common skeleton for any model, including any HF model. 
- Added unit tests for these.

---------

Signed-off-by: Swati Allabadi <sallabad@qti.qualcomm.com>
Co-authored-by: Swati Allabadi <sallabad@qti.qualcomm.com>
quic-akuruvil pushed a commit to quic-akuruvil/efficient_transformers that referenced this pull request Feb 9, 2026
-  Added Base Model class and HF model class.
- Base Model class will support FT for any custom model and will be a
common skeleton for any model, including any HF model. 
- Added unit tests for these.

---------

Signed-off-by: Swati Allabadi <sallabad@qti.qualcomm.com>
Co-authored-by: Swati Allabadi <sallabad@qti.qualcomm.com>
quic-akuruvil pushed a commit to quic-akuruvil/efficient_transformers that referenced this pull request Feb 16, 2026
-  Added Base Model class and HF model class.
- Base Model class will support FT for any custom model and will be a
common skeleton for any model, including any HF model. 
- Added unit tests for these.

---------

Signed-off-by: Swati Allabadi <sallabad@qti.qualcomm.com>
Co-authored-by: Swati Allabadi <sallabad@qti.qualcomm.com>
quic-swatia added a commit to quic-swatia/efficient-transformers that referenced this pull request Feb 26, 2026
-  Added Base Model class and HF model class.
- Base Model class will support FT for any custom model and will be a
common skeleton for any model, including any HF model. 
- Added unit tests for these.

---------

Signed-off-by: Swati Allabadi <sallabad@qti.qualcomm.com>
Co-authored-by: Swati Allabadi <sallabad@qti.qualcomm.com>
smedhe pushed a commit to smedhe/QEff_Sharvari that referenced this pull request Mar 6, 2026
-  Added Base Model class and HF model class.
- Base Model class will support FT for any custom model and will be a
common skeleton for any model, including any HF model. 
- Added unit tests for these.

---------

Signed-off-by: Swati Allabadi <sallabad@qti.qualcomm.com>
Co-authored-by: Swati Allabadi <sallabad@qti.qualcomm.com>
smedhe pushed a commit to smedhe/QEff_Sharvari that referenced this pull request Mar 6, 2026
-  Added Base Model class and HF model class.
- Base Model class will support FT for any custom model and will be a
common skeleton for any model, including any HF model.
- Added unit tests for these.

---------

Signed-off-by: Swati Allabadi <sallabad@qti.qualcomm.com>
Co-authored-by: Swati Allabadi <sallabad@qti.qualcomm.com>
Signed-off-by: Sharvari Medhe <smedhe@qti.qualcomm.com>
smedhe pushed a commit to smedhe/QEff_Sharvari that referenced this pull request Mar 6, 2026
-  Added Base Model class and HF model class.
- Base Model class will support FT for any custom model and will be a
common skeleton for any model, including any HF model.
- Added unit tests for these.

---------

Signed-off-by: Swati Allabadi <sallabad@qti.qualcomm.com>
Co-authored-by: Swati Allabadi <sallabad@qti.qualcomm.com>
Signed-off-by: Sharvari Medhe <smedhe@qti.qualcomm.com>
smedhe pushed a commit to smedhe/QEff_Sharvari that referenced this pull request Mar 8, 2026
-  Added Base Model class and HF model class.
- Base Model class will support FT for any custom model and will be a
common skeleton for any model, including any HF model.
- Added unit tests for these.

---------

Signed-off-by: Swati Allabadi <sallabad@qti.qualcomm.com>
Co-authored-by: Swati Allabadi <sallabad@qti.qualcomm.com>
Signed-off-by: Sharvari Medhe <smedhe@qti.qualcomm.com>
smedhe pushed a commit to smedhe/QEff_Sharvari that referenced this pull request Mar 8, 2026
-  Added Base Model class and HF model class.
- Base Model class will support FT for any custom model and will be a
common skeleton for any model, including any HF model.
- Added unit tests for these.

---------

Signed-off-by: Swati Allabadi <sallabad@qti.qualcomm.com>
Co-authored-by: Swati Allabadi <sallabad@qti.qualcomm.com>
Signed-off-by: Sharvari Medhe <smedhe@qti.qualcomm.com>

Signed-off-by: Sharvari Medhe <smedhe@qti.qualcomm.com>
smedhe pushed a commit to smedhe/QEff_Sharvari that referenced this pull request Mar 8, 2026
-  Added Base Model class and HF model class.
- Base Model class will support FT for any custom model and will be a
common skeleton for any model, including any HF model. 
- Added unit tests for these.

---------

Signed-off-by: Swati Allabadi <sallabad@qti.qualcomm.com>
Co-authored-by: Swati Allabadi <sallabad@qti.qualcomm.com>
Signed-off-by: Sharvari Medhe <smedhe@qti.qualcomm.com>
smedhe pushed a commit to smedhe/QEff_Sharvari that referenced this pull request Mar 9, 2026
-  Added Base Model class and HF model class.
- Base Model class will support FT for any custom model and will be a
common skeleton for any model, including any HF model. 
- Added unit tests for these.

---------

Signed-off-by: Swati Allabadi <sallabad@qti.qualcomm.com>
Co-authored-by: Swati Allabadi <sallabad@qti.qualcomm.com>
smedhe pushed a commit to smedhe/QEff_Sharvari that referenced this pull request Mar 10, 2026
-  Added Base Model class and HF model class.
- Base Model class will support FT for any custom model and will be a
common skeleton for any model, including any HF model. 
- Added unit tests for these.

---------

Signed-off-by: Swati Allabadi <sallabad@qti.qualcomm.com>
Co-authored-by: Swati Allabadi <sallabad@qti.qualcomm.com>
smedhe pushed a commit to smedhe/QEff_Sharvari that referenced this pull request Mar 17, 2026
-  Added Base Model class and HF model class.
- Base Model class will support FT for any custom model and will be a
common skeleton for any model, including any HF model. 
- Added unit tests for these.

---------

Signed-off-by: Swati Allabadi <sallabad@qti.qualcomm.com>
Co-authored-by: Swati Allabadi <sallabad@qti.qualcomm.com>
smedhe pushed a commit to smedhe/QEff_Sharvari that referenced this pull request Mar 18, 2026
-  Added Base Model class and HF model class.
- Base Model class will support FT for any custom model and will be a
common skeleton for any model, including any HF model.
- Added unit tests for these.

---------

Signed-off-by: Swati Allabadi <sallabad@qti.qualcomm.com>
Co-authored-by: Swati Allabadi <sallabad@qti.qualcomm.com>
Signed-off-by: Sharvari Medhe <smedhe@qti.qualcomm.com>
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.

2 participants