Skip to content
New issue

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

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

Already on GitHub? # to your account

feat: Implement the API design and set up pyproject.toml for building wheel #11

Merged
merged 7 commits into from
Oct 29, 2024

Conversation

aluu317
Copy link
Collaborator

@aluu317 aluu317 commented Oct 24, 2024

Run:

python3 -m build

to build a wheel

Then install it:

pip3 install .

And run the sdk example:

python3 fm_training_estimator/sdk/examples/ex1.py

This PR:

  • exposes 3 more estimate functions in sdk for a total of 4 estimate functions: memory, cost, time, tokens
  • changes some print statements to logging
  • updates the SDK example code

Copy link
Collaborator

@ChanderG ChanderG left a comment

Choose a reason for hiding this comment

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

I will need to test out the various UI's once (no integration tests yet!) to be fully sure about some of the changes, but looks good otherwise.

fm_training_estimator/ui/core.py Outdated Show resolved Hide resolved
fm_training_estimator/config/arguments.py Show resolved Hide resolved
Signed-off-by: Angel Luu <angel.luu@us.ibm.com>
Signed-off-by: Angel Luu <angel.luu@us.ibm.com>
Signed-off-by: Angel Luu <angel.luu@us.ibm.com>
Signed-off-by: Angel Luu <angel.luu@us.ibm.com>
Signed-off-by: Angel Luu <angel.luu@us.ibm.com>
@@ -45,7 +48,9 @@ def check_lookup(self, seqlen):
"batch_size": self.ta.per_device_train_batch_size,
"seq_len": seqlen,
"gpu_model": self.ia.gpuModel,
"method": self.fm.technique,
"method": "fsdp"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@ChanderG I wasn't sure about this. I saw that the data.csv file you gave me didn't have any "full" in the method column so I assumed maybe we are looking for "fsdp". Should I leave it as self.fm.technique.value which is full, or should this code be ok?

Copy link
Collaborator

Choose a reason for hiding this comment

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

We should remove the if condition and pass in technique as-is.

I only recently changed the frontend UI to display "full" instead of "fsdp". We can fix this mismatch either in the data.csv file, or in the web ui frontend. Most likely in the source data files, since "fsdp" is misleading when both are fsdp.

@aluu317 aluu317 marked this pull request as ready for review October 24, 2024 22:49
Copy link
Collaborator

@ChanderG ChanderG left a comment

Choose a reason for hiding this comment

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

I was testing the UI with the new changes and ran into a problem. This is in the "parse" function interface which you don't need for the SDK code as it stands (the user is expected to put together the config components directly in Python), but is needed in the other interfaces (UI/cli) where the input is parsed out of JSON.

Here is a minimal reproducer:

from enum import Enum
from transformers import HfArgumentParser
from dataclasses import dataclass, field

class TuningTechnique(Enum):
    LORA = "lora"
    FULL = "full"

@dataclass
class FMArguments:
    technique: TuningTechnique = field(
        default=TuningTechnique.FULL,
        metadata={"help": ("Fine-tuning technique being used")},
    )

config = {"technique": "lora"}
arg_parser = HfArgumentParser([FMArguments])
res = arg_parser.parse_dict(config)

print(res)

We expect the result to be a parsed FMArguments object, with the field technique an enum, but instead we get the technique field set to a string.

I think this is a limitation of HF Argparser (https://github.com/huggingface/transformers/blob/main/src/transformers/hf_argparser.py) in that it may not be possible to parse out from dict to enum like we would want.

Signed-off-by: Angel Luu <angel.luu@us.ibm.com>
Signed-off-by: Angel Luu <angel.luu@us.ibm.com>
@aluu317
Copy link
Collaborator Author

aluu317 commented Oct 28, 2024

@ChanderG Ahh good catch, I see the problem. I spent some time today trying to figure out how to get enum to work with JSON/dict parsing, but couldn't. So I switched it back to using str. Let me know if this is good to merge!

Copy link
Collaborator

@ChanderG ChanderG left a comment

Choose a reason for hiding this comment

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

LGTM.

@ChanderG ChanderG merged commit 2b88d82 into foundation-model-stack:main Oct 29, 2024
1 check passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants