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

adding finetuned model setup #62838

Merged
merged 10 commits into from
May 22, 2024
Merged

Conversation

hitesh-1997
Copy link
Contributor

@hitesh-1997 hitesh-1997 commented May 22, 2024

Context

  1. Adds support for finetuned FIM models hosted on Fireworks. This PR adds the 4 variants and the traffic is routed to the appropriate model.
  2. Client side pull request: adding FIM finetuned model hosted on fireworks cody#4245

Test plan

curl -vS -X POST http://localhost:9992/v1/completions/fireworks -H 'Authorization: bearer <SGD_TOKEN>' -d '{"stream":false,"max_tokens":50, "model": "fim-fine-tuned-model-variant-1", "stop_sequences": ["\n\n"], "prompt": "const value = ", "stream":false}' -H 'X-sourcegraph-feature: code_completions'
curl -vS -X POST http://localhost:9992/v1/completions/fireworks -H 'Authorization: bearer <SGD_TOKEN>' -d '{"stream":false,"max_tokens":50, "model": "fim-fine-tuned-model-variant-2", "stop_sequences": ["\n\n"], "prompt": "const value = ", "stream":false}' -H 'X-sourcegraph-feature: code_completions'
curl -vS -X POST http://localhost:9992/v1/completions/fireworks -H 'Authorization: bearer <SGD_TOKEN>' -d '{"stream":false,"max_tokens":50, "model": "fim-fine-tuned-model-variant-3", "stop_sequences": ["\n\n"], "prompt": "const value = ", "stream":false}' -H 'X-sourcegraph-feature: code_completions'
curl -vS -X POST http://localhost:9992/v1/completions/fireworks -H 'Authorization: bearer <SGD_TOKEN>' -d '{"stream":false,"max_tokens":50, "model": "fim-fine-tuned-model-variant-4", "stop_sequences": ["\n\n"], "prompt": "const value = ", "stream":false}' -H 'X-sourcegraph-feature: code_completions'

@cla-bot cla-bot bot added the cla-signed label May 22, 2024
@hitesh-1997 hitesh-1997 requested a review from rafax May 22, 2024 06:05
@@ -170,7 +188,7 @@ func (c *fireworksClient) makeRequest(ctx context.Context, feature types.Complet
}

payload := fireworksRequest{
Model: requestParams.Model,
Model: c.updateModelStringIfFinetunedModelId(requestParams.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.

Hi @rafax
My local cody gateway setup is not working, can you please verify this re-routing logic for the fine tuning model string.

@rafax
Copy link
Contributor

rafax commented May 22, 2024

curl -vS -X POST http://localhost:9992/v1/completions/fireworks -H 'Authorization: bearer <SGD_TOKEN>' -d '{"stream":false,"max_tokens":50, "model": "cody-autocomplete-fim-finetuned-model-variant1", "stop_sequences": ["\n\n"], "prompt": "const value = ", "stream":false}' -H 'X-sourcegraph-feature: code_completions'

You want fim-fine-tuned-model-variant-1 as model name (no cody-autocomplete, with a - in fine-tuned, with a - before 1).

@hitesh-1997
Copy link
Contributor Author

hitesh-1997 commented May 22, 2024

curl -vS -X POST http://localhost:9992/v1/completions/fireworks -H 'Authorization: bearer <SGD_TOKEN>' -d '{"stream":false,"max_tokens":50, "model": "cody-autocomplete-fim-finetuned-model-variant1", "stop_sequences": ["\n\n"], "prompt": "const value = ", "stream":false}' -H 'X-sourcegraph-feature: code_completions'

You want fim-fine-tuned-model-variant-1 as model name (no cody-autocomplete, with a - in fine-tuned, with a - before 1).

Ah yes, sorry I did not run it since my local gateway is not working, I updated the commands in the description

@@ -65,6 +65,7 @@ type CompletionRequestParameters struct {
Model string `json:"model,omitempty"`
Stream *bool `json:"stream,omitempty"`
Logprobs *uint8 `json:"logprobs"`
LanguageId string `json:"languageId,omitempty"`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @rafax
I added this new parameter for language level routing to fireworks models. Although it should empty by default, could you confirm this shouldn't break any existing functionality ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rafax do we still need changes here after shifting them to fireworks ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Removed

@@ -152,6 +155,50 @@ func (c *fireworksClient) Stream(
return dec.Err()
}

func (c *fireworksClient) updateModelStringIfFinetunedModelId(languageId string, model string) string {
Copy link
Contributor

Choose a reason for hiding this comment

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

Note that this code is in Sourcegraph backend (no cody-gateway in the path), so it will not be executed for PLG requests (which bypass sourcegraph.com). If you want this to apply to PLG, you need to modify cmd/cody-gateway/internal/httpapi/completions/fireworks.go (ex. pickStarCoderModel function)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @rafax do we need this from here ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Removed

Copy link
Contributor

@rafax rafax left a comment

Choose a reason for hiding this comment

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

Move code to Cody Gateway


body.Model = pickStarCoderModel(body.Model, f.config)
body.Model = pickFineTunedModel(body.Model, body.LanguageID)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @rafax
did not notice this before merging the PR, but doing this body.LanguageID = "" in line 142 for the condition body.LanguageID will always make languageId empty. I tested it locally and it was always returning the all language completions. Adding a minor fix for this, which I tested locally.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, I updated the E2E tests to catch similar issues (verifying we resolve the right model)

@hitesh-1997 hitesh-1997 merged commit f12393d into main May 22, 2024
11 checks passed
@hitesh-1997 hitesh-1997 deleted the hitesh/finetuned-fim-model-integration branch May 22, 2024 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants