Skip to content

[bug] contributor basis() snippets omit frac again after the 9058d49..f35482a rollback — and strategy/README's "Register your own" hook never declared it at all #274

Description

@luciferlive112116

Summary

multiply_subspace forwards the VRAM budget only to a basis() that declares
frac
:

# Pass frac only if the transform accepts it, so custom transforms with the
# older basis(...) signature keep working.
if "frac" in inspect.signature(transform.basis).parameters:
    Q = transform.basis(n, m, backend, cdt, A=A, B=B, frac=frac)
else:
    Q = transform.basis(n, m, backend, cdt, A=A, B=B)

That else is a compatibility shim for legacy transforms. Any snippet a
contributor copies that omits frac therefore produces a transform which lands in
the legacy branch and silently streams its basis at _DEFAULT_ROW_BLOCK_FRACTION
(0.3) instead of Config.vram_fraction — the bug #211 fixed for rsvd,
re-introduced once per contribution.

Three copies a contributor actually reads are currently on the pre-#211 signature:

copy state
CONTRIBUTING.md:73 — "What you actually change" ❌ no frac
strategy/README.md:54 — "Register your own (the updatable hook)" ❌ no fracnever covered
strategy/examples/run_example.py:45FirstAxes ❌ no frac

while the authoritative surfaces all declare it: Transform.basis,
transforms.py's module-docstring template, RandomizedSVDTransform.basis
(#211), and examples/transform_template.py (#251, still on main).

Why they regressed

Two of the three were fixed by #253, but that PR was rolled back with the entire
9058d49..f35482a merge window — 1dc8fce..e42c525 reverted all seven PRs of
that batch, LIFO, across five authors (#235, #232, #253, #266, #267, #268, #255).
The rollback restored the stale snippets.

strategy/README.md's hook was never covered by #253 — it is a genuinely
uncovered third copy, and the most likely one to be copied, since it sits directly
under "The transform is the pluggable core tech".

Fix

Declare frac=None in all three and say what it's for (FirstAxes is a fixed
basis that streams nothing, so it notes the parameter is unused but must stay for
the signature-based forwarding gate), plus a CPU test that regex-checks both
markdown snippets and AST-parses the example (run_example.py runs a real
subspace_matmul at module scope, so it can't be imported without a GPU). None of
these paths are protected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:strategySmart strategies / transforms (strategy/)status:triageNewly opened, not yet triagedtype:bugSomething is incorrect or brokentype:docsDocumentation-only changetype:strategyNew smart strategy / transform proposal

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions