Skip to content

[Feature Request]: bf16 and its vector friends #20567

Description

@fengttt

Is there an existing issue for the same feature request?

  • I have checked the existing issues.

Is your feature request related to a problem?

Implement bf16 and its corresponding vector, sparse vector etc types.

https://en.wikipedia.org/wiki/Bfloat16_floating-point_format

Note that bf16 is NOT the same as IEEE half precision format.  bf16 is a simple shortening of float32.   It is much more widely used in AI world than half precision.

Describe the feature you'd like

New data type.

Describe implementation you've considered

No response

Documentation, Adoption, Use Case, Migration Strategy

No response

Additional information

No response

Activity

  1. added
    priority/p0
    on Dec 4, 2024
  2. added this to the 2.1.0 milestone on Dec 4, 2024
  3. modified the milestones: 2.1.0, Backlog on Mar 27, 2025
  4. modified the milestones: Backlog, 2507 on Apr 27, 2025
  5. modified the milestones: MO-2507, MO-2508 on Aug 11, 2025
  6. modified the milestones: MO-2508, MO-202603 on Feb 3, 2026
  7. assigned and unassigned on Jun 29, 2026
  8. 148 remaining items

  9. added 6 commits that reference this issue on Oct 30, 2026
  10. slyunnn commented on Nov 11, 2026

    @slyunnn

    Feature verification for #20567 (bf16 and low-precision vector types) (2026-11-11)

    Test environment

    • Implementations: PR #25095 introduced narrow vectors/index quantization; PR #29554, merge 815a6ab038c4a285cdca8169d518f9bb04cdb906, added scalar bf16/float16/float8/float4, vecf8/vecf4 and VECTOR_MATMUL. Its accepted scalar design explicitly defers sparse vectors to separate work.
    • Tested source and binary: 553e16f52b02d59e9ecc5e3c8862f2603e661f48, fix(parser): support quoted wildcards in DESCRIBE shortcuts (#32339). Binary -version reports 553e16f52b, Go 1.27.1, Darwin/arm64; SHA256 33c50723cc82728d59a58d03ba7e879850db0493584d168eab998d79cfb887bc.
    • git fetch origin succeeded. Latest fetched main and independent GitHub API lookup both returned d9190ff6d01d15d60acdfcdc9acd96f807a7ab6a. Git ancestry confirms the feature merge is contained in both tested HEAD and main. Tested HEAD is three commits behind main; those three commits were not tested.
    • Fresh isolated local deployment: 2 CN / 1 TN / 1 LogService + Proxy, shared local DISK-V2 storage, copied binary/native libraries/configuration, macOS 26.6 arm64. MySQL TCP: Proxy 127.0.0.1:6001, CNs 127.0.0.1:16001 and 127.0.0.1:16002. All three returned git_version() = 553e16f52b and actually executed the independent protocol/state checks. SQL file replay used CN1.
    • Clients: PyMySQL 1.2.4; MySQL Connector/Python 26.10.0 with binary prepared cursors. The service source was not modified; pre-existing untracked .moi-30149/ remained unchanged in Git status.

    Test results

    • Scalar types: DDL/DML, defaults, casts, finite ranges, exact rounding boundaries, comparisons, aggregation, grouping, windows, joins, user variables, SQL preparation and unsupported keys matched existing expectations. Populated-table COPY ALTER ... ADD COLUMN ... NOT NULL without a default succeeded with zero backfill for all four scalar types; the October review finding is covered by the merged regression and passed this run.
    • Block-scaled vectors: dimensions, odd padding/block boundaries, exact cell/text/binary conversions, invalid input, comparisons, DML and CSV/JSONL/Parquet export/load round trips matched expectations. These checks include decoded values and exact binary equality where the existing SQL asserts it.
    • CPU VECTOR_MATMUL: filtering, grouping, ties, empty/NULL input, parameters, invalid configuration, all three metrics and the existing 400000-row result comparisons matched expectations. Separately calculated distances and hit ordering from decoded stored vectors matched both vecf8 and vecf4 for two queries under inner_product, l2sq and cosine (12 independent comparisons).
    • Independent rounding: 10 BF16/IEEE-half boundary cases matched exact-rational BF16 nearest-even selection and Python IEEE-half conversion, comparing float32 bits after canonicalizing zero. No float32 intermediate was used in the final BF16 oracle.
    • Narrow vectors and IVFFLAT: reused vector conversions/reductions, generic operations, quantization/index queries and synchronous insert/update/delete regressions all matched expected outcomes.
    • Protocol/state: on all three routes, text results, binary-prepared scalar results and parameterized scalar/vector inserts passed. A rolled-back update preserved the complete original row when read from the other CN. A committed update was flushed; after graceful process restart, complete scalar/vector rows and a persisted view matched saved pre-restart results through all three routes. This is restart durability evidence, not crash recovery or HA certification.

    Bugs

    No reproducible product bug was found.

    Initial mismatches were test-adapter/oracle defects: JDBC error prefixes, FOUND_ROWS, resource substitution, legacy golden formatting, trailing newlines, ignored flush payloads, and an oracle that retained negative zero and rounded wider BF16 input through float32. First-run evidence was retained; corrections and reruns are recorded separately.

    Regression coverage

    Existing checked-in SQL and golden files were reused:

    File Statements matching expectations
    dtype/lowprec_float.sql 447/447
    dtype/lowprec_ddl_dml.sql 75/75
    dtype/vecblock.sql 265/265
    vector/vector_matmul.sql 119/119
    array/array_vecnarrow.sql 73/73
    vector/vector_narrow_types_generic.sql 40/40
    vector/vector_ivf_quantization.sql 95/95
    vector/vector_ivf_quant_dml_sync.sql 117/117

    Total: 1231/1231 statements matched expectations, including 149 expected errors; independently executed checks: 43/43.

    Execution used python work/replay.py <case paths from the table, without .sql>, python work/probe.py prepare, a graceful service restart with the same isolated data directory, then python work/probe.py verify.

    These were sequential custom-adapter replays, not a full mo-tester/MOTR run. The adapter compared row values and expected error messages, retained native error codes, normalized numeric/text formatting, and required OK for operational flushes. JDBC metadata descriptors were not compared. No MOTR commit, PR or new Nightly run was created: the deterministic CPU regressions already exist. The existing 400000-row case was executed; no additional large-data suite was needed for the validated CPU semantics. Worker/batch/block/spill execution was not instrumented, and no engine-parallelism claim is made.

    Evidence and not covered

    Local deliverables contain raw SQL inputs, golden snapshots, actual results/errors, independent oracle outputs, source/binary/native-library fingerprints, configurations, first-run failures, corrected reruns and service/restart logs, with a SHA256 manifest. Local files are not publicly accessible evidence; this comment reports reproducible commands and counts without presenting local paths as public links. Runtime data remains available locally for review; test databases were dropped by the SQL files/probe, and the isolated service was stopped.

    • Required remaining acceptance work: GPU VECTOR_MATMUL and GPU distance semantics on a supported CUDA build/device (compute capability >= 10.0), including GPU numerical/admission boundaries. The local Darwin/arm64 build has no CUDA device. The requester also confirmed on 2026-11-11 that no GPU environment is currently available. The existing MO GPU Vector Test workflow was inspected; its current jobs focus on IVFPQ/benchmarks and do not directly execute the new matmul GPU regression. It was not dispatched. A suitable target and execution of gpu_cases/vector/vector_matmul_gpu.sql and related semantics coverage are still needed.
    • Not executed: current main's three newer commits, Python matrixone.vecblock follow-up APIs from PR #32166, full-cluster upgrade, crash/failover, GPU performance/scale and cross-CN distributed worker instrumentation. Python SDK follow-up and operational extensions are separate from this CPU SQL verification.
    • Sparse vectors are explicitly deferred, not a failed acceptance item for PR feat: low-precision float types bf16/float16/float8/float4 and vecf8/vecf4 vector columns (#20567) #29554. September verification and PR-author/reviewer reports were used only as historical context; none were counted as this run's tests.

    Conclusion

    Blocked for complete feature acceptance pending supported GPU execution. The implemented CPU SQL, protocol and graceful-restart scope above passed on 553e16f52b; this does not claim GPU verification or verification of the latest main tip. The feature is merged. Keep #20567 open pending the remaining acceptance work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/featurepriority/p0

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions