Skip to content
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

[caikit-nlp-163] Refactor peft module to take out common peft config functionality #174

Closed
wants to merge 8 commits into from

Conversation

rawkintrevo
Copy link
Contributor

No description provided.

Signed-off-by: Trevor Grant <[email protected]>
@rawkintrevo
Copy link
Contributor Author

@gkumbhat i moved a batch of stuff to a new file- is this what you had in mind? wanted to confirm i was on the right path before i did more stuff

Copy link
Collaborator

@gkumbhat gkumbhat Sep 5, 2023

Choose a reason for hiding this comment

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

Thanks @rawkintrevo for quick turn-around. I think 1 other thing that would move would be https://github.com/caikit/caikit-nlp/pull/174/files#diff-1cb191003903163320c02f8ffaf7c5edd48ca6649cd3092d1b4c3a0fdcd038c1R376 function, since that returns the peft_config which is then passed to get the peft_model

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Signed-off-by: Trevor Grant <[email protected]>
@rawkintrevo
Copy link
Contributor Author

I think I've bashed all the bugs, we'll see what the checks say. If so I'll write unit tests tomorrow

Signed-off-by: Trevor Grant <[email protected]>
Signed-off-by: Trevor Grant <[email protected]>
@rawkintrevo rawkintrevo linked an issue Sep 7, 2023 that may be closed by this pull request
1 task
@rawkintrevo rawkintrevo added this to the Add support for LoRA milestone Sep 7, 2023
@rawkintrevo rawkintrevo self-assigned this Sep 7, 2023
@rawkintrevo rawkintrevo requested a review from gkumbhat September 7, 2023 17:35
Signed-off-by: Trevor Grant <[email protected]>
@rawkintrevo rawkintrevo changed the title [wip][caikit-nlp-163] Refactor peft module to take out common peft config functionality [caikit-nlp-163] Refactor peft module to take out common peft config functionality Sep 8, 2023
"Validated tuning source prompt [%s]",
tuning_config.prompt_tuning_init_source_model,
)
base_model_name = base_model._model_name
Copy link
Collaborator

Choose a reason for hiding this comment

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

since in runtime use-cases we do accept str as base_model this would error out. Can we bring back the base_model parsing logic we had in the train function earlier to resolve that. ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The linked block exists in peft_config.py at line 100

Copy link
Collaborator

Choose a reason for hiding this comment

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

yep, but the problem is that one is getting called after we do line 347. And so line 347 can fail if base_model is a string.

Since the code to resolve the base_model is common. It might make sense to pull that out from validate_peft_config function into a separate resolve_base_model function and we call that function before we call validate_peft_config.. So essentially:

base_model = resolve_base_model(base_model)
task_type, output_model_types, peft_config, tuning_type = validate_peft_config(..., base_model, ...)

# LORA = "LORA"


def validate_peft_config(
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: can we rename the function to get_peft_config as this function takes the raw config from our side and returns back the "peft config` ?



def validate_peft_config(
tuning_type, tuning_config, error, log, base_model, cls, torch_dtype, verbalizer
Copy link
Collaborator

Choose a reason for hiding this comment

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

We usually initialize logger per module / file to allow easy backtracking. To do this, we can initialize log at the beginning of this file and re-use that everywhere in this file.

log = alog.use_channel("PFT_CNFG_TLKT")

"Validated tuning source prompt [%s]",
tuning_config.prompt_tuning_init_source_model,
)
base_model_name = base_model._model_name
Copy link
Collaborator

Choose a reason for hiding this comment

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

yep, but the problem is that one is getting called after we do line 347. And so line 347 can fail if base_model is a string.

Since the code to resolve the base_model is common. It might make sense to pull that out from validate_peft_config function into a separate resolve_base_model function and we call that function before we call validate_peft_config.. So essentially:

base_model = resolve_base_model(base_model)
task_type, output_model_types, peft_config, tuning_type = validate_peft_config(..., base_model, ...)

Copy link
Collaborator

@gkumbhat gkumbhat left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks Trevor. We need to coordinate these merges a bit as they are all changing same files.

@rawkintrevo
Copy link
Contributor Author

ack @gkumbhat - will let someone else coordinate the merge

@alex-jw-brooks
Copy link
Collaborator

Pushed a rebased version of this branch to #197!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Closed
Development

Successfully merging this pull request may close these issues.

Refactor peft module to take out common peft config functionality
3 participants