Skip to content

Conversation

@jaideepr97
Copy link
Member

Current check for auto-detection of backend requires a vLLM friendly model's directory to contain *.safetensors files to qualify as valid. However, we should also accept the presence of *.bin files in place of *.safetensors files as training outputs .bin checkpoints that can be served through vLLM

Checklist:

  • Commit Message Formatting: Commit titles and messages follow guidelines in the
    conventional commits.
  • Changelog updated with breaking and/or notable changes for the next minor release.
  • Documentation has been updated, if necessary.
  • Unit tests have been added, if necessary.
  • Integration tests have been added, if necessary.

@jaideepr97 jaideepr97 marked this pull request as ready for review July 19, 2024 21:27
@mergify mergify bot added testing Relates to testing ci-failure PR has at least one CI failure and removed ci-failure PR has at least one CI failure labels Jul 19, 2024
@jaideepr97 jaideepr97 force-pushed the improve-model-detection branch 2 times, most recently from d7b06c4 to 4bdde20 Compare July 19, 2024 21:35
@jaideepr97 jaideepr97 removed the testing Relates to testing label Jul 19, 2024
@mergify mergify bot added the testing Relates to testing label Jul 19, 2024
Copy link
Contributor

@booxter booxter left a comment

Choose a reason for hiding this comment

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

Style change suggested; code-wise it's good I think.

Also, please re-wrap commit message lines to 50/72 rule. Thank you.

with open(
safetensors_model_path / "model.safetensors", "a+", encoding="UTF-8"
) as f:
model_file = (
Copy link
Contributor

Choose a reason for hiding this comment

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

with open(model_path / f"model.{model_file_type}", ...):
    pass

? (pass will be equivalent to f.write("") I think.)

Copy link
Member Author

Choose a reason for hiding this comment

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

what would the benefit of making that change be?

Copy link
Contributor

Choose a reason for hiding this comment

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

2 lines vs 10 lines? The nested ternary if-else is also rather convoluted.

Copy link
Member

Choose a reason for hiding this comment

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

Personally I'm not a fan of this approach, as it increases the valid values for file types from just safetensors and bin to allow all valid strings.

We should instead keep the values constricted to just safetensors and bin as those are types which we explicitly support, and instead throw a ValueError if the provided model type ever deviates.

In all likelihood, this function shouldn't be used outside of this codebase or even that much, so we shouldn't run into this error in the first place.

Copy link
Member

Choose a reason for hiding this comment

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

So we can just make the following change:

Suggested change
model_file = (
if model_file_type not in ("safetensors", "bin"):
raise ValueError(f"model file type is not supported: {model_file_type}")
with open(os.path.join(model_path, f"model.{model_file_type}"), "a+", encoding="UTF-8"):
pass

Copy link
Contributor

Choose a reason for hiding this comment

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

since this is test case, and if you'd like to raise an error, you can also assert model_file_type in (...)

Copy link
Contributor

Choose a reason for hiding this comment

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

(that said, I think there's a test variant here that actually passes "other".)

Copy link
Member Author

Choose a reason for hiding this comment

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

@booxter ah sorry - I totally misread what you were suggesting
have updated the code to match that, thanks! 🙏

@RobotSail this is just a test case so I think we do need to create valid and invalid scenarios to properly test the code

@jaideepr97
Copy link
Member Author

Also, please re-wrap commit message lines to 50/72 rule. Thank you.

Interesting @booxter , wasn't familiar with this rule but it seems like we haven't really been following it in this repository
I've mostly been asked to reuse the PR description as the commit msg

@booxter
Copy link
Contributor

booxter commented Jul 22, 2024

@jaideepr97 Yes, commit messages in this repo are most often than not non-compliant with 50/72. I don't think the project ever made an explicit decision that the rule should be enforced, but it shouldn't stop us from applying the best practice. Core git tools like git-log expect that the rule is adhered. And while we can discuss if 72 or 100 limit is the best for the project, having SOME limit and not piling the commit message into a single line shouldn't be controversial.

@russellb should the project formally document some rules for commit messages?

@russellb
Copy link
Member

@jaideepr97 Yes, commit messages in this repo are most often than not non-compliant with 50/72. I don't think the project ever made an explicit decision that the rule should be enforced, but it shouldn't stop us from applying the best practice. Core git tools like git-log expect that the rule is adhered. And while we can discuss if 72 or 100 limit is the best for the project, having SOME limit and not piling the commit message into a single line shouldn't be controversial.

@russellb should the project formally document some rules for commit messages?

Yes.

I started instructlab/dev-docs#110

haven't prioritized getting back to it to finish it up, though.

Copy link
Contributor

@Maxusmusti Maxusmusti left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@RobotSail RobotSail left a comment

Choose a reason for hiding this comment

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

LGTM

@mergify mergify bot added the one-approval PR has one approval from a maintainer label Jul 22, 2024
@leseb leseb added the hold In-progress PR. Tag should be removed before merge. label Jul 23, 2024
Copy link
Contributor

@leseb leseb left a comment

Choose a reason for hiding this comment

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

@booxter do you have request changes left? Added the hold flag until your concerns are resolved. Thanks

@mergify mergify bot removed the one-approval PR has one approval from a maintainer label Jul 23, 2024
@jaideepr97 jaideepr97 force-pushed the improve-model-detection branch from 4bdde20 to 727e478 Compare July 23, 2024 11:42
@mergify mergify bot added the ci-failure PR has at least one CI failure label Jul 23, 2024
@jaideepr97
Copy link
Member Author

updated the commit to follow 50/72 rule @booxter
sorry for the delay

Thanks for all the inputs, everyone!

@jaideepr97 jaideepr97 force-pushed the improve-model-detection branch from 727e478 to df01f54 Compare July 23, 2024 11:45
@mergify mergify bot removed the ci-failure PR has at least one CI failure label Jul 23, 2024
Current check for auto-detection of backend requires a vLLM friendly
model's directory to contain *.safetensors files to qualify as valid.
However, we should also accept the presence of *.bin files in place of
*.safetensors files as training outputs .bin checkpoints that can be
served through vLLM.

Signed-off-by: Jaideep Rao <[email protected]>
@jaideepr97 jaideepr97 force-pushed the improve-model-detection branch from df01f54 to e5c46d3 Compare July 23, 2024 12:18
@leseb leseb removed the hold In-progress PR. Tag should be removed before merge. label Jul 23, 2024
@mergify mergify bot merged commit ed5d5cd into instructlab:main Jul 23, 2024
@jaideepr97 jaideepr97 deleted the improve-model-detection branch August 12, 2024 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testing Relates to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants