Skip to content

Speed up AddToIgs and AddToIgsParallel - #174

Draft
fingolfin wants to merge 3 commits into
masterfrom
mh-claude/addtoigs-speedup
Draft

fingolfin wants to merge 3 commits into
masterfrom
mh-claude/addtoigs-speedup

Conversation

@fingolfin

Copy link
Copy Markdown
Member

Most of the time went into commutators that were computed only to be discarded because they already lay in the tail of the igs: for UT(20,5) with 1000 random elements, 15,000 of 16,000. A table of lower bounds for commutator depths, derived from the presentation once per collector and cached in it, lets the loop skip those without computing them.

The generators are now taken one at a time, each closed under powers and commutators before the next is sifted, so the tail limit drops as early as possible. In groups with infinite relative orders a generator is reduced only just before it is sifted instead of every time the igs changes; with many generators that reduction dominated the running time. Inverse powers of igs entries are cached during sifting.

UT(20,5), 1000 elements: 24 s -> 7 s. UT(25,5): 260 s -> 43 s. UT(30,5): more than 30 min -> 5.4 min. UT(6,Z), 1000 elements: 0.8 s -> 0.02 s. In infinite groups with few generators the running time depends on processing order either way; over 48 seeds in UT(6,Z) with 10 elements the new order is faster on 31 and slower on 10.

Assisted-by: Claude Code (Opus 5.5, Fable 5.1)


Vibe coded, I have not yet reviewed it myself, though the numbers sound impressive.

@codecov

codecov Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.83%. Comparing base (7e84dbe) to head (6fe05f3).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #174      +/-   ##
==========================================
+ Coverage   71.51%   71.83%   +0.31%     
==========================================
  Files          88       88              
  Lines       13029    13175     +146     
==========================================
+ Hits         9318     9464     +146     
  Misses       3711     3711              
Files with missing lines Coverage Δ
gap/basic/collect.gd 100.00% <100.00%> (ø)
gap/basic/collect.gi 88.19% <100.00%> (+0.03%) ⬆️
gap/basic/pcppara.gi 94.52% <100.00%> (+1.19%) ⬆️
gap/basic/pcppcps.gi 86.36% <100.00%> (+2.17%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

stertooy and others added 3 commits October 22, 2026 13:27
Most of the time went into commutators that were computed only to be
discarded because they already lay in the tail of the igs: for UT(20,5)
with 1000 random elements, about 15,000 of 16,000. A table of lower
bounds for commutator depths, derived from the presentation once per
collector and cached in it, lets the loop skip those without computing
them.

The generators are now taken one at a time, each closed under powers
and commutators before the next is sifted, so the tail limit drops as
early as possible. In groups with infinite relative orders a generator
is reduced only just before it is sifted instead of every time the igs
changes; with many generators that reduction dominated the running
time. In infinite groups with few generators the running time depends
strongly on processing order, and the new order is slower on some
inputs.

Setup:

    gap> ut := function(n, p, k) local G; G := UnitriangularPcpGroup(n, p); Reset(GlobalMersenneTwister, 1); return List([1..k], i -> Random(G)); end;;
    gap> dt := function(n, k) local G; G := UnitriangularPcpGroup(n, 0); AddHallPolynomials(Collector(G)); Reset(GlobalMersenneTwister, 1); return List([1..k], i -> Random(G)); end;;
    gap> sift := function(gens) local t; t := Runtime(); AddToIgs([], gens); return Runtime() - t; end;;

Before:

    gap> sift(ut(20, 5, 30));
    19245
    gap> sift(ut(20, 5, 1000));
    18643
    gap> sift(ut(25, 5, 1000));
    163026
    gap> sift(ut(6, 0, 1000));
    200
    gap> sift(dt(10, 1000));
    13987

After:

    gap> sift(ut(20, 5, 30));
    4424
    gap> sift(ut(20, 5, 1000));
    7095
    gap> sift(ut(25, 5, 1000));
    42009
    gap> sift(ut(6, 0, 1000));
    7
    gap> sift(dt(10, 1000));
    410

Assisted-by: Generative AI
@fingolfin
fingolfin force-pushed the mh-claude/addtoigs-speedup branch from f930200 to 6fe05f3 Compare October 22, 2026 23:23

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants