Skip to content

[FEATURE] neuron Phase 10 — channel-as-node graph hidden layer foundations (A-safe with 0-init 금지) #61

Description

@juhy0987

배경

Phase 9 (PR #60) 의 결정적 발견:

  • group_full ≈ plain Linear (graph 구조 free, function preservation 입증)
  • group_identity (block-diagonal sparse 시작) = +0.14 loss 열위 — 0-init vanishing 패턴이 graph paradigm 에서도 재현
  • 메모리 등록: 0-init 금지 규칙 (feedback_no_zero_init.md)

이 결과를 바탕으로 사용자 vision (히든 레이어 자체를 graph) 의 본질 axis A (channel-as-node) 진입. 그러나 단순 0-init sparse 진입 = Phase 9 의 함정 재현 → A-safe (small random adj init) 로 진입.

핵심 설계 — channel-as-node graph (단일 채널 = 1 node)

hidden_dim H 채널 = H 개 node
edge[in, out]: 각 (in, out) 쌍에 대해 adj[out, in] ∈ ℝ (학습 가능 routing scalar)
effective weight: W_eff = adj ⊙ W (elementwise product)
forward: y = W_eff @ x
  • node = 1 채널 (graph 의 vertex, paradigm 의 finest unit)
  • edge weight = adj[out, in] · W[out, in]
  • adj_init 옵션:
    • "full" — 모두 1 (function preserving, standard Linear 와 forward 동치)
    • "uniform_small" — uniform[0.05, 0.15] (Phase 2 sweet spot 패턴 channel-level edge 에 적용)
  • "zero" 옵션 거부 — 0-init 금지 규칙 적용 (명시적 ValueError)

검증할 가설

  1. function preservation — adj=full 시 standard Linear 와 forward 동치?
  2. gradient flow through adj — adj 가 학습 가능 (per-edge importance 학습)?
  3. sweet spot 적용 효과 — adj_init=uniform_small (Phase 2 패턴) 으로 시작 시 plain 과 비교?
  4. post-training adj 분포 — 학습 후 일부 edge 가 자연 약화 (implicit pruning channel-level)?
  5. Phase 9 group 과의 비교 — channel-level granularity 가 group-level 보다 표현력 우위?

범위 — Phase 10 = channel graph foundations

신규 모듈 — src/graphlm/neuron/graph_channel.py

  • ChannelGraphLinear(in_features, out_features, adj_init)
    • weight: (out, in) standard linear weight
    • adj: (out, in) — 학습 가능 per-edge gate scalar
    • forward: y = (adj * weight) @ x (elementwise)
    • adj_init="full" → 모두 1 (function preserving)
    • adj_init="uniform_small" → uniform[0.05, 0.15] (sweet spot 패턴)
    • adj_init="zero" 시 ValueError (0-init 금지 규칙)
  • sparsify_adj(threshold) — Phase 11+ 학습된 routing 의 hard sparsification stub
  • adj_sparsity() — 현재 |adj| < threshold edges 비율 측정

테스트 — tests/neuron/test_graph_channel.py

  • shape (weight + adj 모두 (out, in))
  • adj_init values 검증 (full=1, uniform_small ∈ [0.05, 0.15])
  • 0-init 거부 검증adj_init="zero" 시 ValueError + 메모리 규칙 명시
  • function preservation — adj=full + 같은 W → standard Linear forward 동치 (atol=1e-5)
  • gradient flow — weight, adj 모두 grad 흐름
  • sparsify_adj / adj_sparsity 동작 + edge case
  • in/out features 검증 (positive int)

데모 노트북 — notebooks/02-function-level/09-phase10-channel-graph-foundations.ipynb

  • 3 × 2 sweep: arch ∈ {plain, channel_full, channel_uniform_small} × seed ∈ {42, 123} = 6 run
  • HIDDEN_DIM=256, GROUP_SIZE 무관 (channel granularity)
  • §5 final_loss 비교 + Phase 9 결과 (plain 2.1378, group_full 2.1391) 와 직접 비교
  • §6 학습된 adj 분포 분석 (histogram) — Phase 5 의 implicit pruning 패턴이 edge-level 에서 재현?
  • §7 adj heatmap (256 × 256 — color-coded sparsity)
  • §8 loss curve 3 arch

완료 조건

  • ChannelGraphLinear 구현 + function preservation 검증
  • adj 학습 가능성 (gradient) 검증
  • 0-init 거부 (ValueError) 검증
  • 신규 테스트 ≥ 7건 통과
  • 데모 노트북 실행 + verdict
  • make lint / make test 통과
  • PR 머지

Phase 11+ 계획

  • Phase 11: 계층적 hybrid (Phase 9 group + Phase 10 channel nest) — vision 의 ultimate
  • Phase 12: 학습된 routing (DARTS / L0 / Gumbel) 로 adj sparsification 학습
  • Phase 13: Transformer 통합 (Q/K/V/O 모두 ChannelGraphLinear or GroupGraphLinear)

참고

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions