Skip to content

Commit 196fa06

Browse files
RJKeevilriccardopinosio
authored andcommitted
do not pad to nearest pow2 if using simpleGo
1 parent 4579a78 commit 196fa06

3 files changed

Lines changed: 20 additions & 8 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

7+
## [0.5.3] - 2025-09-01
8+
9+
### Changed
10+
11+
- Performance improvement: do not pad inputs to POW2 when using simplego backend
12+
713
## [0.5.2] - 2025-08-30
814

915
### Changed

pipelineBackends/model_gomlx.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ func loadInputOutputMetaGoMLX(model *onnx.Model) ([]InputOutputInfo, []InputOutp
193193
return inputs, outputs
194194
}
195195

196-
func createInputTensorsGoMLX(batch *PipelineBatch, model *Model, padBatchDimension bool) error {
196+
func createInputTensorsGoMLX(batch *PipelineBatch, model *Model, padBatchDimension bool, padSequenceDimension bool) error {
197197
leftPad := len(model.EosTokenIDs) > 0
198198

199199
// TODO: replace this once dynamic input shapes fixed
@@ -204,7 +204,7 @@ func createInputTensorsGoMLX(batch *PipelineBatch, model *Model, padBatchDimensi
204204
batchSize = nextPowerOf2(batchSize)
205205
}
206206
maxSeqLength := batch.MaxSequenceLength
207-
if !leftPad {
207+
if padSequenceDimension && !leftPad {
208208
maxSeqLength = nextPowerOf2(maxSeqLength)
209209
}
210210
total := batchSize * maxSeqLength

pipelineBackends/pipeline.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,10 @@ func RunGenerativeSessionOnBatch(batch *PipelineBatch, p *BasePipeline) error {
140140
switch p.Runtime {
141141
case "ORT":
142142
return runGenerativeORTSessionOnBatch(batch, p)
143-
case "GO", "XLA":
144-
return errors.New("GO/XLA backend is not yet implemented for generative models")
143+
case "GO":
144+
return errors.New("GO backend is not yet implemented for generative models")
145+
case "XLA":
146+
return errors.New("XLA backend is not yet implemented for generative models")
145147
default:
146148
return errors.New("invalid backend")
147149
}
@@ -153,8 +155,10 @@ func CreateInputTensorsTraining(batch *PipelineBatch, model *Model, runtime stri
153155
switch runtime {
154156
case "ORT":
155157
return createInputTensorsORT(batch, model)
156-
case "GO", "XLA":
157-
return createInputTensorsGoMLX(batch, model, false)
158+
case "GO":
159+
return createInputTensorsGoMLX(batch, model, false, false)
160+
case "XLA":
161+
return createInputTensorsGoMLX(batch, model, false, true)
158162
}
159163
return nil
160164
}
@@ -163,8 +167,10 @@ func CreateInputTensors(batch *PipelineBatch, model *Model, runtime string) erro
163167
switch runtime {
164168
case "ORT":
165169
return createInputTensorsORT(batch, model)
166-
case "GO", "XLA":
167-
return createInputTensorsGoMLX(batch, model, true)
170+
case "GO":
171+
return createInputTensorsGoMLX(batch, model, false, false)
172+
case "XLA":
173+
return createInputTensorsGoMLX(batch, model, true, true)
168174
}
169175
return nil
170176
}

0 commit comments

Comments
 (0)