Audit and fix dimension label checking and inference (#255)#451
Closed
lukstafi wants to merge 2 commits intoahrefs:masterfrom
Closed
Audit and fix dimension label checking and inference (#255)#451lukstafi wants to merge 2 commits intoahrefs:masterfrom
lukstafi wants to merge 2 commits intoahrefs:masterfrom
Conversation
ea03bfc to
f9438f8
Compare
- Fix variable-mediated label loss: when unify_dim sees Dim{label=None}
vs Dim{label=Some l} with equal sizes, upgrade the variable that
resolved to the unlabeled dim so the label persists in future checks
- Add label guard to unify_dim and dim_comparison_for_axis fast paths
- Add concat label consistency check in s_dim_one (conflicting labels raise)
- Add affine/convolution label conflict check in s_dim_one
- Propagate labels through stride/convolution arithmetic (4 branches)
- Document intentional LUB broadcast semantics for conflicting labels
- Add 18 focused test cases (8 DSL integration + 10 direct Row construction)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Address reviewer feedback: tests that claim label preservation or propagation now explicitly verify the label string (via row_to_labels or Shape.to_labels), not just absence of exceptions. Key changes: - Add get_var_label helper using Row.row_to_labels to inspect labels - Add test 5b: verifies variable label upgrade in the environment - Tests 1, 3: verify label visible in result shape via Shape.to_labels - Tests 9, 11: restructure concat tests to use variable components (triggers s_dim_one collapse), verify label="x" and d=5 - Tests 12, 14-17: verify label="x" on solved dims after affine/stride arithmetic, not just absence of errors - Test 18: assert definite Shape_error for mutual inequality with conflicting labels, instead of accepting either outcome Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
f9438f8 to
8b9140b
Compare
Collaborator
Author
|
@codex review Focus on bugs, correctness issues, and edge cases. Do not check adherence to a spec or plan. |
3 tasks
Collaborator
Author
|
Closing: this PR was filed against the wrong repo due to a gh-resolved bug (see lukstafi/ludics#302). Ported to lukstafi#7. |
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.
Summary
unify_dim: when a dim variable solved to an unlabeled dim is later unified with a labeled dim of the same size, the variable's stored value is upgraded to carry the label, so future conflicting labels are caughtunify_dimanddim_comparison_for_axisfast paths (defense-in-depth)Shape_errorunify_dim)Test plan
dune build @checkpassesOCANNL_BACKEND=sync_cc dune exec test/einsum/test_dimension_labels.exe— all 19 tests passOCANNL_BACKEND=sync_cc dune runtest— no new failures beyond pre-existing baselineCloses #255
🤖 Generated with Claude Code