8000 ml/zoo/transformer/generate: normalize integer prompt tensors to Int32 by janpfeifer · Pull Request #505 · gomlx/gomlx · GitHub
[go: up one dir, main page]

Skip to content

ml/zoo/transformer/generate: normalize integer prompt tensors to Int32 - #505

Merged
janpfeifer merged 1 commit into
mainfrom
fix-prompt-dtype
Nov 30, 2026
Merged

janpfeifer merged 1 commit into
mainfrom
fix-prompt-dtype

Conversation

@janpfeifer
Copy link
Copy Markdown
Contributor

Summary

  • Normalize integer prompt inputs ([]int, [][]int, []int64, non-Int32 integer *tensors.Tensor, etc.) to dtypes.Int32 at entry in Generator.Decode and Generator.GenerateStreaming via normalizePromptTensor.
  • Prevents Concatenate/DynamicUpdateSlice Int64 vs Int32 dtype mismatch panics when passing []int token IDs (e.g. from tokenizer.Encode) on dynamic-shape backends (go via growCurrentSeqDynamic), bucket-boundary prompts (updateCurrentSeq / growCurrentSeq), KV-cache early-EOS concatenation, and beam search (beamsearch.Step), while ensuring consistent Int32 outputs and rejecting non-integer prompt dtypes.
  • Preserves caller-owned *tensors.Tensor lifetimes while cleanly finalizing temporary tensors allocated during normalization.
  • Adds TestPromptDTypeNormalization in ml/zoo/transformer/generate/generate_test.go and updates docs/CHANGELOG.md.

Testing

  • go test -p 1 -v ./ml/zoo/transformer/generate/... (all unit tests including all 6 TestPromptDTypeNormalization subtests pass).
  • Verified end-to-end with go-huggingface/modeltests (gemma4-e4b and qwen3.5-4b on go and xla:cuda).

@janpfeifer
janpfeifer merged commit 1a52f7a into main Nov 30, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0