Skip to content
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

Speed up NumberField_generic.zeta() and DirichletGroup() #15486

Closed
elarson314 opened this issue Dec 5, 2013 · 26 comments
Closed

Speed up NumberField_generic.zeta() and DirichletGroup() #15486

elarson314 opened this issue Dec 5, 2013 · 26 comments

Comments

@elarson314
Copy link

The runtime of the Newforms function is unacceptable for large conductors. To fix this, we speed up both the DirichletGroup constructor and the zeta(n) method of number fields by avoiding the computation of the group of all roots of unity or its order.

For a benchmark --- This reduces the runtime of Newforms(719, names='a') to 3--4 sec... from its previous value of over a day (interrupted before completion)!

Depends on #15898
Depends on #15767

Component: modular forms

Keywords: roots of unity dirichlet group

Author: Peter Bruin

Branch/Commit: 0bbfc15

Reviewer: Frédéric Chapoton

Issue created by migration from https://trac.sagemath.org/ticket/15486

@elarson314 elarson314 added this to the sage-6.1 milestone Dec 5, 2013
@elarson314
Copy link
Author

comment:1

Attachment: trac_15486_lazy_R_character.patch.gz

@elarson314 elarson314 changed the title Lazy Evaluation for Modular Forms Lazy Evaluation of R_Characters for Modular Forms Dec 5, 2013
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.1, sage-6.2 Jan 30, 2014
@fchapoton
Copy link
Contributor

comment:3

Here is a git branch


New commits:

dc4df25Rewrote the __R_character variable of the ModularFormsAmbient_R function in modular/modform/ambient_R.py with lazy evaluation.

@fchapoton
Copy link
Contributor

Commit: dc4df25

@fchapoton
Copy link
Contributor

Author: Eric Larson

@fchapoton
Copy link
Contributor

Branch: public/15486

@pjbruin
Copy link
Contributor

pjbruin commented Apr 7, 2014

comment:4

I remember running into this slowness issue as well; most of the time was spent in PARI on something like a class group and unit group computation for the coefficient fields. It's nice that this computation does not always have to be done.

@pjbruin
Copy link
Contributor

pjbruin commented Apr 7, 2014

Reviewer: Peter Bruin

@vbraun
Copy link
Member

vbraun commented Apr 7, 2014

comment:5
sage -t --long src/sage/modular/modform/ambient_eps.py
**********************************************************************
File "src/sage/modular/modform/ambient_eps.py", line 187, in sage.modular.modform.ambient_eps.ModularFormsAmbient_eps.change_ring
Failed example:
    m.change_ring(QQ)
Expected:
    Traceback (most recent call last):
    ...
    ValueError: cannot coerce element of order 6 into self
Got:
    Modular Forms space of dimension 3, character [zeta6] and weight 2 over Rational Field

@pjbruin
Copy link
Contributor

pjbruin commented Apr 7, 2014

comment:6

Hmm, I did create a local branch to doctest this ticket, but it seems I was so convinced that this couldn't break anything that I didn't even check the branch out from Trac. The failing doctest shows that the current patch removes the check for whether there are enough roots of unity.

My comment above was not completely accurate; it was actually PARI's nfinit() that was taking forever. This is called when constructing the Dirichlet group modulo N with values in the group of roots of unity of a number field K. It turns out that by being a bit more careful about which roots of unity one asks for, one can avoid nfinit() and just look for roots of cyclotomic polynomials of degree dividing the degree of K.

I made a new patch for this approach, which is now doctesting. If successful, we can see if it would be a suitable alternative fix.

@pjbruin
Copy link
Contributor

pjbruin commented Apr 7, 2014

comment:7

The new branch makes both the DirichletGroup constructor and the zeta(n) method of number fields more intelligent by avoiding the computation of the group of all roots of unity or its order. Would this be a suitable alternative solution? It is unfortunately completely disjoint from Eric's original solution, but I do not see how that approach can easily detect invalid base rings as in the above doctest failure.

@pjbruin
Copy link
Contributor

pjbruin commented Apr 21, 2014

Changed branch from public/15486 to u/pbruin/15486-roots_of_unity

@pjbruin
Copy link
Contributor

pjbruin commented Apr 21, 2014

Dependencies: #15898

@pjbruin
Copy link
Contributor

pjbruin commented Apr 21, 2014

Changed commit from dc4df25 to f849274

@pjbruin
Copy link
Contributor

pjbruin commented Apr 21, 2014

Changed keywords from none to roots of unity dirichlet group

@pjbruin
Copy link
Contributor

pjbruin commented Apr 21, 2014

Changed author from Eric Larson to Peter Bruin

@pjbruin
Copy link
Contributor

pjbruin commented Apr 21, 2014

Changed reviewer from Peter Bruin to none

@pjbruin pjbruin changed the title Lazy Evaluation of R_Characters for Modular Forms Speed up NumberField_generic.zeta() and DirichletGroup() Apr 21, 2014
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.2, sage-6.3 May 6, 2014
@pjbruin
Copy link
Contributor

pjbruin commented May 9, 2014

comment:10

The patchbot found one doctest failure, which is however completely unrelated to this ticket and is caused by the fact that the patchbot tests this ticket in a temporary directory.

@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.3, sage-6.4 Aug 10, 2014
@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 26, 2014

Changed commit from f849274 to 608c103

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 26, 2014

Branch pushed to git repo; I updated commit sha1. New commits:

37fc8e8Upgrade to PARI-2.7.1
5db54b6Trac 15767: reviewer patch
1d103daTrac 15767: fix doctest in Ser()
62ca821Trac 15767: explain application of Sturm's theorem
bf435f8Merge tag '6.4.beta1' into ticket/15767
608c103Merge branch 'ticket/15767-pari-2.7.1' into ticket/15486-roots_of_unity

@pjbruin
Copy link
Contributor

pjbruin commented Aug 26, 2014

Changed dependencies from #15898 to #15898, #15767

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Dec 4, 2014

Branch pushed to git repo; I updated commit sha1. New commits:

6b4dee6Merge branch 'develop' into ticket/15486-roots_of_unity
0bbfc15Merge branch 'develop' into ticket/15486-roots_of_unity

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Dec 4, 2014

Changed commit from 608c103 to 0bbfc15

@pjbruin

This comment has been minimized.

@fchapoton
Copy link
Contributor

comment:16

As far as I can tell, this looks good. Disclaimer: I am not a number theorist.
All tests pass, the patchbot is happy, the NewForms test takes 3s.
I was worrying about some eventual regressions in timings.
But I have not been able to find any.
Let me put this in positive review.

@fchapoton
Copy link
Contributor

Reviewer: Frédéric Chapoton

@vbraun
Copy link
Member

vbraun commented May 2, 2015

Changed branch from u/pbruin/15486-roots_of_unity to 0bbfc15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants