Skip to content

Commit 15c4e52

Browse files
authored
Merge pull request #33 from TensorKitchen/lm-workload
Reduce precompile workload
2 parents 1ec3450 + 0a3a8fd commit 15c4e52

1 file changed

Lines changed: 9 additions & 68 deletions

File tree

src/precompile.jl

Lines changed: 9 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,16 @@ if Base.VERSION >= v"1.9"
55
rng = MersenneTwister(7)
66
A = randn(rng, 4, 3, 2)
77
B = abs.(A)
8-
A_med = randn(rng, 6, 5, 4)
98

109
model = JoinModel(A, 2; geometry = :canonical)
1110
p0 = _solver_point(manifold(model), initial_point(model, :random; verbose = false))
12-
model_med = JoinModel(A_med, 2; geometry = :canonical)
13-
p0_med = _solver_point(
14-
manifold(model_med),
15-
initial_point(model_med, :random; verbose = false),
16-
)
1711

18-
nn_model = JoinModel(B, 2; nonnegative = true, geometry = :softplus_metric)
19-
p0_nn = _solver_point(
20-
manifold(nn_model),
21-
initial_point(nn_model, :random; verbose = false),
22-
)
23-
24-
# The first LM call is dominated by JIT compilation in the operator-action
25-
# path. Precompiling a minimal canonical and softplus NNCP workload moves
26-
# that cost to package precompile time instead of first user execution.
12+
# Keep this workload intentionally small: we want to cover the operator LM
13+
# path and the public CP/NNCP frontends without forcing every user to pay
14+
# a very large package precompile cost up front.
2715
@compile_workload begin
28-
# Direct LM solve path on an already-prepared canonical CP model.
16+
# Direct LM solve on a canonical CP model covers the core operator
17+
# least-squares path without routing through the public frontend.
2918
solve(
3019
LMSolver(),
3120
model;
@@ -36,38 +25,8 @@ if Base.VERSION >= v"1.9"
3625
verbose = false,
3726
return_stats = true,
3827
)
39-
solve(
40-
LMSolver(),
41-
model_med;
42-
init = :random,
43-
p0 = p0_med,
44-
maxiter = 1,
45-
tol = 1e-6,
46-
verbose = false,
47-
return_stats = true,
48-
)
49-
cpd(
50-
A,
51-
2;
52-
solver = :lm,
53-
init = :random,
54-
p0 = p0,
55-
maxiter = 1,
56-
tol = 1e-6,
57-
verbose = false,
58-
)
59-
cpd(
60-
A_med,
61-
2;
62-
solver = :lm,
63-
init = :random,
64-
p0 = p0_med,
65-
maxiter = 1,
66-
tol = 1e-6,
67-
verbose = false,
68-
)
69-
# Frontend LM route with ALS warm start, which is the path users hit
70-
# most often when they request cpd(...; solver=:lm).
28+
29+
# Warm-started CPD is the most common public LM entry point.
7130
cpd(
7231
A,
7332
2;
@@ -78,26 +37,8 @@ if Base.VERSION >= v"1.9"
7837
tol = 1e-6,
7938
verbose = false,
8039
)
81-
cpd(
82-
A_med,
83-
2;
84-
solver = :lm,
85-
init = :alswarm,
86-
warm_steps = 2,
87-
maxiter = 1,
88-
tol = 1e-6,
89-
verbose = false,
90-
)
91-
nncpd(
92-
B,
93-
2;
94-
solver = :lm,
95-
init = :random,
96-
p0 = p0_nn,
97-
maxiter = 1,
98-
tol = 1e-6,
99-
verbose = false,
100-
)
40+
41+
# Nonnegative LM still goes through a distinct parameterization path.
10142
nncpd(
10243
B,
10344
2;

0 commit comments

Comments
 (0)