Repository navigation
feat(MachineLearning): convex online-to-batch and SGD in expectation - #4942
SamuelSchlesinger wants to merge 6 commits into
Conversation
Part of #4918 (Part B of the first milestone). - OnlineLearning/ConvexOnlineToBatch: for losses convex on K and dominated by an integrable b, and points w t S in K that do not depend on S t, the expected true risk of the average point is at most the average expected online loss, and with regret R against u at most L_D u + R / T. - LossMinimization/StochasticGradientDescent: sgd (OGD on the sample's losses), measurability and causality, and E L_D(w-bar) <= L_D u + B rho / sqrt T (SSBD Thm 14.8 / Cor 14.12), with only l x0 integrable and K possibly univ. - OnlineGradientDescent: ogd_sum_inner_le_of_const, norm_ogd_sub_le, ogd_regret_le_fixed_of_norm_sub_le; ogd_regret_le_fixed now derived from it. - FirstOrder: convexOn_of_forall_add_le, convexOn_of_forall_add_inner_le, abs_sub_le_of_forall_add_inner_le. - PiUpdate: integral_apply_eval_eq_integral_integral. - Tests: absolute loss on R; manual paragraph in Online convex optimization. AI-assisted: Jetski agent worker sgd for Samuel Schlesinger.
…vexOn_of_integrand_ae
SamuelSchlesinger
left a comment
There was a problem hiding this comment.
Reviewer review-c (Jetski swarm, coordinator session 5f40c2da; non-author agent review, not human review) at 126f565 (top commit only; base #4937): CHANGES REQUESTED
The mathematics is correct and the reuse is good. One blocking item is a small re-proof in the test file. Everything else is non-blocking.
What is proved (checked).
integral_trueRisk_average_le.
- Jensen holds for each sample, through
convexOn_trueRiskandConvexOn.map_sum_le, withw̄ S ∈ KbyConvex.sum_mem. hfreshmakesΦ S z = ℓ (w t S) zinvariant underupdate S t.integral_apply_eval_eq_integral_integralthen gives𝔼 ℓ(w t S, S t) = 𝔼 L_D(w t S)with no conditional expectation.hfreshis exactly what is needed. Depending on later examples is allowed; depending onS tis not. The|w − z|counterexample in the docstring is correct.- Integrability comes from the single dominating
b.
integral_trueRisk_average_le_add.
𝔼 ℓ(u, S t) = L_D ubyintegral_comp_eval.- The regret bound integrates to
L_D u + R/T.
integral_trueRisk_sgd_average_le.
- The iterates stay in
K ∩ closedBall x₀ (ρTc + B), bynorm_ogd_sub_lewitht < T.uis there too. - On that set,
|ℓ w z| ≤ |ℓ x₀ z| + ρ r, byabs_sub_le_of_forall_add_inner_le, sobis integrable fromℓ x₀alone. - Convexity on
K'comes from the subgradient inequality. - The regret is
ρB√T, byogd_regret_le_fixed_of_norm_sub_lewith‖x₀ − u‖² / 2c + cTρ²/2atc = B/(ρ√T). Dividing byTgivesBρ/√T. sgd_updateholds because iteratetonly readsS ifori < t.
Comparison with SSBD. This matches SSBD Thm 14.8 and Cor 14.12 (step √(B²/(ρ²T)), averaged iterate). It generalizes to a projection and to an arbitrary x₀ with ‖x₀ − u‖ ≤ B.
Supporting lemmas.
convexOn_of_forall_add_leis the converse of the tangent-plane inequality.a(x − p) + b(y − p) = 0kills the linear terms.ogd_sum_inner_le_of_consttelescopes with the constant step and no diameter.ogd_regret_le_fixedis now a corollary with its statement unchanged, which removes a duplicated proof.
Tests.
- The iterate
0 − ½·(−1) = ½is concrete. - The four-step bound:
Bρ/√T = 1/2atB = ρ = 1,T = 4. - The hypotheses are discharged for the absolute loss under any
Dwith a first moment, so the test is nonvacuous.
Blocking.
CslibFrontierTests/StochasticGradientDescent.lean:25-26: the privatereal_innerre-proves Mathlib'sReal.inner_apply(Mathlib/Analysis/InnerProductSpace/Basic.lean:1013,inner ℝ x y = x * y). Use it directly. AGENTS.md (Placement and reuse) applies even to private helpers. The same helper exists inCslibFrontierTests/FTRL.lean:29andCslibFrontierTests/OnlineGradientDescent.lean:29on main. Cleaning those up is optional and outside this PR.
Nits (non-blocking).
StochasticGradientDescent.lean:57references "Section 14.5". As far as I recall, Theorem 14.8 is in §14.3 and Corollary 14.12 in §14.5. I have not verified this either; consider "Sections 14.3 and 14.5 (unverified)".- The manual paragraph names SSBD Theorem 14.8 / Corollary 14.12 without the "(locators unverified)" caveat that the docstrings carry. Add it for consistency.
references.bib:CesaBianchiConconiGentile2004duplicates the entry in #4932. Whichever PR lands second needsmainmerged in before queueing (expected; noted for the landing order).ConvexOnlineToBatch.lean:68-95: the three private integrability helpers are reasonable.integrable_trueRisk_comp(a dominated, measurablev) may suitLossMinimization/Basiclater, next tointegrable_empiricalRisk_comp, once a second client needs it.
Reuse and placement.
- This reuses
ogd,ogd_mem,sum_sub_le_sum_innerand the OGD regret machinery, and the risk notions are #4937'strueRisk/convexOn_trueRisk. There is no parallel risk or online-to-batch notion: #4932's Part A is the 0-1/majority-vote setting. - General lemmas are in their topic modules (
Convex/FirstOrder,Integral/PiUpdate,OnlineGradientDescent). I found no Mathlib subgradient-converse or Lipschitz-from-subgradient lemma. - Headers and
-- upstream: candidatemarkers are present. No@[expose]is used, andsgd_defis provided.
Manuals. The new paragraph in "Online convex optimization" is accurate and usable. It covers the hypotheses (hfresh, domination, measurability), the entry points and the in-expectation limitation. No change to the Agent Operator's Manual is needed: library content only.
CI / landing. ci-checks was pending when I posted, and I will read the advisory notices at the fixed head. The PR is stacked on #4937, so after approval it is held until #4937 lands and this branch is retargeted and merged with main.
Review of #4942 by review-c.
|
Fixed in 063ef6e: the test uses Mathlib's |
…to feat/online-to-batch-convex
SamuelSchlesinger
left a comment
There was a problem hiding this comment.
Reviewer review-c (Jetski swarm, coordinator session 5f40c2da; non-author agent review, not human review) at 70fd1c3: APPROVE (held: stacked on #4937)
I reviewed the delta from 126f565, which my earlier review covered.
- 063ef6e resolves the blocking item: the test now uses
Real.inner_apply, and the privatereal_inneris gone. - It also covers both locator nits. The module docstring now says "Sections 14.3 and 14.5 (locators unverified)", and the manual paragraph carries the same caveat.
- Merge 70fd1c3 brings in only #4937's head 2c69c2f. Its
Basic.leanis identical to that head: a proof-only change, and theconvexOn_trueRiskstatement this PR relies on is unchanged. - The remaining nits (the duplicate
CesaBianchiConconiGentile2004bib entry with #4932, andintegrable_trueRisk_comppossibly moving to Basic later) stay non-blocking.
Manuals. The manual change is only the added caveat, which is accurate. No change to the Agent Operator's Manual is needed.
CI. ci-checks passes at this head. The advisory notices are clean: no parallel definitions, no duplicate statements among the 19 theorems examined, and no repeated proof blocks among 48 proofs. The PR-description-names notice flags only CesaBianchiConconiGentile2004, which is a bib key, not a declaration.
Landing. This PR is held until #4937 lands. Then merge main into this branch and retarget it to main. If #4932 lands first, resolve the duplicate bib entry. This approval carries over to the restacked head only if scripts/check_restack.py passes.
…convex # Conflicts: # CslibFrontier.lean
SamuelSchlesinger
left a comment
There was a problem hiding this comment.
Reviewer review-c (Jetski swarm, coordinator session 5f40c2da; non-author agent review, not human review) at 668e875: APPROVE
This head restacks the approved 70fd1c3 onto main now that #4937 has landed. Restack check: identical to the approved change: approved 70fd1c390819 (from 2c69c2f651d5) replayed onto 269ed430f863, new 668e875368b2. The PR has no other reviews and no holds besides #4937, which has landed. It is queued once ci-checks passes at this head.
Convex online-to-batch conversion in expectation and the SGD corollary: Part B of the first milestone of #4918. It uses
trueRiskfrom #4937 (now onmain), andmainhas been merged in.Mathematical results.
OnlineLearning.integral_trueRisk_average_le(newOnlineLearning/ConvexOnlineToBatch.lean). Let the lossesℓ · zbe convex on a convex setKand dominated there by an integrableb. Letw t S ∈ Kbe measurable in the i.i.d. sampleS : Fin T → Zand independent ofS t(hfresh). Then𝔼_S L_D((1/T) ∑ t, w t S) ≤ (1/T) ∑ t, 𝔼_S ℓ (w t S) (S t).integral_trueRisk_average_le_addturns a regret boundRagainstu ∈ KintoL_D u + R/T. As the issue asks, the conditional step goes through the product measure. Sincew tignores coordinatet,MeasureTheory.integral_apply_eval_eq_integral_integralintegrates out the fresh example, with no conditional expectations.integral_trueRisk_sgd_average_le(newLossMinimization/StochasticGradientDescent.lean): the SSBD Thm 14.8 / Cor 14.12 bound𝔼 L_D(w̄) ≤ L_D(u) + Bρ/√Tfor projected SGD (sgd=ogdon the sample's losses). The hypotheses are step sizeB/(ρ√T), subgradients of norm at mostρonKand‖x₀ − u‖ ≤ B. The only integrability assumption is thatℓ x₀isD-integrable.K = univwithproj = id(the source's unconstrained SGD) is covered:norm_ogd_sub_lekeeps the iterates in a ball aroundx₀, where bounded subgradients make the loss Lipschitz.Supporting lemmas (general, placed in their topic modules):
OnlineGradientDescent:ogd_sum_inner_le_of_const,norm_ogd_sub_leandogd_regret_le_fixed_of_norm_sub_le(regretG B √Tfrom‖x₀ − u‖ ≤ B, no diameter bound). The existingogd_regret_le_fixedis now a one-line corollary of the last one. Its statement is unchanged.Convex/FirstOrder:convexOn_of_forall_add_leandconvexOn_of_forall_add_inner_le(the converse of the tangent-plane inequality), andabs_sub_le_of_forall_add_inner_le(bounded subgradients ⇒ Lipschitz onK).Integral/PiUpdate:integral_apply_eval_eq_integral_integral.Limitations.
log T / Trates and running time are the issue's remaining objective and are not done here.bdominating|ℓ w z|onK. The SGD corollary derivesbfromℓ x₀and the Lipschitz bound.references.bibgets the sameCesaBianchiConconiGentile2004entry as feat(MachineLearning): online-to-batch conversion of mistake bounds into PAC learners #4932, at the same position, so it merges cleanly.Tests (
CslibFrontierTests/StochasticGradientDescent.lean): the absolute loss|w − z|onℝ(median estimation). The file checks the subgradient, norm and measurability hypotheses and one concrete iterate. It then instantiates the bound for 4 unconstrained steps with step size1/2:𝔼 L_D(w̄) ≤ L_D(u) + 1/2for everyDwith a first moment and every|u| ≤ 1. The finite-class halving client is in #4932.Manual impact
hfreshand domination hypotheses, the SGD theorem and its limitations.Validation
lake build --wfail --iofailof the new modules, tests and every in-repo importer of the edited modules (FTRL, Multilinear, Mechanism, OGD/FTRL/LossMinimization tests): clean.lake linton the changed library modules,lake exe lint-style,lake exe mk_all --check,scripts/check_hygiene.pyandscripts/check_operator_manual.py: pass.Part of #4918.
AI disclosure: implemented by a Jetski AI agent as worker
sgdunder coordinator session 5f40c2da, for Samuel Schlesinger. Review is by agentreview-c, which is agent review, not human review.