Repository navigation
fix(xreg): handle empty dimensions in padded JAX arrays - #478
Bitshank-2338 wants to merge 2 commits into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
rajpratham1
left a comment
There was a problem hiding this comment.
Looks good to me. The change correctly handles zero-sized dimensions without affecting the existing padding behavior for non-empty arrays. The added regression tests cover both empty-dimension cases and the existing padding behavior, so this looks safe to merge.
sylvesterkaczmarek
left a comment
There was a problem hiding this comment.
Now that zero-column design matrices are supported, max_rows_per_col exposes another edge case here. When x_train.shape[1] == 0, w = ncols * max_rows_per_col becomes 0, so any positive max_rows_per_col selects an empty row set and also truncates flat_targets to length 0. The fitted predictions remain zero because there are no predictors, but debug_info=True no longer returns the documented flattened target vector. Could the subsampling branch be skipped when ncols == 0, with a regression combining the single-category/no-intercept case, max_rows_per_col > 0, and debug_info=True?
|
Thanks @sylvesterkaczmarek, I reproduced this with the single-category/no-intercept case and Your diagnosis is correct: |
sylvesterkaczmarek
left a comment
There was a problem hiding this comment.
Rechecked current head 276ded8. This resolves the zero-column subsampling case I raised: subsampling is now skipped when there are no predictor columns in both implementations, and the regression covers positive max_rows_per_col values while confirming the padded targets are preserved and predictions remain zero. No remaining blocker from my review.
rajpratham1
left a comment
There was a problem hiding this comment.
The empty-dimension handling is correctly addressed in both XReg implementations, including safe padding for zero-sized dimensions and avoiding subsampling when there are zero predictor columns. The added regression tests cover empty shapes, normal padding, single-category fitting, and zero-predictor subsampling behavior. I don't see a blocking issue in this PR.
rajpratham1
left a comment
There was a problem hiding this comment.
The empty-dimension handling looks correct and is consistently applied to both src/ and v1/src/. The new tests cover zero-sized dimensions, existing non-empty padding behavior, and the zero-predictor subsampling case. I don't see any blocking issues in this PR.
rajpratham1
left a comment
There was a problem hiding this comment.
The empty-dimension handling is implemented consistently in both src and v1, and the added tests cover the affected zero-sized dimensions, normal padding behavior, and the zero-predictor subsampling path. I don't see any blocking issues in this PR.
|
Hi @rajatsen91, could you take a look at this fix for #197 when you have a chance? The follow-up in 276ded8 addresses the zero-column subsampling issue raised during review in both XReg implementations. The regression tests cover positive I'd appreciate a maintainer review and consideration for merge. Please let me know if any further changes are needed. Thank you! |
Summary
Root cause
_to_padded_jax_arraycalledmath.log2(0)for arrays with an empty dimension. A valid way to reach this state is a single-category feature encoded withdrop="first"while the intercept is disabled, which produces an(n, 0)design matrix.The padding helper now treats a zero-length dimension as requiring zero padding while continuing to power-of-two pad every non-empty dimension.
Testing
PYTHONPATH=src python -m pytest tests -q— 68 passedPYTHONPATH=src python -m pytest tests/test_xreg_lib.py -q— 5 passedpython -m ruff check tests/test_xreg_lib.pygit diff --checkFixes #197