Skip to content

Commit d2bb249

Browse files
committed
build and test fixes
1 parent 4ffbb3a commit d2bb249

15 files changed

Lines changed: 251 additions & 244 deletions

Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
ARG GO_VERSION=1.25.5
44
ARG ONNXRUNTIME_VERSION=1.23.2
5-
ARG ONNXRUNTIME_GENAI_VERSION=0.11.14
5+
ARG ONNXRUNTIME_GENAI_VERSION=0.11.4
66
ARG GOPJRT_VERSION=0.83.1
77
ARG BUILD_PLATFORM=linux/amd64
88

@@ -12,12 +12,14 @@ ARG BUILD_PLATFORM=linux/amd64
1212
FROM --platform=$BUILD_PLATFORM public.ecr.aws/amazonlinux/amazonlinux:2023 AS hugot-runtime
1313
ARG GO_VERSION
1414
ARG ONNXRUNTIME_VERSION
15+
ARG ONNXRUNTIME_GENAI_VERSION
1516
ARG GOPJRT_VERSION
1617

1718
ENV PATH="$PATH:/usr/local/go/bin" \
1819
GOPJRT_NOSUDO=1
1920

2021
COPY ./scripts/download-onnxruntime.sh /download-onnxruntime.sh
22+
COPY ./scripts/download-onnxruntime-genai.sh /download-onnxruntime-genai.sh
2123
RUN --mount=src=./go.mod,dst=/go.mod \
2224
dnf --allowerasing -y install gcc jq bash tar xz gzip glibc-static libstdc++ wget zip git dirmngr sudo which && \
2325
ln -s /usr/lib64/libstdc++.so.6 /usr/lib64/libstdc++.so && \

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ To use Hugot as a library in your application, you can directly import it and fo
8282

8383
#### Backends
8484

85-
- if using Onnx Runtime, the onnxruntime.so file should be obtained from the releases section of this page. If you want to use alternative architectures from `linux/amd64` you will have to download it from [the ONNX Runtime releases page](https://github.com/microsoft/onnxruntime/releases/), see the [dockerfile](./Dockerfile) as an example. Hugot looks for this file at /usr/lib/onnxruntime.so or /usr/lib64/onnxruntime.so by default. A different location can be specified by passing the `WithOnnxLibraryPath()` option to `NewORTSession()`, e.g:
85+
- if using Onnx Runtime, the onnxruntime.so file should be obtained from the releases section of this page. If you want to use alternative architectures from `linux/amd64` you will have to download it from [the ONNX Runtime releases page](https://github.com/microsoft/onnxruntime/releases/), see the [dockerfile](./Dockerfile) as an example. Hugot looks for this file at /usr/lib/libonnxruntime.so by default. A different location can be specified by passing the `WithOnnxLibraryPath()` option to `NewORTSession()`, e.g:
8686

8787
```
8888
session, err := NewORTSession(
@@ -274,12 +274,11 @@ To use Hugot with Nvidia gpu acceleration, you need to have the following:
274274

275275
- The Nvidia driver for your graphics card (if running in Docker and WSL2, starting with --gpus all should inherit the drivers from the host OS)
276276
- ONNX Runtime:
277-
- The cuda gpu version of ONNX Runtime on the machine/docker container. You can see how we get that by looking at the [Dockerfile](./Dockerfile). You can also get the ONNX Runtime libraries that we use for testing from the release. Just download the gpu .so libraries and put them in /usr/lib64.
277+
- The cuda gpu version of ONNX Runtime on the machine/docker container. You can see how we get that by looking at the [Dockerfile](./Dockerfile). You can also get the ONNX Runtime libraries that we use for testing from the release. Just download the gpu .so libraries and put them in /usr/lib.
278278
- The required CUDA libraries installed on your system that are compatible with the ONNX Runtime gpu version you use. See [here](https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html). For instance, for onnxruntime-gpu 19.0, we need CUDA 12.x (any minor version should be compatible) and cuDNN 9.x.
279279
- Start a session with the following:
280280
```
281281
opts := []options.WithOption{
282-
options.WithOnnxLibraryPath("/usr/lib64/onnxruntime-gpu/libonnxruntime.so"),
283282
options.WithCuda(map[string]string{
284283
"device_id": "0",
285284
}),

backends/model_ort.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,35 +37,35 @@ func mapORTOptions(options *options.Options) ([]string, map[string]map[string]st
3737

3838
// CUDA
3939
if ortOptions.CudaOptions != nil {
40-
providers = append(providers, "NvTensorRtRtxExecutionProvider")
41-
providerOptions["NvTensorRtRtxExecutionProvider"] = ortOptions.CudaOptions
40+
providers = append(providers, "cuda")
41+
providerOptions["cuda"] = ortOptions.CudaOptions
4242
}
4343

4444
// CoreML
4545
if ortOptions.CoreMLOptions != nil {
46-
providers = append(providers, "CoreMLExecutionProvider")
47-
providerOptions["CoreMLExecutionProvider"] = ortOptions.CoreMLOptions
46+
providers = append(providers, "CoreML")
47+
providerOptions["CoreML"] = ortOptions.CoreMLOptions
4848
}
4949

5050
// DirectML
5151
if ortOptions.DirectMLOptions != nil {
52-
providers = append(providers, "DirectMLExecutionProvider")
52+
providers = append(providers, "DML")
5353
// Map device id to string map expected by advanced session
54-
providerOptions["DirectMLExecutionProvider"] = map[string]string{
54+
providerOptions["DML"] = map[string]string{
5555
"device_id": strconv.Itoa(*ortOptions.DirectMLOptions),
5656
}
5757
}
5858

5959
// OpenVINO
6060
if ortOptions.OpenVINOOptions != nil {
61-
providers = append(providers, "OpenVINOExecutionProvider")
62-
providerOptions["OpenVINOExecutionProvider"] = ortOptions.OpenVINOOptions
61+
providers = append(providers, "OpenVINO")
62+
providerOptions["OpenVINO"] = ortOptions.OpenVINOOptions
6363
}
6464

6565
// TensorRT
6666
if ortOptions.TensorRTOptions != nil {
67-
providers = append(providers, "TensorRTExecutionProvider")
68-
providerOptions["TensorRTExecutionProvider"] = ortOptions.TensorRTOptions
67+
providers = append(providers, "NvTensorRtRtx")
68+
providerOptions["NvTensorRtRtx"] = ortOptions.TensorRTOptions
6969
}
7070
return providers, providerOptions, nil
7171
}

cmd/main_test.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ import (
1515
"github.com/knights-analytics/hugot/util/fileutil"
1616
)
1717

18-
const onnxRuntimeSharedLibrary = "/usr/lib64/onnxruntime.so"
19-
2018
func TestTextClassificationCli(t *testing.T) {
2119
app := &cli.Command{
2220
Name: "hugot",
@@ -43,7 +41,6 @@ func TestTextClassificationCli(t *testing.T) {
4341

4442
args := append(baseArgs, "run",
4543
fmt.Sprintf("--input=%s", testDataDir),
46-
fmt.Sprintf("--s=%s", onnxRuntimeSharedLibrary),
4744
fmt.Sprintf("--model=%s", testModel),
4845
"--type=textClassification")
4946
if err := app.Run(context.Background(), args); err != nil {
@@ -73,7 +70,6 @@ func TestTokenClassificationCli(t *testing.T) {
7370

7471
args := append(baseArgs, "run",
7572
fmt.Sprintf("--input=%s", path.Join(testDataDir, "test-token-classification.jsonl")),
76-
fmt.Sprintf("--s=%s", onnxRuntimeSharedLibrary),
7773
fmt.Sprintf("--model=%s", testModel),
7874
"--type=tokenClassification",
7975
fmt.Sprintf("--output=%s", testDataDir))
@@ -105,7 +101,6 @@ func TestFeatureExtractionCli(t *testing.T) {
105101

106102
args := append(baseArgs, "run",
107103
fmt.Sprintf("--input=%s", path.Join(testDataDir, "test-feature-extraction.jsonl")),
108-
fmt.Sprintf("--s=%s", onnxRuntimeSharedLibrary),
109104
fmt.Sprintf("--model=%s", testModel),
110105
fmt.Sprintf("--onnxFilename=%s", "model.onnx"),
111106
"--type=featureExtraction",
@@ -146,7 +141,6 @@ func TestModelChain(t *testing.T) {
146141
// try to download the model to hugo folder and run it
147142
args := append(baseArgs, "run",
148143
fmt.Sprintf("--input=%s", testDataDir),
149-
fmt.Sprintf("--s=%s", onnxRuntimeSharedLibrary),
150144
fmt.Sprintf("--model=%s", "KnightsAnalytics/distilbert-base-uncased-finetuned-sst-2-english"),
151145
"--type=textClassification")
152146
if err := app.Run(context.Background(), args); err != nil {
@@ -156,7 +150,6 @@ func TestModelChain(t *testing.T) {
156150
// run it again. This time the model should be read from the hugot folder without re-downloading it.
157151
args = append(baseArgs, "run", fmt.Sprintf("--input=%s", testDataDir),
158152
fmt.Sprintf("--model=%s", "KnightsAnalytics/distilbert-base-uncased-finetuned-sst-2-english"),
159-
fmt.Sprintf("--s=%s", onnxRuntimeSharedLibrary),
160153
"--type=textClassification")
161154
if err := app.Run(context.Background(), args); err != nil {
162155
check(t, err)

cuda.Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
ARG GO_VERSION=1.25.5
44
ARG ONNXRUNTIME_VERSION=1.23.2
5+
ARG ONNXRUNTIME_GENAI_VERSION=0.11.4
56
ARG GOPJRT_VERSION=0.83.1
67
ARG JAX_CUDA_VERSION=0.8.1
78
ARG BUILD_PLATFORM=linux/amd64
@@ -11,13 +12,15 @@ ARG BUILD_PLATFORM=linux/amd64
1112
FROM --platform=$BUILD_PLATFORM public.ecr.aws/amazonlinux/amazonlinux:2023 AS hugot-runtime
1213
ARG GO_VERSION
1314
ARG ONNXRUNTIME_VERSION
15+
ARG ONNXRUNTIME_GENAI_VERSION
1416
ARG GOPJRT_VERSION
1517
ARG JAX_CUDA_VERSION
1618

1719
ENV PATH="$PATH:/usr/local/go/bin" \
1820
GOPJRT_NOSUDO=1
1921

20-
COPY ./scripts/download-onnxruntime-gpu.sh /download-onnxruntime-gpu.sh
22+
COPY ./scripts/download-onnxruntime.sh /download-onnxruntime.sh
23+
COPY ./scripts/download-onnxruntime-genai.sh /download-onnxruntime-genai.sh
2124
RUN --mount=src=./go.mod,dst=/go.mod \
2225
dnf --allowerasing -y install gcc jq bash tar xz gzip glibc-static libstdc++ wget zip git dirmngr sudo which && \
2326
ln -s /usr/lib64/libstdc++.so.6 /usr/lib64/libstdc++.so && \

downloader.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func DownloadModel(modelName string, destination string, options DownloadOptions
6868
}
6969

7070
// make sure it's an onnx model with tokenizer
71-
downloadFiles, err := validateDownloadHfModel(repo, options)
71+
downloadFiles, err := validateDownloadedHFModel(repo, options)
7272
if err != nil {
7373
return "", err
7474
}
@@ -104,7 +104,7 @@ func DownloadModel(modelName string, destination string, options DownloadOptions
104104
return "", fmt.Errorf("failed to download %s after %d attempts", modelName, options.MaxRetries)
105105
}
106106

107-
func validateDownloadHfModel(repo *hub.Repo, options DownloadOptions) ([]string, error) {
107+
func validateDownloadedHFModel(repo *hub.Repo, options DownloadOptions) ([]string, error) {
108108
for i := 0; i < options.MaxRetries; i++ {
109109
err := repo.DownloadInfo(false)
110110
if err != nil {

go.mod

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/gomlx/go-huggingface v0.3.1
99
github.com/gomlx/gomlx v0.26.0-rc2
1010
github.com/gomlx/onnx-gomlx v0.3.4-rc0.0.20251216070438-403f89ce7f75
11-
github.com/knights-analytics/ortgenai v0.0.0-20251215144038-8c17ce42e8d5
11+
github.com/knights-analytics/ortgenai v0.0.0-20251217113036-5abc6d6b37b1
1212
github.com/stretchr/testify v1.11.1
1313
github.com/sugarme/tokenizer v0.3.0
1414
github.com/urfave/cli/v3 v3.6.1
@@ -17,8 +17,6 @@ require (
1717
golang.org/x/image v0.34.0
1818
)
1919

20-
replace github.com/knights-analytics/ortgenai => /home/rpinosio/repositories/knights/ortgenai
21-
2220
require (
2321
github.com/davecgh/go-spew v1.1.1 // indirect
2422
github.com/dustin/go-humanize v1.0.1 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
4141
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
4242
github.com/janpfeifer/go-benchmarks v0.1.1 h1:gLLy07/JrOKSnMWeUxSnjTdhkglgmrNR2IBDnR4kRqw=
4343
github.com/janpfeifer/go-benchmarks v0.1.1/go.mod h1:5AagXCOUzevvmYFQalcgoa4oWPyH1IkZNckolGWfiSM=
44+
github.com/knights-analytics/ortgenai v0.0.0-20251217113036-5abc6d6b37b1 h1:1CCq4Rux7SyRm+HG5rWydGeluI1NzBRvgbSj91GoFUg=
45+
github.com/knights-analytics/ortgenai v0.0.0-20251217113036-5abc6d6b37b1/go.mod h1:zolhST8PioaCCsnwHBUesIBKU4CW/ZrF169YjFfg7BY=
4446
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
4547
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
4648
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=

hugot_go_test.go

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -176,25 +176,28 @@ func TestObjectDetectionPipelineValidationGo(t *testing.T) {
176176
}
177177

178178
// text generation
179-
// func TestTextGenerationPipelineGo(t *testing.T) {
180-
// session, err := NewGoSession()
181-
// checkT(t, err)
182-
// defer func(session *Session) {
183-
// destroyErr := session.Destroy()
184-
// checkT(t, destroyErr)
185-
// }(session)
186-
// textGenerationPipeline(t, session)
187-
// }
188-
//
189-
// func TestTextGenerationPipelineValidationGo(t *testing.T) {
190-
// session, err := NewGoSession()
191-
// checkT(t, err)
192-
// defer func(session *Session) {
193-
// destroyErr := session.Destroy()
194-
// checkT(t, destroyErr)
195-
// }(session)
196-
// textGenerationPipelineValidation(t, session)
197-
// }
179+
180+
func TestTextGenerationPipelineGo(t *testing.T) {
181+
t.Skip("Generative models are not supported yet for Go")
182+
session, err := NewGoSession()
183+
checkT(t, err)
184+
defer func(session *Session) {
185+
destroyErr := session.Destroy()
186+
checkT(t, destroyErr)
187+
}(session)
188+
textGenerationPipeline(t, session)
189+
}
190+
191+
func TestTextGenerationPipelineValidationGo(t *testing.T) {
192+
t.Skip("Generative models are not supported yet for Go")
193+
session, err := NewGoSession()
194+
checkT(t, err)
195+
defer func(session *Session) {
196+
destroyErr := session.Destroy()
197+
checkT(t, destroyErr)
198+
}(session)
199+
textGenerationPipelineValidation(t, session)
200+
}
198201

199202
// No same name
200203

0 commit comments

Comments
 (0)