-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3ad8b9c
commit dc77fe1
Showing
9 changed files
with
491 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module github.com/Trendyol/go-triton-client/basic-infer | ||
|
||
go 1.23.2 | ||
|
||
require github.com/Trendyol/go-triton-client v0.0.1 | ||
|
||
require ( | ||
github.com/x448/float16 v0.8.4 // indirect | ||
golang.org/x/net v0.28.0 // indirect | ||
golang.org/x/sys v0.24.0 // indirect | ||
golang.org/x/text v0.17.0 // indirect | ||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect | ||
google.golang.org/grpc v1.67.1 // indirect | ||
google.golang.org/protobuf v1.35.1 // indirect | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
github.com/Trendyol/go-triton-client v0.0.1 h1:RWWFQQ1vic3vlEZ1YVgzJfpN39JTqJpn9ejf4raJCYY= | ||
github.com/Trendyol/go-triton-client v0.0.1/go.mod h1:sS2kFrbNgc+3EPSTpc8Py9gNatJs30/UnwZpvxDM4Lk= | ||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | ||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= | ||
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= | ||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= | ||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= | ||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= | ||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= | ||
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= | ||
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= | ||
golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= | ||
golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= | ||
golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= | ||
golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= | ||
golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= | ||
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= | ||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1:e7S5W7MGGLaSu8j3YjdezkZ+m1/Nm0uRVRMEMGk26Xs= | ||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= | ||
google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E= | ||
google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= | ||
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA= | ||
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= | ||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= | ||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package basic_infer | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"github.com/Trendyol/go-triton-client/base" | ||
"github.com/Trendyol/go-triton-client/client/grpc" | ||
"github.com/Trendyol/go-triton-client/parser" | ||
"github.com/Trendyol/go-triton-client/postprocess" | ||
"log" | ||
) | ||
|
||
func performGRPCInference(tritonClient base.Client) { | ||
input := grpc.NewInferInput("input_ids", "INT64", []int64{1, 1}, nil) | ||
err := input.SetData([]int{101, 202536, 102}, true) // Example data | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
outputs := []base.InferOutput{ | ||
grpc.NewInferOutput("output_name", map[string]interface{}{"binary_data": true}), | ||
} | ||
|
||
response, err := tritonClient.Infer( | ||
context.Background(), | ||
"model_name", | ||
"model_version", | ||
[]base.InferInput{input}, | ||
outputs, | ||
nil, | ||
) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
// Process response | ||
sliceResp, err := response.AsSlice("output_name") | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
// Parse the response | ||
parsedData, ok := parser.ParseSlice[[][]float64](sliceResp) | ||
if !ok { | ||
log.Fatal("Failed to parse inference response") | ||
} | ||
|
||
// Post-process if needed | ||
postprocessManager := postprocess.NewPostprocessManager() | ||
processedData := postprocessManager.Float64ToFloat32Slice2D(parsedData) | ||
fmt.Println(processedData) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package basic_infer | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"github.com/Trendyol/go-triton-client/base" | ||
"github.com/Trendyol/go-triton-client/client/http" | ||
"github.com/Trendyol/go-triton-client/parser" | ||
"github.com/Trendyol/go-triton-client/postprocess" | ||
"log" | ||
) | ||
|
||
func performHttpInference(tritonClient base.Client) { | ||
inputIds := http.NewInferInput("input_ids", "INT64", []int64{2, 3}, nil) | ||
err := inputIds.SetData([]int{101, 202536, 102, 101, 202536, 102}, true) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
tokenTypeIds := http.NewInferInput("token_type_ids", "INT64", []int64{2, 3}, nil) | ||
err = tokenTypeIds.SetData([]int{0, 0, 0, 0, 0, 0}, true) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
attentionMask := http.NewInferInput("attention_mask", "INT64", []int64{2, 3}, nil) | ||
err = attentionMask.SetData([]int{1, 1, 1, 1, 1, 1}, true) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
outputs := []base.InferOutput{ | ||
http.NewInferOutput("logits", map[string]interface{}{"binary_data": true}), | ||
} | ||
|
||
response, err := tritonClient.Infer( | ||
context.Background(), | ||
"ty_bert", | ||
"1", | ||
[]base.InferInput{inputIds, tokenTypeIds, attentionMask}, | ||
outputs, | ||
nil, | ||
) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
sliceResp, err := response.AsSlice("logits") | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
embeddings, ok := parser.ParseSlice[[][][]float64](sliceResp) | ||
if !ok { | ||
log.Fatal("Failed to parse inference response") | ||
} | ||
|
||
postprocessManager := postprocess.NewPostprocessManager() | ||
convertedEmbeddings := postprocessManager.Float64ToFloat32Slice3D(embeddings) | ||
|
||
meanPooledEmbeddings, err := postprocessManager.MeanPoolingFloat32Slice3D(convertedEmbeddings, [][]int64{{1, 1, 1}, {1, 1, 1}}) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
fmt.Println(meanPooledEmbeddings) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
FROM golang:1.23.0 AS builder | ||
|
||
WORKDIR /app | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y git && \ | ||
apt-get install -y curl | ||
|
||
RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash && \ | ||
apt-get install -y git-lfs && \ | ||
git lfs install | ||
|
||
RUN git clone https://github.com/berkayersoyy/triton-ty-models.git /repo && \ | ||
cd /repo && git lfs pull && \ | ||
echo "Repository cloned with LFS files pulled" | ||
|
||
RUN cp -r /repo/models /models && \ | ||
cp -r /repo/tokenizers /tokenizers | ||
|
||
RUN rm -rf /repo | ||
|
||
COPY . . | ||
|
||
RUN apt-get update && apt-get install -y gcc | ||
|
||
ENV CGO_ENABLED=1 | ||
|
||
RUN go mod tidy && go mod download | ||
|
||
RUN go build -o main . | ||
|
||
FROM nvcr.io/nvidia/tritonserver:23.08-py3 | ||
|
||
RUN apt-get update && apt-get install -y curl | ||
|
||
COPY --from=builder /models /models | ||
COPY --from=builder /tokenizers /tokenizers | ||
COPY --from=builder /app/main /main | ||
|
||
COPY start.sh /start.sh | ||
RUN chmod +x /start.sh | ||
|
||
EXPOSE 8000 8001 8002 | ||
|
||
ENTRYPOINT ["/start.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module github.com/Trendyol/go-triton-client/end2end_inference | ||
|
||
go 1.23.0 | ||
|
||
require ( | ||
github.com/Trendyol/go-triton-client v0.0.1 | ||
github.com/Trendyol/go-triton-client/tokenizer v0.0.0-20241121105756-3ad8b9c92dce | ||
) | ||
|
||
require ( | ||
github.com/daulet/tokenizers v0.9.0 // indirect | ||
github.com/x448/float16 v0.8.4 // indirect | ||
golang.org/x/net v0.28.0 // indirect | ||
golang.org/x/sys v0.24.0 // indirect | ||
golang.org/x/text v0.17.0 // indirect | ||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect | ||
google.golang.org/grpc v1.67.1 // indirect | ||
google.golang.org/protobuf v1.35.1 // indirect | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
github.com/Trendyol/go-triton-client v0.0.1 h1:RWWFQQ1vic3vlEZ1YVgzJfpN39JTqJpn9ejf4raJCYY= | ||
github.com/Trendyol/go-triton-client v0.0.1/go.mod h1:sS2kFrbNgc+3EPSTpc8Py9gNatJs30/UnwZpvxDM4Lk= | ||
github.com/Trendyol/go-triton-client/tokenizer v0.0.0-20241121105756-3ad8b9c92dce h1:hlZNkBxJl2MYRy6ERKKdGlr6bZ/p/BRdoBhZXzHWJvg= | ||
github.com/Trendyol/go-triton-client/tokenizer v0.0.0-20241121105756-3ad8b9c92dce/go.mod h1:cN2Sb6vK08mXGhj5hSr36Hn8O/Xm92hyciqJbZxOsb0= | ||
github.com/daulet/tokenizers v0.9.0 h1:PSjFUGeuhqb3C0GKP9hdvtHvJ6L1AZceV+0nYGACtCk= | ||
github.com/daulet/tokenizers v0.9.0/go.mod h1:tGnMdZthXdcWY6DGD07IygpwJqiPvG85FQUnhs/wSCs= | ||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | ||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= | ||
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= | ||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= | ||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= | ||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= | ||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= | ||
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= | ||
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= | ||
golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= | ||
golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= | ||
golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= | ||
golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= | ||
golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= | ||
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= | ||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1:e7S5W7MGGLaSu8j3YjdezkZ+m1/Nm0uRVRMEMGk26Xs= | ||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= | ||
google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E= | ||
google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= | ||
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA= | ||
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= | ||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= | ||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
Oops, something went wrong.