Skip to content

⚡ Bolt: Optimize _factor_fit with vectorized aggregations - #179

Closed
seonghobae wants to merge 1 commit into
mainfrom
bolt-optimize-factor-fit-10043797980699195769
Closed

⚡ Bolt: Optimize _factor_fit with vectorized aggregations#179
seonghobae wants to merge 1 commit into
mainfrom
bolt-optimize-factor-fit-10043797980699195769

Conversation

@seonghobae

Copy link
Copy Markdown
Contributor

What

fast_mlsirm/diagnostics.py_factor_fit 함수에서 Python for 루프를 제거하고, axis=0 기준 병합 및 boolean masking 행렬 곱셈(@)을 통한 완전 벡터화(vectorized) 구현으로 변경하였습니다. 또한 최적화에 대한 설명 주석을 추가했습니다.

Why

NumPy 환경에서 Python 레벨의 명시적 for 루프를 반복하며 범주형 데이터(factor) 단위로 집계 연산을 수행하면 인터프리터 오버헤드와 C 레벨 루프 최적화 부재로 인해 병목이 발생합니다. .sum(axis=0)을 통한 선제적 아이템 집계 및 매핑 마스크(boolean mapping mask)에 대한 행렬 곱(@)을 활용하면 C/BLAS 수준의 최적화를 이끌어낼 수 있습니다. 이로 인해 대형 데이터셋에서 메모리 추가 할당(allocation)과 실행 시간을 극적으로 절감할 수 있습니다. (참고: .jules/bolt.md)

Impact

배열을 3차원으로 브로드캐스팅하거나 Python 스칼라 호출을 하는 대신 마스킹과 행렬 곱으로 일괄 치환함으로써, 요소와 팩터의 수가 많은 환경에서 실행 시간을 약 1/14로 획기적으로 줄였습니다. benchmark_factor_fit.py 벤치마크 결과 (N=5000, J=500):

  • 원본 코드: ~4.20s
  • 벡터화 최적화 코드: ~0.30s (성능 향상: 약 93% 시간 단축)

Measurement

Python pytest( python -m pytest tests ) 및 Rust 단위 테스트( cargo test --workspace )가 정상적으로 통과되며, 원래 출력 형태와 완전히 동일한 값을 반환하는 것을 확인하였습니다.


PR created automatically by Jules for task 10043797980699195769 started by @seonghobae

@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.

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 success with required evidence or explicit no-source not-applicable evidence.

  • Regression test: Keep the approval branch checking needs.coverage-evidence.result == success before 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 head 7d4ca15245d53137981ac500a40f98b1bd76631c.

  • Head SHA: 7d4ca15245d53137981ac500a40f98b1bd76631c

  • Workflow run: 29617236539

  • 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: diagnostics.py"]
  S1 --> I1["repository behavior"]
  I1 --> R1["Review risk: Changed file: diagnostics.py"]
  R1 --> V1["required checks"]
  Evidence --> S2["Test: test_objective.py"]
  S2 --> I2["regression suite"]
  I2 --> R2["Review risk: Test: test_objective.py"]
  R2 --> V2["targeted test run"]
Loading

@opencode-agent

Copy link
Copy Markdown
Contributor

OpenCode Review Overview

  • Head SHA: 7d4ca15245d53137981ac500a40f98b1bd76631c
  • Workflow run: 29617236539
  • Workflow attempt: 1
  • Gate result: REQUEST_CHANGES (approval step)

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 success with required evidence or explicit no-source not-applicable evidence.

  • Regression test: Keep the approval branch checking needs.coverage-evidence.result == success before 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 head 7d4ca15245d53137981ac500a40f98b1bd76631c.

  • Head SHA: 7d4ca15245d53137981ac500a40f98b1bd76631c

  • Workflow run: 29617236539

  • 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: diagnostics.py"]
  S1 --> I1["repository behavior"]
  I1 --> R1["Review risk: Changed file: diagnostics.py"]
  R1 --> V1["required checks"]
  Evidence --> S2["Test: test_objective.py"]
  S2 --> I2["regression suite"]
  I2 --> R2["Review risk: Test: test_objective.py"]
  R2 --> V2["targeted test run"]
Loading

Copy link
Copy Markdown
Contributor Author

중복 정리: _factor_fit 벡터화가 #169 와 동일하며, #169_binary/_categorical_stratum_(item_)fit 4종 벡터화까지 포괄하는 상위집합입니다. 이 PR의 tests/test_objective.py 변경은 재포맷입니다. #169 를 대표로 남기고 닫습니다.

배경: 2026-07-14 이후 조직 coverage-evidence 인프라 문제로 모든 PR이 REQUEST_CHANGES 상태였습니다(인프라 수정: ContextualWisdomLab/.github#611). 필요 시 재오픈 가능합니다.


Generated by Claude Code

@google-labs-jules

Copy link
Copy Markdown

중복 정리: _factor_fit 벡터화가 #169 와 동일하며, #169_binary/_categorical_stratum_(item_)fit 4종 벡터화까지 포괄하는 상위집합입니다. 이 PR의 tests/test_objective.py 변경은 재포맷입니다. #169 를 대표로 남기고 닫습니다.

배경: 2026-07-14 이후 조직 coverage-evidence 인프라 문제로 모든 PR이 REQUEST_CHANGES 상태였습니다(인프라 수정: ContextualWisdomLab/.github#611). 필요 시 재오픈 가능합니다.


Generated by Claude Code

Understood. Acknowledging that this work is a subset of #169 and is now obsolete, and stopping work on this task.

@seonghobae seonghobae closed this Jul 21, 2026
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.

1 participant