Skip to content

Migrate fully to JetSpace backend (remove legacy TaylorN lookup tables)#414

Merged
lbenet merged 15 commits into
JuliaDiff:masterfrom
PerezHz:jetspace-only-backend
May 27, 2026
Merged

Migrate fully to JetSpace backend (remove legacy TaylorN lookup tables)#414
lbenet merged 15 commits into
JuliaDiff:masterfrom
PerezHz:jetspace-only-backend

Conversation

@PerezHz
Copy link
Copy Markdown
Contributor

@PerezHz PerezHz commented May 26, 2026

After #410 introduced JetSpace, v0.21.10 was released as a compatibility release. Here, we migrate fully to the JetSpace backend, removing the legacy lookup tables. The intention is for this PR to become the next minor release (0.22).

@coveralls
Copy link
Copy Markdown

coveralls commented May 26, 2026

Coverage Status

coverage: 90.374% (-0.02%) from 90.398% — PerezHz:jetspace-only-backend into JuliaDiff:master

@PerezHz PerezHz changed the title Migrte fully to JetSpace backend (remove legacy TaylorN lookup tables) Migrate fully to JetSpace backend (remove legacy TaylorN lookup tables) May 26, 2026
@PerezHz PerezHz marked this pull request as ready for review May 26, 2026 03:30
@PerezHz
Copy link
Copy Markdown
Contributor Author

PerezHz commented May 26, 2026

I think I found a way to make the product tables include less entries by removing those which are never used (thanks to @lbenet who noticed many entries remained empty in space.mul_table even after loading). This change is completely internal to JetSpace and should be transparent to all users (except maybe too eager users which might be already using JetSpace internals explicitly from v0.21.10, but this release is breaking anyway). So in short what we have now is:

julia> using TaylorSeries

julia> space = JetSpace(order=4, variables=[:x, :y])
JetSpace
    Expansion order:        4
    Number of variables:    2
    Variable names:         ["x", "y"]
    Variable symbols:       [:x, :y]

julia> x, y = variables(space)
2-element Vector{TaylorN{Float64}}:
  1.0 x + 𝒪(‖x‖⁵)
  1.0 y + 𝒪(‖x‖⁵)

julia> space.mul_table # empty because of lazy loading
4-element Vector{Vector{TaylorSeries.HomogeneousProductTable}}:
 [TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0), TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0), TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0), TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0)]
 [TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0), TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0), TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0), TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0)]
 [TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0), TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0), TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0), TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0)]
 [TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0), TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0), TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0), TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0)]

julia> exp(1+x)*exp(1-y)
 7.3890560989306495 + 7.3890560989306495 x - 7.3890560989306495 y + 3.6945280494653248 x² - 7.3890560989306495 x y + 3.6945280494653248 y² + 1.2315093498217748 x³ - 3.6945280494653248 x² y + 3.6945280494653248 x y² - 1.2315093498217748 y³ + 0.3078773374554437 x⁴ - 1.2315093498217748 x³ y + 1.8472640247326624 x² y² - 1.2315093498217748 x y³ + 0.3078773374554437 y⁴ + 𝒪(‖x‖⁵)

julia> space.mul_table # many entries filled, but also many others empty
4-element Vector{Vector{TaylorSeries.HomogeneousProductTable}}:
 [TaylorSeries.HomogeneousProductTable([1, 2, 2, 3], [1, 2, 4, 5], UInt32[0x00000001, 0x00000002, 0x00000003, 0x00000004], 2), TaylorSeries.HomogeneousProductTable([1, 2, 3, 2, 3, 4], [1, 2, 4, 6, 7], UInt32[0x00000001, 0x00000002, 0x00000004, 0x00000003, 0x00000005, 0x00000006], 3), TaylorSeries.HomogeneousProductTable([1, 2, 3, 4, 2, 3, 4, 5], [1, 2, 4, 6, 8, 9], UInt32[0x00000001, 0x00000002, 0x00000005, 0x00000003, 0x00000006, 0x00000004, 0x00000007, 0x00000008], 4), TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0)]
 [TaylorSeries.HomogeneousProductTable([1, 2, 2, 3, 3, 4], [1, 2, 4, 6, 7], UInt32[0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006], 2), TaylorSeries.HomogeneousProductTable([1, 2, 3, 2, 3, 4, 3, 4, 5], [1, 2, 4, 7, 9, 10], UInt32[0x00000001, 0x00000002, 0x00000004, 0x00000003, 0x00000005, 0x00000007, 0x00000006, 0x00000008, 0x00000009], 3), TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0), TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0)]
 [TaylorSeries.HomogeneousProductTable([1, 2, 2, 3, 3, 4, 4, 5], [1, 2, 4, 6, 8, 9], UInt32[0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008], 2), TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0), TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0), TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0)]
 [TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0), TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0), TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0), TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0)]

In this case, space.mul_table[4] is empty because it corresponds to product combinations that exceed the truncation order. For lower orders in the table, there are other empty entries which essentially correspond to degree_a + degree_b > space.order, where degree_a and degree_b are the order of the homogeneous polynomials being multiplied.

So with the changes in commit d170995 this changes to:

julia> using TaylorSeries

julia> space = JetSpace(order=4, variables=[:x, :y])
JetSpace
    Expansion order:        4
    Number of variables:    2
    Variable names:         ["x", "y"]
    Variable symbols:       [:x, :y]

julia> space.mul_table # empty because of lazy loading
3-element Vector{Vector{TaylorSeries.HomogeneousProductTable}}:
 [TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0), TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0), TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0)]
 [TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0), TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0)]
 [TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0)]

julia> x, y = variables(space)
2-element Vector{TaylorN{Float64}}:
  1.0 x + 𝒪(‖x‖⁵)
  1.0 y + 𝒪(‖x‖⁵)

julia> exp(1+x)*exp(1-y)
 7.3890560989306495 + 7.3890560989306495 x - 7.3890560989306495 y + 3.6945280494653248 x² - 7.3890560989306495 x y + 3.6945280494653248 y² + 1.2315093498217748 x³ - 3.6945280494653248 x² y + 3.6945280494653248 x y² - 1.2315093498217748 y³ + 0.3078773374554437 x⁴ - 1.2315093498217748 x³ y + 1.8472640247326624 x² y² - 1.2315093498217748 x y³ + 0.3078773374554437 y⁴ + 𝒪(‖x‖⁵)

julia> space.mul_table # less entries, and all of them are now filled
3-element Vector{Vector{TaylorSeries.HomogeneousProductTable}}:
 [TaylorSeries.HomogeneousProductTable([1, 2, 2, 3], [1, 2, 4, 5], UInt32[0x00000001, 0x00000002, 0x00000003, 0x00000004], 2), TaylorSeries.HomogeneousProductTable([1, 2, 3, 2, 3, 4], [1, 2, 4, 6, 7], UInt32[0x00000001, 0x00000002, 0x00000004, 0x00000003, 0x00000005, 0x00000006], 3), TaylorSeries.HomogeneousProductTable([1, 2, 3, 4, 2, 3, 4, 5], [1, 2, 4, 6, 8, 9], UInt32[0x00000001, 0x00000002, 0x00000005, 0x00000003, 0x00000006, 0x00000004, 0x00000007, 0x00000008], 4)]
 [TaylorSeries.HomogeneousProductTable([1, 2, 2, 3, 3, 4], [1, 2, 4, 6, 7], UInt32[0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006], 2), TaylorSeries.HomogeneousProductTable([1, 2, 3, 2, 3, 4, 3, 4, 5], [1, 2, 4, 7, 9, 10], UInt32[0x00000001, 0x00000002, 0x00000004, 0x00000003, 0x00000005, 0x00000007, 0x00000006, 0x00000008, 0x00000009], 3)]
 [TaylorSeries.HomogeneousProductTable([1, 2, 2, 3, 3, 4, 4, 5], [1, 2, 4, 6, 8, 9], UInt32[0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008], 2)]

This should not have a great impact on performance, but does allow for better bookkeeping.

@PerezHz
Copy link
Copy Markdown
Contributor Author

PerezHz commented May 26, 2026

@lbenet this is now ready for you to have a look

Copy link
Copy Markdown
Member

@lbenet lbenet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @PerezHz for cleaning up the code so we can get rid of the old (global constant) hash tables. In general, everythings LGTM, and the simplification of mul_table are really welcome. Yet, I've left some comments and suggestions. I think the important ones are:

  • treat TS.default_space[] as a const or force it to be ::JetSpace, so its type cannot be changed;
  • emit a warning if the TS.default_space[] is reset.

Comment thread src/hash_tables.jl Outdated
Comment thread src/hash_tables.jl
Comment thread src/hash_tables.jl Outdated
Comment thread src/parameters.jl
Comment thread README.md Outdated
Comment thread README.md Outdated
@lbenet
Copy link
Copy Markdown
Member

lbenet commented May 26, 2026

Closes #218, closes #246

@PerezHz
Copy link
Copy Markdown
Contributor Author

PerezHz commented May 27, 2026

@lbenet thank you for your comments and suggestions; I think I have addressed them. So this is again ready for review

Copy link
Copy Markdown
Member

@lbenet lbenet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot @PerezHz! Merging, to release the new version!

@lbenet lbenet merged commit 4b5c3a7 into JuliaDiff:master May 27, 2026
13 checks passed
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.

3 participants