You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add float16 (half-precision) vector support (#117)
* Add float16 (half-precision) vector support
This commit adds comprehensive support for float16 (F16) vectors to both
MySQL and HTTP clients in the SingleStoreDB Python SDK.
Changes:
- Add FLOAT16 = 7 as the 7th vector type constant
- Add FIELD_TYPE constants: FLOAT16_VECTOR_JSON (2007) and FLOAT16_VECTOR (3007)
- Update protocol parser to recognize and handle FLOAT16 vector metadata
- Add float16_vector_json_or_none() and float16_vector_or_none() converters
- Register float16 converters in the converters dictionary (types 2007 and 3007)
- Add FLOAT16 vector types to TEXT_TYPES set for proper type handling
- Update C accelerator with full float16 support:
- Add FLOAT16 constants and PyStrings struct member
- Update type arrays with 'e' format (2 bytes) for struct.unpack
- Add float16 to JSON and binary vector case statements
- Initialize numpy dtype kwargs for float16
- Add comprehensive tests:
- Create f16_vectors test table with 3 test rows
- Implement test_f16_vectors() method following existing patterns
- Use assert_array_almost_equal with decimal=2 for float16 precision
Technical notes:
- Float16 has ~3 decimal digits of precision (vs ~7 for float32)
- Uses struct format 'e' for half-precision (2 bytes per element)
- Supports both JSON and binary wire formats
- All pre-commit hooks passed (flake8, autopep8, mypy)
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
* Add float16 (half-precision) support to UDF system
Extends the UDF framework to handle float16/half-precision types:
- Add F16 vector type constant and export
- Map float16 to FLOAT SQL type in signatures
- Add Float16Array/HalfArray type aliases
- Implement F16 numpy and struct format conversions
- Add comprehensive float16 UDF tests
This complements protocol-level float16 vector support (5377083).
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
* Add server version checks and conditional loading for float16 tests
This commit implements a generalized version-based SQL loading system
for tests and adds server version checks for float16 vector tests.
Changes:
- Add server version check to test_f16_vectors() that skips the test
if server version < 9.1 with a descriptive message
- Create test_9_1.sql containing float16 vector test data
- Implement generalized version-specific SQL file loading in utils.py:
- get_server_version(): Extract server version as (major, minor) tuple
- find_version_specific_sql_files(): Discover test_X_Y.sql files
- load_version_specific_sql(): Conditionally load SQL based on version
- Update load_sql() to automatically load version-specific SQL files
- Remove f16_vectors table from test.sql (now in test_9_1.sql)
The new system automatically discovers and loads SQL files matching the
pattern test_X_Y.sql where X is major version and Y is minor version.
Files are loaded only if the server version >= the file version.
This makes it easy to add version-specific test data in the future
(e.g., test_9_2.sql, test_10_0.sql) without modifying Python code.
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
---------
Co-authored-by: Claude Sonnet 4.5 <[email protected]>
0 commit comments