Skip to content

Commit dff7443

Browse files
committed
fix: use int32 instead of uint64 and fix formatting for vllm
1 parent 3da4010 commit dff7443

File tree

4 files changed

+11
-17
lines changed

4 files changed

+11
-17
lines changed

backends_vllm.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ func initVLLMBackend(log *logrus.Logger, modelManager *models.Manager) (inferenc
2020

2121
func registerVLLMBackend(backends map[string]inference.Backend, backend inference.Backend) {
2222
backends[vllm.Name] = backend
23-
}
23+
}

backends_vllm_stub.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ func initVLLMBackend(log *logrus.Logger, modelManager *models.Manager) (inferenc
1414

1515
func registerVLLMBackend(backends map[string]inference.Backend, backend inference.Backend) {
1616
// No-op when vLLM is disabled
17-
}
17+
}

pkg/inference/backends/sglang/sglang_config.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func (c *Config) GetArgs(bundle types.ModelBundle, socket string, mode inference
5656

5757
// Add context-length if specified in model config or backend config
5858
if contextLen := GetContextLength(bundle.RuntimeConfig(), config); contextLen != nil {
59-
args = append(args, "--context-length", strconv.FormatUint(*contextLen, 10))
59+
args = append(args, "--context-length", strconv.Itoa(int(*contextLen)))
6060
}
6161

6262
return args, nil
@@ -65,16 +65,14 @@ func (c *Config) GetArgs(bundle types.ModelBundle, socket string, mode inference
6565
// GetContextLength returns the context length (context size) from model config or backend config.
6666
// Model config takes precedence over backend config.
6767
// Returns nil if neither is specified (SGLang will auto-derive from model).
68-
func GetContextLength(modelCfg types.Config, backendCfg *inference.BackendConfiguration) *uint64 {
68+
func GetContextLength(modelCfg types.Config, backendCfg *inference.BackendConfiguration) *int32 {
6969
// Model config takes precedence
70-
if modelCfg.ContextSize != nil {
71-
val := uint64(*modelCfg.ContextSize)
72-
return &val
70+
if modelCfg.ContextSize != nil && *modelCfg.ContextSize > 0 {
71+
return modelCfg.ContextSize
7372
}
7473
// Fallback to backend config
7574
if backendCfg != nil && backendCfg.ContextSize != nil && *backendCfg.ContextSize > 0 {
76-
val := uint64(*backendCfg.ContextSize)
77-
return &val
75+
return backendCfg.ContextSize
7876
}
7977
// Return nil to let SGLang auto-derive from model config
8078
return nil

pkg/inference/backends/sglang/sglang_config_test.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ func TestGetContextLength(t *testing.T) {
193193
name string
194194
modelCfg types.Config
195195
backendCfg *inference.BackendConfiguration
196-
expectedValue *uint64
196+
expectedValue *int32
197197
}{
198198
{
199199
name: "no config",
@@ -207,15 +207,15 @@ func TestGetContextLength(t *testing.T) {
207207
backendCfg: &inference.BackendConfiguration{
208208
ContextSize: int32ptr(4096),
209209
},
210-
expectedValue: float64ptr(4096),
210+
expectedValue: int32ptr(4096),
211211
},
212212
{
213213
name: "model config only",
214214
modelCfg: types.Config{
215215
ContextSize: int32ptr(8192),
216216
},
217217
backendCfg: nil,
218-
expectedValue: float64ptr(8192),
218+
expectedValue: int32ptr(8192),
219219
},
220220
{
221221
name: "model config takes precedence",
@@ -225,7 +225,7 @@ func TestGetContextLength(t *testing.T) {
225225
backendCfg: &inference.BackendConfiguration{
226226
ContextSize: int32ptr(4096),
227227
},
228-
expectedValue: float64ptr(16384),
228+
expectedValue: int32ptr(16384),
229229
},
230230
{
231231
name: "zero context size in backend config returns nil",
@@ -249,10 +249,6 @@ func TestGetContextLength(t *testing.T) {
249249
}
250250
}
251251

252-
func float64ptr(v uint64) *uint64 {
253-
return &v
254-
}
255-
256252
func int32ptr(v int32) *int32 {
257253
return &v
258254
}

0 commit comments

Comments
 (0)