Repository navigation
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01M96xSez6PZwTmfaGh2eJgS
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01M96xSez6PZwTmfaGh2eJgS
alxmrs
force-pushed
the
m3/regrouped-operands
branch
from
October 31, 2026 12:43
ee8eeff to
a37f74b
Compare
Member
Author
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.
🪭 Claude (einfold)
einfold now finds a
SUMof a product whose factors read three or more joined relations. In a ddx gradient step, these are the softmax-weighted sums over attention's saved scores. ddx is an XQL Systems project for automatic differentiation of SQL queries. On spike S31's steps, at 1,024 tokens:O = softmax(S)·Vfrom the saved scores takes 33 ms with einfold, against DataFusion's 302 ms;dV = Pᵀ·dOtakes 33 ms, against 653 ms.Both run on the dense algorithm. The two take 0.7–0.9 s of einfold's 1.7–2.1 s per attention gradient, and the GPT's
dPand attention output have the same shape.In such a step, the plan joins the saved scores
s, the valuesv, and the saved normalizerz, and sumsexp(s − m) / z.z * v.x. Its first factor readssandz, so no single join in the plan splits the product into two operands, and the detector declined.Decisions to review
Regrouping the joins (
regrouped). Inner joins on equalities can be joined in any order and give the same rows. So where the top join doesn't split the product, the detector:It declines where both factors read one relation, a relation is joined with both sides or neither, a side's relations aren't joined to each other, or a column's name is in two relations. DataFusion still computes each operand, joins and windows included. The node keeps the original plan as its fallback, as every node does. The alternative was a pipeline whose producer is a table read, in the fused kernel. That needs a table producer, masks taken from missing rows, and batch dimensions, which the fused kernel doesn't have. This change is detection alone, and reaches any such product, not only softmaxes.
Float
/and%may be computed on an operand's every row (movable). On floats, DataFusion gives inf or NaN for a division by zero, never an error. It still fails on integers, so an integer/stays above the join, asfallible_factors_stay_above_the_joinchecks. Before this change, a factor such asw / zkept even a two-table product from being found.Operand order. The first factor's relations are the first operand, which matters to the dense algorithm: only its first operand may have missing rows without a domain's default. That suits S31's steps, whose first factor is the masked scores.
How it is tested
detect_vs_hostdraws three-relation products:(l.v / m.v) * r.vwithmjoined tol,l.v * (r.v + m.v)withmjoined tor, and(l.v * m.v) * r.v, wheremis the domain table by another name. Look-alikes must decline:mjoined to bothlandr, or read by both factors. The invariants, over 3,000 cases with NULL and duplicate keys, missing rows, NaN, ±inf and zeros (so that divisions by zero happen):products_over_saved_scores_run_dense, is S31'sOstep: a window over causal scores, a saved normalizer, and values. It checksdense_folds=1, no host plan, and results within 1e-12 of DataFusion's.🤖 Generated with Claude Code
https://claude.ai/code/session_01M96xSez6PZwTmfaGh2eJgS