refactor: migrate embedding storage to BF16 format#1246
Merged
zhenghaoz merged 3 commits intogorse-io:masterfrom Apr 21, 2026
Merged
refactor: migrate embedding storage to BF16 format#1246zhenghaoz merged 3 commits intogorse-io:masterfrom
zhenghaoz merged 3 commits intogorse-io:masterfrom
Conversation
- Convert float32/float64 slices in labels to BF16 (uint16) format - Update Embedding.Value type from []float32 to []uint16 in CTR model - Add support for []float32 and []float64 direct label input - Update tests to use BF16 format for embedded labels
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1246 +/- ##
==========================================
+ Coverage 73.01% 73.28% +0.27%
==========================================
Files 91 91
Lines 16694 16704 +10
==========================================
+ Hits 12189 12242 +53
+ Misses 3262 3250 -12
+ Partials 1243 1212 -31 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…update item processing logic
Contributor
There was a problem hiding this comment.
Pull request overview
This PR migrates embedding storage across CTR and item-to-item logic from []float32/[]float64 to BF16 bit-pattern storage ([]uint16) to reduce memory usage and align embedding handling across the codebase.
Changes:
- Update CTR
Embedding.Valueto[]uint16and propagate through AFM batch prediction code paths. - Convert dataset label embedding processing to store embeddings as BF16 (
[]uint16) and add a BF16FromAnyhelper for mixed numeric inputs. - Update unit tests to assert against BF16-encoded embeddings.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
model/ctr/model_test.go |
Updates CTR model tests to pass BF16 embeddings ([]uint16). |
model/ctr/fm_xla.go |
Stops converting embeddings to BF16 inside batch prediction (now already BF16). |
model/ctr/fm.go |
Same as above for the non-XLA AFM path; expects BF16 embeddings. |
model/ctr/data_test.go |
Updates embedding conversion tests to assert BF16 output. |
model/ctr/data.go |
Changes Embedding.Value to []uint16 and converts input embedding representations to BF16. |
master/tasks.go |
Stores item embeddings directly as BF16 in CTR dataset construction. |
logics/item_to_item_test.go |
Removes toFloat32Slice tests (conversion responsibility moved). |
logics/item_to_item.go |
Switches embedding item-to-item ANN distance to BF16 Euclidean and uses BF16 vectors. |
dataset/dataset_test.go |
Updates dataset item label expectations to BF16-encoded embeddings; adds mixed-type input case. |
dataset/dataset.go |
Converts numeric []any label slices to BF16 during label processing. |
common/bfloats/bfloats_test.go |
Adds tests for bfloats.FromAny. |
common/bfloats/bfloats.go |
Adds FromAny and numeric conversion helper for BF16 ingestion. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR migrates embedding storage from float32 to BF16 (bfloat16) format for memory efficiency.
Changes
Embedding.Valuetype from[]float32to[]uint16[]float32and[]float64label inputRelated PRs
Benefits