[FEAT#63] neuron Phase 11 — channel adj 의 scale-corrected init (uniform_around_one) - #64
Conversation
…_around_one) 배경: Phase 10 (PR #62) 결정적 발견 — 'sweet spot magnitude 는 자유도의 의미적 위치에 의존' 규칙 (memory: feedback_no_zero_init.md 업데이트). - residual gate (y = x + α·f(x)): ~0.10 - weight multiplier (y = (adj·W)x): ~1.0 graph_channel.py: - AdjInit Literal 에 'uniform_around_one' 추가 - 동작: uniform[0.95, 1.05] — 1.0 근처 small noise - 의미: scale 균형 (effective_w ≈ W magnitude) + 0-init 회피 - 기존 uniform_small 은 anti-pattern 으로 유지 (ablation 비교용) - docstring 갱신 — 모든 옵션의 trade-off 명시 graph_channel_demo.py: - Arch literal + _make_linear 분기 추가 tests/neuron/test_graph_channel.py — 2 신규 테스트: - uniform_around_one range [0.95, 1.05] + mean ≈ 1.0 검증 - function preservation approximate — effective_w/W magnitude ratio ≈ 1.0 (vs uniform_small 의 ratio ~0.10) notebooks/02-function-level/10-phase11-scale-corrected-init.ipynb: - 4 × 2 sweep: arch ∈ {plain, channel_full, channel_uniform_small, channel_uniform_around_one} - Phase 10 baseline 직접 비교 + 자동 verdict - §6 4 arch adj distribution 비교 - §7 loss curve 4 arch 104/104 tests pass.
|
Important Review skippedReview was skipped due to path filters ⛔ Files ignored due to path filters (2)
CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThis PR implements the Phase 11 feature introducing a new Changesuniform_around_one initialization and Phase 11 validation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Code Review
This pull request introduces a new scale-corrected initialization option, uniform_around_one, for ChannelGraphLinear across the codebase, including updates to the demo script, a new Phase 11 Jupyter notebook, and corresponding unit tests. It also documents uniform_small as an anti-pattern. The reviewer suggested updating the ValueError message for zero-initialization to recommend uniform_around_one instead of uniform_small to maintain consistency with these changes.
There was a problem hiding this comment.
Pull request overview
본 PR은 Phase 10에서 확인된 “weight multiplier 위치의 adj는 magnitude가 ~1.0이어야 한다”는 관찰을 검증하기 위해, ChannelGraphLinear의 adj_init에 scale-corrected 초기화(uniform_around_one, U[0.95, 1.05])를 추가합니다. 이를 통해 uniform_small(≈0.1 스케일)로 인해 effective_w = adj * W의 magnitude가 과도하게 줄어드는 문제를 완화/검증하는 흐름입니다.
Changes:
adj_init="uniform_around_one"옵션 추가 및 초기화 로직 구현 (U[0.95, 1.05])- 데모 아키텍처 분기 확장 및 신규 테스트 2건 추가(범위/scale 보존 근사)
- Phase 11 실험 노트북 추가(4 arch × 2 seed sweep 및 자동 verdict/시각화)
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/graphlm/neuron/graph_channel.py |
AdjInit에 uniform_around_one 추가 및 adj 초기화 분기 확장 |
src/graphlm/neuron/graph_channel_demo.py |
데모용 Arch에 channel_uniform_around_one 추가 및 _make_linear 분기 확장 |
tests/neuron/test_graph_channel.py |
uniform_around_one 범위/scale 근사 보존 검증 테스트 2건 추가 |
notebooks/02-function-level/10-phase11-scale-corrected-init.ipynb |
Phase 11 sweep/비교/자동 판정 및 분포·loss curve 시각화 노트북 추가 |
Comments suppressed due to low confidence (1)
src/graphlm/neuron/graph_channel.py:103
adj_init in {"zero","zeros"}에 대한 ValueError 메시지가 현재'full'/'uniform_small'만 권장하고 있어, 새로 추가된 (그리고 Phase 11+ 권장으로 문서화된)'uniform_around_one'옵션을 사용하는 사용자가 혼란스러울 수 있습니다. 에러 메시지의 권장 옵션/설명을'uniform_around_one'까지 포함하도록 갱신하는 편이 일관됩니다.
f"adj_init={adj_init!r} 는 금지됨 — 0-init 은 vanishing gradient 함정 "
"(Phase 1 dead block / Phase 7 amplitude vanishing / Phase 9 block-diagonal "
"에서 3차 재현). rationale: Phase 9 PR #60. "
"'full' (function preserving) 또는 'uniform_small' (sweet spot 패턴) 사용 권장."
)
- graph_channel.py 모듈 docstring 의 권장 옵션 list 갱신: 'uniform_small' → 'uniform_around_one' 권장으로 (Copilot #3302006547) uniform_small 은 anti-pattern 명시 - graph_channel.py ValueError 메시지에서 'uniform_small' 권장 → 'uniform_around_one' 으로 (gemini #3301992790) + Phase 10 PR #62 (magnitude rule) 참조 추가 - graph_channel_demo.py 모듈 docstring 의 '3 가지 architecture' → '4 가지' + uniform_around_one 설명 추가 (Copilot #3302006608) 104/104 tests pass.
- docs/figures/neuron/phase11/adj_dist_compare.png — 3 channel arch 의 adj 분포 비교 - docs/figures/neuron/phase11/loss_curves.png — 4 arch loss curve (mean ± σ) feature branch 에서 commit (feedback_image_commit_branch.md 규칙).
연관 이슈
Closes #63
배경 — Phase 10 의 결정적 발견 확장 검증
Phase 10 (PR #62) 결과:
channel_full(adj=1) ≈ plain Linear + 약간 우위 (-0.0148)channel_uniform_small(adj ∈ [0.05, 0.15], Phase 2 sweet spot 패턴) = +0.18 열위effective_w = adj * W에서 adj≈0.10 → magnitude 10% 수준 → forward 약화→ 새 규칙: 0-init 금지 + 적정 magnitude 는 자유도의 의미적 위치에 의존
y = x + α·f(x)): ~0.10y = (adj·W)x): ~1.0 ← 본 PR 의 직접 검증본 phase = uniform[0.95, 1.05] 로 magnitude balance + 0-init 회피 + adj 학습 활성 동시 달성 가설 검증.
구현 내용
1.
src/graphlm/neuron/graph_channel.py(변경)AdjInitliteral 에"uniform_around_one"추가uniform[0.95, 1.05]— 1.0 근처 small noise"uniform_small"은 anti-pattern (ablation 용) 으로 유지 + docstring 에 magnitude rule 위반 명시2.
src/graphlm/neuron/graph_channel_demo.py(변경)Archliteral +_make_linear분기 추가3.
tests/neuron/test_graph_channel.py— 2 신규test_uniform_around_one_adj_init_range— [0.95, 1.05] + mean ≈ 1.0 검증test_uniform_around_one_function_preservation_approximate— effective_w/W magnitude ratio ≈ 1.0 (vs uniform_small ratio ~0.10)4.
notebooks/02-function-level/10-phase11-scale-corrected-init.ipynb검증할 가설
CI / 머지 게이트 점검
make fmt통과make lint통과 (nbqa --fix 1건)make test통과 — 104 passed (기존 102 + 신규 2)변경 영향 범위 + 위험도
adj_init옵션 추가 + 기존 옵션 동작 무변경 → backward-compatible additive메모리 규칙 update 사전 반영
feedback_no_zero_init.md가 Phase 10 발견 (magnitude rule) 으로 업데이트됨 (본 PR 의 motivation).Phase 12+ 계획 유지
Summary by CodeRabbit
New Features
Documentation
Tests