⚡ Bolt: Vectorize MMLE M-step Newton-Raphson loops for 50%+ speedup - #162
⚡ Bolt: Vectorize MMLE M-step Newton-Raphson loops for 50%+ speedup#162seonghobae wants to merge 9 commits into
Conversation
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
Pull request overview
OpenCode cannot approve yet because required coverage evidence did not pass.
Review outcome
1. HIGH .github/workflows/opencode-review.yml:1 - Coverage evidence did not prove required test/docstring evidence
-
Problem: The required coverage-evidence job result was
failure, so OpenCode cannot establish approval sufficiency for this head. -
Root cause: Automated approval is only valid when the same-head coverage-evidence job proves supported repository test suites passed and configured docstring gates passed or were advisory, or reports not applicable because no supported source files or package manifests exist. Missing, failed, skipped, unavailable, or unsupported-tooling test evidence is a blocker.
-
Fix: Install or configure the repository test/docstring evidence tooling when source files or package manifests exist, rerun the current-head coverage-evidence job, and approve only after it reports
successwith required evidence or explicit no-source not-applicable evidence. -
Regression test: Keep the approval branch checking
needs.coverage-evidence.result == successbefore posting APPROVE, and publish REQUEST_CHANGES when coverage-evidence blocker states such as cancelled, skipped, failed, unsupported-tooling, or below-100 evidence are present. -
Result: REQUEST_CHANGES
-
Reason: coverage-evidence result was
failure, so required test/docstring evidence was not proven for current heade52297df8f0d9e3e8e5a09291c5c546ff9e70f47. -
Head SHA:
e52297df8f0d9e3e8e5a09291c5c546ff9e70f47 -
Workflow run: 29359708273
-
Workflow attempt: 1
Coverage evidence
Coverage Decision
- Result: FAIL
- Test evidence: not proven passing
- Docstring evidence: not proven passing when configured
- Failure count: 1
Changed-File Evidence Map
flowchart LR
PR["PR changed files"] --> Evidence["OpenCode bounded evidence"]
Evidence --> S1["Changed file (2 files)"]
S1 --> I1["repository behavior"]
I1 --> R1["Review risk: Changed file (2 files)"]
R1 --> V1["required checks"]
OpenCode Review Overview
Pull request overviewOpenCode cannot approve yet because required coverage evidence did not pass. Review outcome1. HIGH .github/workflows/opencode-review.yml:1 - Coverage evidence did not prove required test/docstring evidence
Coverage evidenceCoverage Decision
Changed-File Evidence Mapflowchart LR
PR["PR changed files"] --> Evidence["OpenCode bounded evidence"]
Evidence --> S1["Changed file (3 files)"]
S1 --> I1["repository behavior"]
I1 --> R1["Review risk: Changed file (3 files)"]
R1 --> V1["required checks"]
|
There was a problem hiding this comment.
Pull request overview
OpenCode cannot approve yet because required coverage evidence did not pass.
Review outcome
1. HIGH .github/workflows/opencode-review.yml:1 - Coverage evidence did not prove required test/docstring evidence
-
Problem: The required coverage-evidence job result was
failure, so OpenCode cannot establish approval sufficiency for this head. -
Root cause: Automated approval is only valid when the same-head coverage-evidence job proves supported repository test suites passed and configured docstring gates passed or were advisory, or reports not applicable because no supported source files or package manifests exist. Missing, failed, skipped, unavailable, or unsupported-tooling test evidence is a blocker.
-
Fix: Install or configure the repository test/docstring evidence tooling when source files or package manifests exist, rerun the current-head coverage-evidence job, and approve only after it reports
successwith required evidence or explicit no-source not-applicable evidence. -
Regression test: Keep the approval branch checking
needs.coverage-evidence.result == successbefore posting APPROVE, and publish REQUEST_CHANGES when coverage-evidence blocker states such as cancelled, skipped, failed, unsupported-tooling, or below-100 evidence are present. -
Result: REQUEST_CHANGES
-
Reason: coverage-evidence result was
failure, so required test/docstring evidence was not proven for current head34d60e58f73e1d6951a0a19088e9e5ee065a29ab. -
Head SHA:
34d60e58f73e1d6951a0a19088e9e5ee065a29ab -
Workflow run: 29360636077
-
Workflow attempt: 1
Coverage evidence
Coverage Decision
- Result: FAIL
- Test evidence: not proven passing
- Docstring evidence: not proven passing when configured
- Failure count: 1
Changed-File Evidence Map
flowchart LR
PR["PR changed files"] --> Evidence["OpenCode bounded evidence"]
Evidence --> S1["Changed file (2 files)"]
S1 --> I1["repository behavior"]
I1 --> R1["Review risk: Changed file (2 files)"]
R1 --> V1["required checks"]
There was a problem hiding this comment.
Pull request overview
OpenCode cannot approve yet because required coverage evidence did not pass.
Review outcome
1. HIGH .github/workflows/opencode-review.yml:1 - Coverage evidence did not prove required test/docstring evidence
-
Problem: The required coverage-evidence job result was
failure, so OpenCode cannot establish approval sufficiency for this head. -
Root cause: Automated approval is only valid when the same-head coverage-evidence job proves supported repository test suites passed and configured docstring gates passed or were advisory, or reports not applicable because no supported source files or package manifests exist. Missing, failed, skipped, unavailable, or unsupported-tooling test evidence is a blocker.
-
Fix: Install or configure the repository test/docstring evidence tooling when source files or package manifests exist, rerun the current-head coverage-evidence job, and approve only after it reports
successwith required evidence or explicit no-source not-applicable evidence. -
Regression test: Keep the approval branch checking
needs.coverage-evidence.result == successbefore posting APPROVE, and publish REQUEST_CHANGES when coverage-evidence blocker states such as cancelled, skipped, failed, unsupported-tooling, or below-100 evidence are present. -
Result: REQUEST_CHANGES
-
Reason: coverage-evidence result was
failure, so required test/docstring evidence was not proven for current head24b6247444198d85459fa98d40bb794a6aa50c15. -
Head SHA:
24b6247444198d85459fa98d40bb794a6aa50c15 -
Workflow run: 29361639962
-
Workflow attempt: 1
Coverage evidence
Coverage Decision
- Result: FAIL
- Test evidence: not proven passing
- Docstring evidence: not proven passing when configured
- Failure count: 1
Changed-File Evidence Map
flowchart LR
PR["PR changed files"] --> Evidence["OpenCode bounded evidence"]
Evidence --> S1["Changed file (2 files)"]
S1 --> I1["repository behavior"]
I1 --> R1["Review risk: Changed file (2 files)"]
R1 --> V1["required checks"]
There was a problem hiding this comment.
Pull request overview
OpenCode cannot approve yet because required coverage evidence did not pass.
Review outcome
1. HIGH .github/workflows/opencode-review.yml:1 - Coverage evidence did not prove required test/docstring evidence
-
Problem: The required coverage-evidence job result was
failure, so OpenCode cannot establish approval sufficiency for this head. -
Root cause: Automated approval is only valid when the same-head coverage-evidence job proves supported repository test suites passed and configured docstring gates passed or were advisory, or reports not applicable because no supported source files or package manifests exist. Missing, failed, skipped, unavailable, or unsupported-tooling test evidence is a blocker.
-
Fix: Install or configure the repository test/docstring evidence tooling when source files or package manifests exist, rerun the current-head coverage-evidence job, and approve only after it reports
successwith required evidence or explicit no-source not-applicable evidence. -
Regression test: Keep the approval branch checking
needs.coverage-evidence.result == successbefore posting APPROVE, and publish REQUEST_CHANGES when coverage-evidence blocker states such as cancelled, skipped, failed, unsupported-tooling, or below-100 evidence are present. -
Result: REQUEST_CHANGES
-
Reason: coverage-evidence result was
failure, so required test/docstring evidence was not proven for current head4faa8144f4d1572663fca7203c4683d66118a6a4. -
Head SHA:
4faa8144f4d1572663fca7203c4683d66118a6a4 -
Workflow run: 29362563583
-
Workflow attempt: 1
Coverage evidence
Coverage Decision
- Result: FAIL
- Test evidence: not proven passing
- Docstring evidence: not proven passing when configured
- Failure count: 1
Changed-File Evidence Map
flowchart LR
PR["PR changed files"] --> Evidence["OpenCode bounded evidence"]
Evidence --> S1["Changed file (2 files)"]
S1 --> I1["repository behavior"]
I1 --> R1["Review risk: Changed file (2 files)"]
R1 --> V1["required checks"]
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Vectorizes the MMLE-EM M-step Newton–Raphson updates across items to reduce Python-loop overhead and improve runtime, using an active_mask to stop updating converged/singular items early.
Changes:
- Replaces per-item Newton–Raphson loops with batched NumPy ops (
@, masked slicing) across active items. - Adds
active_maskto track convergence / singular-Hessian items during the M-step. - Documents the optimization in
CHANGELOG.mdand internal performance notes (.jules/bolt.md).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| python/fast_mlsirm/estimators/mmle.py | Vectorizes per-item Newton–Raphson updates and introduces active_mask convergence handling. |
| CHANGELOG.md | Adds an entry describing the vectorized MMLE-EM M-step update. |
| .jules/bolt.md | Adds internal note documenting the vectorization approach and rationale. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
최적화 대상: fast_mlsirm/estimators/mmle.py 의 MMLE M-step 내부 최적화 Python 루프(for i in range(n_items))를 통해 각 문항마다 독립적으로 Newton-Raphson 업데이트와 sum() 축소 연산을 수행하여 상당한 오버헤드가 발생했습니다. 이를 완전히 벡터화된 NumPy 연산(@ 및 boolean active_mask 사용)으로 리팩터링하여 루프 없이 모든 활성 문항을 동시에 계산하도록 최적화했습니다. 측정 결과(5000명, 200문항, max_iter=50): 2.669s -> 1.617s로 성능이 약 40%~50% 향상되었습니다.
최적화 대상: fast_mlsirm/estimators/mmle.py 의 MMLE M-step 내부 최적화 Python 루프(for i in range(n_items))를 통해 각 문항마다 독립적으로 Newton-Raphson 업데이트와 sum() 축소 연산을 수행하여 상당한 오버헤드가 발생했습니다. 이를 완전히 벡터화된 NumPy 연산(@ 및 boolean active_mask 사용)으로 리팩터링하여 루프 없이 모든 활성 문항을 동시에 계산하도록 최적화했습니다. 측정 결과(5000명, 200문항, max_iter=50): 2.669s -> 1.617s로 성능이 약 40%~50% 향상되었습니다.
최적화 대상: fast_mlsirm/estimators/mmle.py 의 MMLE M-step 내부 최적화 Python 루프(for i in range(n_items))를 통해 각 문항마다 독립적으로 Newton-Raphson 업데이트와 sum() 축소 연산을 수행하여 상당한 오버헤드가 발생했습니다. 이를 완전히 벡터화된 NumPy 연산(@ 및 boolean active_mask 사용)으로 리팩터링하여 루프 없이 모든 활성 문항을 동시에 계산하도록 최적화했습니다. 측정 결과(5000명, 200문항, max_iter=50): 2.669s -> 1.617s로 성능이 약 40%~50% 향상되었습니다.
최적화 대상: fast_mlsirm/estimators/mmle.py 의 MMLE M-step 내부 최적화 Python 루프(for i in range(n_items))를 통해 각 문항마다 독립적으로 Newton-Raphson 업데이트와 sum() 축소 연산을 수행하여 상당한 오버헤드가 발생했습니다. 이를 완전히 벡터화된 NumPy 연산(@ 및 boolean active_mask 사용)으로 리팩터링하여 루프 없이 모든 활성 문항을 동시에 계산하도록 최적화했습니다. 측정 결과(5000명, 200문항, max_iter=50): 2.669s -> 1.617s로 성능이 약 40%~50% 향상되었습니다.
…or re-review The previous CHANGES_REQUESTED verdict on this head was an infrastructure failure (the central coverage-evidence sandbox could not install numpy — fixed by ContextualWisdomLab/.github#611), not a code judgment. This commit documents the change in the changelog and produces a fresh head so the scheduler dispatches a new review under the repaired pipeline.
026e344 to
adad31c
Compare
|
Warning Review limit reached
Next review available in: 42 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughMMLE-EM M-step이 문항별 Python 루프에서 활성 마스크 기반 벡터화 Newton-Raphson 연산으로 변경되었습니다. 특이 헤시안과 문항별 수렴 처리가 유지되며, MMLE 라우팅 및 벡터화 지침이 문서화되었습니다. ChangesMMLE-EM 업데이트 최적화
Estimated code review effort: 2 (Simple) | ~15 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Dismissed: opencode coverage-evidence is a CI infrastructure failure, not a real code defect. All main CI checks (python, rust, fuzz, trivy-fs) pass.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
CHANGELOG.md:2116
- In this list item, the continuation lines lost their two-space indentation, so Markdown will render them as separate paragraphs rather than part of the bullet. Re-indent the wrapped lines to preserve the list formatting.
- `estimator="mmle"` with a spatial/multidimensional model now fits (routed to
the marginal estimator) instead of raising `NotImplementedError`; plain
`ULS2PLM`/`ULSRM` without a population structure keep the legacy
unidimensional fast path and its exact previous behavior.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (2)
python/fast_mlsirm/estimators/mmle.py:157
- The invalid-determinant handling doesn’t actually guarantee
da/dbbecome 0: if any Hessian component isNaN/Inf(ordetisNaN), the current approach can still produceNaNupdates via operations likeh_bb * 0.0, which then propagates intoa_act/b_act. It also makes the comment about “(da, db will be 0)” potentially incorrect. Consider computingda/dbwithnp.divide(..., where=valid, out=0)and extendingvalidto include finite checks so invalid items get a guaranteed zero step before being masked inactive.
# Avoid division by zero, set invalid determinants to 1.0 (da, db will be 0)
valid = np.abs(det) >= 1e-12
if not np.all(valid):
det = np.where(valid, det, 1.0)
g_a = np.where(valid, g_a, 0.0)
CHANGELOG.md:2448
- These lines lost the two-space indentation used for bullet continuations in the changelog, which breaks Markdown rendering (the wrapped lines become a new paragraph instead of continuing the list item).
- `estimator="mmle"` with a spatial/multidimensional model now fits (routed to
the marginal estimator) instead of raising `NotImplementedError`; plain
`ULS2PLM`/`ULSRM` without a population structure keep the legacy
unidimensional fast path and its exact previous behavior.
There was a problem hiding this comment.
Pull request overview
OpenCode cannot approve yet because required coverage evidence did not pass.
Review outcome
1. HIGH .github/workflows/opencode-review.yml:1 - Coverage evidence did not prove required test/docstring evidence
-
Problem: The required coverage-evidence job result was
failure, so OpenCode cannot establish approval sufficiency for this head. -
Root cause: Automated approval is only valid when the same-head coverage-evidence job proves supported repository test suites passed and configured docstring gates passed or were advisory, or reports not applicable because no supported source files or package manifests exist. Missing, failed, skipped, unavailable, or unsupported-tooling test evidence is a blocker.
-
Fix: Install or configure the repository test/docstring evidence tooling when source files or package manifests exist, rerun the current-head coverage-evidence job, and approve only after it reports
successwith required evidence or explicit no-source not-applicable evidence. -
Regression test: Keep the approval branch checking
needs.coverage-evidence.result == successbefore posting APPROVE, and publish REQUEST_CHANGES when coverage-evidence blocker states such as cancelled, skipped, failed, unsupported-tooling, or below-100 evidence are present. -
Result: REQUEST_CHANGES
-
Reason: coverage-evidence result was
failure, so required test/docstring evidence was not proven for current headd4b3a223595e6588a7725855499617ef80c95651. -
Head SHA:
d4b3a223595e6588a7725855499617ef80c95651 -
Workflow run: 30506123636
-
Workflow attempt: 1
Coverage evidence
Coverage Decision
- Result: FAIL
- Test evidence: not proven passing
- Docstring evidence: not proven passing when configured
- Failure count: 1
Changed-File Evidence Map
flowchart LR
PR["PR changed files"] --> Evidence["OpenCode bounded evidence"]
Evidence --> S1["Changed file (3 files)"]
S1 --> I1["repository behavior"]
I1 --> R1["Review risk: Changed file (3 files)"]
R1 --> V1["required checks"]
|
Superseded: Bolt performance theme conflicts with current main (related landings e.g. #345 linear_predictor in-place ops). Closing as superseded; reopen from clean base if still valuable. |
|
Closing as superseded: Bolt theme already on main or blocked by unresolvable conflicts with current main. Prefer re-open from a fresh branch if still needed. |
Understood. Acknowledging that this work is now superseded by other optimizations on main and stopping work on this task. |
Acknowledged. |
💡 What:
python/fast_mlsirm/estimators/mmle.py내 MMLE M-step 과정의 최적화를 수행했습니다. 문항별 Newton-Raphson 업데이트를 수행하던 외부 파이썬for루프와.sum()기반 축소 연산을 제거하고, 전체 활성 문항을 동시에 계산하는 완전히 벡터화된 NumPy 배열 연산과 행렬곱(@)으로 대체했습니다. 더 이상 업데이트가 필요하지 않은 문항(수렴 또는 determinant 오류 등)을 추적하기 위해active_mask를 도입했습니다.🎯 Why: 기존 코드는 각 문항을 순회하며 개별적으로 그래디언트와 헤시안을 스칼라 방식에 가깝게 계산하고
.sum()연산을 반복하여, 문항 수가 많아질수록 파이썬 루프 오버헤드와 연산 비효율로 인한 주요 병목이 발생했습니다. 벡터화된 접근법은 내부적으로 BLAS 최적화 연산을 활용해 실행 시간을 비약적으로 단축합니다.📊 Impact: 5000명, 200개 문항을 대상으로 max_iter=50을 설정한 테스트에서 수행 시간이 2.669초에서 1.617초로 단축되어 약 40% 이상의 성능 향상을 달성했습니다. 수학적 연산 결과의 오차는 1e-14 이하 수준으로 사실상 동일함을 확인했습니다.
🔬 Measurement: 기존 코드와 최적화된 코드의 수행 시간을 측정하는 스크립트를 작성하여 테스트를 완료했으며, 전체 테스트 스위트(
pytest)를 실행하여 기능이 손상되지 않고 수치적 퇴보가 없음을 검증했습니다.PR created automatically by Jules for task 14594582842277912981 started by @seonghobae
Summary by CodeRabbit
성능 개선
기능 개선
문서