Skip to content

refactor(glm): preserve binomial likelihood while removing ifelse - #111

Draft
seonghobae wants to merge 5 commits into
masterfrom
optimize-glm-ifelse-13016045089936808825
Draft

refactor(glm): preserve binomial likelihood while removing ifelse#111
seonghobae wants to merge 5 commits into
masterfrom
optimize-glm-ifelse-13016045089936808825

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 30, 2026

Copy link
Copy Markdown
Collaborator

범위

llcont.glm()의 binomial casewise likelihood 계산에서 ifelse()를 직접 산술·부분 대입으로 바꾸되, 모델별 likelihood 의미와 zero-contribution 계약을 보존합니다. 이 변경을 아직 buyer-visible 성능 개선으로 승격하지 않습니다.

이번 repair

  • exact head: cda75b392cb06637fe6d627ce073f2a53dc7daa9
  • protected base: master@807e9405f8c32faafdf186f977a24d0b23358b43
  • generated .jules/bolt.md~22% repository-wide 성능 교리는 protected-base canonical blob으로 normal descendant 복원했습니다.
  • ..Rcheck/00check.logDESCRIPTIONAuthor/Maintainer 누락으로 Status: 1 ERROR인 로컬 실패 산출물이므로 branch에서 제거했습니다. 실패 로그를 package acceptance evidence로 보존하지 않습니다.
  • tests/testthat/test_llcont_glm_binomial_zero_contract.R를 추가해 grouped-binomial의 zero-total row와 zero prior-weight row가 유한한 0 contribution을 유지하고 sum(llcont(fit)) == as.numeric(logLik(fit))인지 직접 검증합니다.

증거 경계

생성 PR의 1,000,000개 synthetic 벡터 microbenchmark와 ~208 ms -> ~144 ms, ~22% 주장은 제품 workload, fitted-GLM construction, runtime/CPU, warm-up/repetition, allocation/GC, failure denominator를 고정하지 않았습니다. 따라서 이 수치는 탐색 결과일 뿐 제품 성능 acceptance가 아닙니다.

현재 source delta의 promotion 조건은 먼저 exact-head R package tests/R-CMD-check가 semantics를 검증하는 것입니다. 성능 개선으로 승격하려면 production-representative binomial model shapes에서 동일한 fitted-model/output 계약을 유지한 채 wall-clock/CPU/allocation evidence를 재현해야 합니다. 효과가 작거나 역행하면 더 단순한 구현으로 되돌립니다.

Current gate

Draft를 유지합니다. 현재 head의 hosted R-CMD-check/security/review evidence가 terminal GREEN이 되기 전에는 Ready/merge하지 않습니다. predecessor check, failed local Rcheck log, synthetic microbenchmark를 current-head GREEN으로 이전하지 않습니다. force-push, destructive rebase, self-approval, gate weakening은 사용하지 않습니다.

@google-labs-jules

Copy link
Copy Markdown

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai

coderabbitai Bot commented Aug 30, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 652b8e55-d71d-4b25-99f6-f9ac46ce3085

📥 Commits

Reviewing files that changed from the base of the PR and between 807e940 and 0712d23.

📒 Files selected for processing (2)
  • .jules/bolt.md
  • R/llcont.R

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

이항 GLM의 행렬 응답 정규화와 가중치 계산에서 ifelse를 제거했습니다. 사전 할당과 벡터화된 부분 대입을 사용합니다. NA 인덱스 처리 및 관련 성능 지침을 문서에 추가했습니다.

Changes

이항 GLM 계산 벡터화

Layer / File(s) Summary
응답·가중치 계산과 최적화 지침
R/llcont.R, .jules/bolt.md
행렬 응답에서 n == 0인 값을 0으로 설정하고, m <= 0인 가중치를 0으로 설정합니다. ifelse 대신 사전 할당과 조건부 부분집합 대입을 사용합니다. NA 인덱스 정제 방법과 성능 정보를 문서화했습니다.

Estimated code review effort: 2 (Simple) | ~10분

Merge Risk: ⚪ Minimal · up to 0712d

This localized change replaces conditional vector construction with direct vectorized assignments in the binomial GLM likelihood path; no actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목은 glm의 이항 우도 계산을 유지하면서 ifelse를 제거하는 주요 변경을 정확하고 간결하게 설명합니다.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch optimize-glm-ifelse-13016045089936808825

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Note

This report is out of date. Scroll down for Devin Review's latest report on this PR.

Devin Review found 1 potential issue.

Devin Review

Comment thread R/llcont.R
Comment on lines +57 to +65
y <- y[, 1]/n
y[n == 0] <- 0
} else {
n <- rep.int(1, length(y))
}
m <- if (any(n > 1)) n else wt
wt <- ifelse(m > 0, (wt/m), 0)
## Bolt: replaced ifelse with preallocation and vectorized subsetting for performance
wt <- wt / m
wt[m <= 0] <- 0

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📝 Info: Zero denominators remain contained

Zero-trial and zero-weight rows create transient NaN values. The indexed assignments replace them before likelihood evaluation, preserving prior results.

Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

Devin Review

Comment thread ..Rcheck/00check.log Outdated
Comment on lines +9 to +13
* checking for file ‘./DESCRIPTION’ ... ERROR
Required fields missing or empty:
‘Author’ ‘Maintainer’
* DONE
Status: 1 ERROR

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔍 Failed check artifact is committed

The generated 00check.log records a failed source check, not completion of the required tarball-based CRAN quality gate.

Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@opencode-agent

opencode-agent Bot commented Sep 4, 2026

Copy link
Copy Markdown

Scheduled review-feedback autofix for this PR head.

  • Head SHA: 6095aec24f17c5e64c5162f3d2a92d3223a2a456

@opencode-agent

opencode-agent Bot commented Sep 4, 2026

Copy link
Copy Markdown

Scheduled review-feedback autofix for this PR head.

  • Head SHA: 6095aec24f17c5e64c5162f3d2a92d3223a2a456

@seonghobae
seonghobae marked this pull request as draft September 4, 2026 14:48
@seonghobae seonghobae changed the title ⚡ Bolt: Optimize llcont.glm by replacing ifelse with vectorized subsetting refactor(glm): preserve binomial likelihood while removing ifelse Sep 4, 2026
@opencode-agent

opencode-agent Bot commented Sep 4, 2026

Copy link
Copy Markdown

Scheduled review-feedback autofix for this PR head.

  • Head SHA: cda75b392cb06637fe6d627ce073f2a53dc7daa9

@opencode-agent

opencode-agent Bot commented Sep 5, 2026

Copy link
Copy Markdown

Scheduled review-feedback autofix for this PR head.

  • Head SHA: cda75b392cb06637fe6d627ce073f2a53dc7daa9

@seonghobae seonghobae added maintenance priority: medium Normal-priority or P2 work type: maintenance Maintenance, build, dependency, or operational upkeep labels Sep 7, 2026 — with ChatGPT Codex Connector
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance priority: medium Normal-priority or P2 work type: maintenance Maintenance, build, dependency, or operational upkeep

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant