Skip to content

Commit c77c706

Browse files
committed
fix: rebase main and fix args and int64 lint errors
1 parent d83ac95 commit c77c706

File tree

2 files changed

+17
-65
lines changed

2 files changed

+17
-65
lines changed

pkg/inference/backends/sglang/sglang_config.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,6 @@ func (c *Config) GetArgs(bundle types.ModelBundle, socket string, mode inference
5959
args = append(args, "--context-length", strconv.FormatUint(*contextLen, 10))
6060
}
6161

62-
// Add arguments from backend config
63-
if config != nil {
64-
args = append(args, config.RuntimeFlags...)
65-
}
66-
6762
return args, nil
6863
}
6964

@@ -73,11 +68,12 @@ func (c *Config) GetArgs(bundle types.ModelBundle, socket string, mode inference
7368
func GetContextLength(modelCfg types.Config, backendCfg *inference.BackendConfiguration) *uint64 {
7469
// Model config takes precedence
7570
if modelCfg.ContextSize != nil {
76-
return modelCfg.ContextSize
71+
val := uint64(*modelCfg.ContextSize)
72+
return &val
7773
}
78-
// else use backend config
79-
if backendCfg != nil && backendCfg.ContextSize > 0 {
80-
val := uint64(backendCfg.ContextSize)
74+
// Fallback to backend config
75+
if backendCfg != nil && backendCfg.ContextSize != nil && *backendCfg.ContextSize > 0 {
76+
val := uint64(*backendCfg.ContextSize)
8177
return &val
8278
}
8379
// Return nil to let SGLang auto-derive from model config

pkg/inference/backends/sglang/sglang_config_test.go

Lines changed: 12 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func TestGetArgs(t *testing.T) {
8080
},
8181
mode: inference.BackendModeCompletion,
8282
config: &inference.BackendConfiguration{
83-
ContextSize: 8192,
83+
ContextSize: int32ptr(8192),
8484
},
8585
expected: []string{
8686
"-m",
@@ -95,39 +95,17 @@ func TestGetArgs(t *testing.T) {
9595
"8192",
9696
},
9797
},
98-
{
99-
name: "with runtime flags",
100-
bundle: &mockModelBundle{
101-
safetensorsPath: "/path/to/model/model.safetensors",
102-
},
103-
mode: inference.BackendModeCompletion,
104-
config: &inference.BackendConfiguration{
105-
RuntimeFlags: []string{"--mem-fraction-static", "0.9"},
106-
},
107-
expected: []string{
108-
"-m",
109-
"sglang.launch_server",
110-
"--model-path",
111-
"/path/to/model",
112-
"--host",
113-
"127.0.0.1",
114-
"--port",
115-
"30000",
116-
"--mem-fraction-static",
117-
"0.9",
118-
},
119-
},
12098
{
12199
name: "with model context size (takes precedence)",
122100
bundle: &mockModelBundle{
123101
safetensorsPath: "/path/to/model/model.safetensors",
124102
runtimeConfig: types.Config{
125-
ContextSize: ptrUint64(16384),
103+
ContextSize: int32ptr(16384),
126104
},
127105
},
128106
mode: inference.BackendModeCompletion,
129107
config: &inference.BackendConfiguration{
130-
ContextSize: 8192,
108+
ContextSize: int32ptr(8192),
131109
},
132110
expected: []string{
133111
"-m",
@@ -179,32 +157,6 @@ func TestGetArgs(t *testing.T) {
179157
"30000",
180158
},
181159
},
182-
{
183-
name: "combined config with context size and runtime flags",
184-
bundle: &mockModelBundle{
185-
safetensorsPath: "/path/to/model/model.safetensors",
186-
},
187-
mode: inference.BackendModeCompletion,
188-
config: &inference.BackendConfiguration{
189-
ContextSize: 4096,
190-
RuntimeFlags: []string{"--tp-size", "2", "--enable-flashinfer"},
191-
},
192-
expected: []string{
193-
"-m",
194-
"sglang.launch_server",
195-
"--model-path",
196-
"/path/to/model",
197-
"--host",
198-
"127.0.0.1",
199-
"--port",
200-
"30000",
201-
"--context-length",
202-
"4096",
203-
"--tp-size",
204-
"2",
205-
"--enable-flashinfer",
206-
},
207-
},
208160
}
209161

210162
for _, tt := range tests {
@@ -253,33 +205,33 @@ func TestGetContextLength(t *testing.T) {
253205
name: "backend config only",
254206
modelCfg: types.Config{},
255207
backendCfg: &inference.BackendConfiguration{
256-
ContextSize: 4096,
208+
ContextSize: int32ptr(4096),
257209
},
258210
expectedValue: ptrUint64(4096),
259211
},
260212
{
261213
name: "model config only",
262214
modelCfg: types.Config{
263-
ContextSize: ptrUint64(8192),
215+
ContextSize: int32ptr(8192),
264216
},
265217
backendCfg: nil,
266218
expectedValue: ptrUint64(8192),
267219
},
268220
{
269221
name: "model config takes precedence",
270222
modelCfg: types.Config{
271-
ContextSize: ptrUint64(16384),
223+
ContextSize: int32ptr(16384),
272224
},
273225
backendCfg: &inference.BackendConfiguration{
274-
ContextSize: 4096,
226+
ContextSize: int32ptr(4096),
275227
},
276228
expectedValue: ptrUint64(16384),
277229
},
278230
{
279231
name: "zero context size in backend config returns nil",
280232
modelCfg: types.Config{},
281233
backendCfg: &inference.BackendConfiguration{
282-
ContextSize: 0,
234+
ContextSize: int32ptr(0),
283235
},
284236
expectedValue: nil,
285237
},
@@ -300,3 +252,7 @@ func TestGetContextLength(t *testing.T) {
300252
func ptrUint64(v uint64) *uint64 {
301253
return &v
302254
}
255+
256+
func int32ptr(v int32) *int32 {
257+
return &v
258+
}

0 commit comments

Comments
 (0)