feat: BF16ThinkingEngine — distance table at source weight precision#125
Merged
Conversation
bf16_engine.rs (8 tests):
BF16 distance table (u16 bit patterns, NOT integers)
bf16_to_f32 lossless (bit shift), sign bit = gate decision
cycle(): F32x16 SIMD with BF16→f32 conversion per lane
cycle_with_temperature(): softmax/T after BF16 accumulation
from_codebook(): build from ClamCodebook pairwise StackedN cosine
from_f32_cosines(), from_f64_cosines(): build from raw cosines
load()/save(): 256×256 × 2 bytes = 128 KB files
Tests verify:
- Real negative values in BF16 table (not CDF rank relabeling)
- Inhibition from negative BF16 entries
- Temperature differentiates (low T = fewer active, high T = more)
- Different inputs produce different peaks
- BF16 roundtrip error < 0.01 (1 ULP)
builder.rs:
TableType::BF16 added
BuiltEngine::BF16(BF16ThinkingEngine) with all match arms
Temporary u8→BF16 conversion path until BF16 lenses are baked
252 tests pass (+8 new).
https://claude.ai/code/session_019RzHP8tpJu55ESTxhfUy1A
AdaWorldAPI
pushed a commit
that referenced
this pull request
Apr 17, 2026
…eam #150 ## Stale artifact removal (182 files, 3 MB) `AdaWorldAPI-lance-graph-d9df43b/` was a committed snapshot of an older upstream version (48 .rs files vs our 98). Full audit confirmed: - ZERO files exist only in the artifact (every file has a counterpart) - Every differing file: ours >= artifact in LOC (ours is strictly ahead) - All upstream features (#125 parameter_substitution, #140 lance_vector_search) are already in our src tree The directory created GitHub path confusion — duplicate navigation paths for datafusion_planner, spo, blasgraph, neighborhood, arigraph. Removing it eliminates that confusion with zero content loss. ## Cherry-pick: spark_dialect.rs from upstream PR #150 The ONE file upstream has that we didn't: - `crates/lance-graph/src/spark_dialect.rs` (107 LOC) Spark SQL dialect for DataFusion unparser: backtick quoting, STRING type casting, EXTRACT for dates, BIGINT/INT types, LENGTH(), derived table aliases. - `crates/lance-graph/tests/test_to_spark_sql.rs` (293 LOC) Full test suite for Spark SQL output. - `pub mod spark_dialect;` added to lib.rs Adapted from upstream's DF 50.3 to our DF 51 — same API surface, no changes needed. ## Upstream audit result (for the record) Upstream (lance-format/lance-graph) is at v0.5.4. Our fork is at v0.5.3 with newer deps (arrow 57 vs 56.2, datafusion 51 vs 50.3). Other than spark_dialect, every upstream feature and fix is already present in our source tree — parameter_substitution (#125), lance_vector_search (#140), complex RETURN clauses (#142), duplicate columns fix (#128) are all in `crates/lance-graph/src/`. Their deleted `simple_executor` was a prototype cold-path executor we never had. Our `ExecutionStrategy::DataFusion` path (6K LOC planner) + `ExecutionStrategy::BlasGraph` (semiring algebra) subsume it. The user has flagged adding a deliberate `ExecutionStrategy::Simple` cold path as a 4th strategy for trivial queries — that's a separate PR per the documented matrix of execution strategies. https://claude.ai/code/session_01NYGrxVopyszZYgLBxe4hgj
4 tasks
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.
bf16_engine.rs (8 tests):
BF16 distance table (u16 bit patterns, NOT integers)
bf16_to_f32 lossless (bit shift), sign bit = gate decision
cycle(): F32x16 SIMD with BF16→f32 conversion per lane
cycle_with_temperature(): softmax/T after BF16 accumulation
from_codebook(): build from ClamCodebook pairwise StackedN cosine
from_f32_cosines(), from_f64_cosines(): build from raw cosines
load()/save(): 256×256 × 2 bytes = 128 KB files
Tests verify:
- Real negative values in BF16 table (not CDF rank relabeling)
- Inhibition from negative BF16 entries
- Temperature differentiates (low T = fewer active, high T = more)
- Different inputs produce different peaks
- BF16 roundtrip error < 0.01 (1 ULP)
builder.rs:
TableType::BF16 added
BuiltEngine::BF16(BF16ThinkingEngine) with all match arms
Temporary u8→BF16 conversion path until BF16 lenses are baked
252 tests pass (+8 new).
https://claude.ai/code/session_019RzHP8tpJu55ESTxhfUy1A