-
-
Notifications
You must be signed in to change notification settings - Fork 543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Misleading maximum n
value in docstring of matrix_modn_dense_float.pyx
#35365
Comments
Any new insight from the experiments? Having a reduced performance is expected when approaching the maximum acceptable modulus value for the used techniques to be applicable. This would not happen for the The documentation should be improved indeed. Would you have an explicit code fragment which raises an issue (overflow error)? |
Here are some preliminary experiments I ran. I'll run some more experiments with other functions soon.
There's a big spike after |
Although it is indeed the expected threshold phenomenon that occurs, these cases are over non-prime fields and so are in fact not relevant for Doing similar experiments but with prime fields (and taking the random generation out of the timings):
So we do see the expected behaviour change when going from 8-bit modulus to 9-bit and more. But pushing a bit further...
Timings are the same up to 20-bit moduli (and about the same up to 23, in fact), for a good reason:
as soon as we exceed 8 bits, we switch to the This is why I was asking about any actual detected issue related to |
Ah okay. So in essence In this particular case, the documentation should mention that because LinBox runs really slow on values greater than 2**8 despite supporting upto Also, since matrices can be over any arbitrary ring and |
Yes, exactly. Beyond 23 bits, SageMath switches to "generic dense matrix".
The documentation is really about SageMath, not about details of the underlying libraries, so I don't think that the fact that LinBox can support primes that are more than 23 bits (but this is not offered through SageMath) is relevant information in SageMath's doc. However it is something that could be raised among developers: is this 23-bit limit still justified today? (I assume it was at the time this choice was made)
Yes, the documentation should be clearer on this point. I would suggest to make it simple, saying that the switch from float to double variant is chosen for performance reasons (in other words I would avoid negative statements like "runs really slow", since there are very good reasons behind the fact that the float variant is slower for e.g. 10 bit primes, and this phenomenon is general, it has nothing to do with LinBox in particular).
Oh, I see my previous comment was probably misleading on this point; it focused on prime fields because this was in response to your experiments which were over a field. The current documentation is correct and non-prime integer moduli |
<!-- Please provide a concise, informative and self-explanatory title. --> <!-- Don't put issue numbers in the title. Put it in the Description below. --> <!-- For example, instead of "Fixes #12345", use "Add a new method to multiply two integers" --> ### 📚 Description <!-- Describe your changes here in detail. --> Improves the documentation to give more precisions on the upper limit MAX_MODULUS of `matrix_modn_dense_float.pyx` for performances sake. <!-- Why is this change required? What problem does it solve? --> <!-- If this PR resolves an open issue, please link to it here. For example "Fixes #12345". --> Fixes #35365 <!-- If your change requires a documentation PR, please link it appropriately. --> ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. It should be `[x]` not `[x ]`. --> - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [x] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - #12345: short description why this is a dependency - #34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: #35752 Reported by: Marie Bonboire Reviewer(s): Vincent Neiger
In
matrix_modn_dense_float.pyx
,MAX_MODULUS
is set as2**8
in line 41, andMAX_MODULUS
is used to create aMatrix_modn_dense_template
object. An overflow error is raised ifn >= MAX_MODULUS
. However, the docstring states thatn
values upto2**11
are supported. The documentation should clearly mention that because LinBox runs really low on values greater than2**8
, it is set as a hard limit.Interestingly, this is only the case for
matrix_modn_dense_float.pyx
and notmatrix_modn_dense_double.pyx
. In thedouble
variant,MAX_MODULUS = 2**23
and is consistent with the docstring and LinBox's upper limit. Is thedouble
variant not slow? Does LinBox only bottleneck on thefloat
variant? I'll do some experiments tomorrow and try to figure this out, but if somebody else has worked with this, do tell.The text was updated successfully, but these errors were encountered: