Skip to content

PJHkorea/Egregore

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

111 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš€ Optax-Based Accelerator Optimizer Engine Architectural Overhaul (v2.0)

[EN] This document delivers the technical specifications and mathematical mechanics regarding the Optax Optimizer Engine Architectural Overhaul achieved via migrating from CR_egregore_jax_test.py to CR_egregore_jax_test_v2.py. It provides a rigorous computational resolution to both XLA graph fragmentation and host-side memory leaks previously encountered during LLM and MoE acceleration pipelines.

[KR] ๋ณธ ๋ฌธ์„œ๋Š” CR_egregore_jax_test.py์—์„œ CR_egregore_jax_test_v2.py๋กœ์˜ ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜์„ ํ†ตํ•ด ๋‹ฌ์„ฑํ•œ Optax ์˜ตํ‹ฐ๋งˆ์ด์ € ์—”์ง„ ์•„ํ‚คํ…์ฒ˜ ๊ฐœํŽธ๊ณผ ๊ด€๋ จ๋œ ๊ธฐ์ˆ ์  ๋ช…์„ธ ๋ฐ ์ˆ˜๋ฆฌ ์—ญํ•™์  ๊ฐœ์„  ์‚ฌํ•ญ์„ ๋‹ค๋ฃน๋‹ˆ๋‹ค. LLM ๋ฐ MoE ๊ฐ€์†ํ™” ๊ณผ์ •์—์„œ ๋ฐœ์ƒํ•˜๋˜ XLA ๊ทธ๋ž˜ํ”„ ํŒŒํŽธํ™”์™€ ํ˜ธ์ŠคํŠธ ๋ฉ”๋ชจ๋ฆฌ ๋ˆ„์ˆ˜ ๋ฌธ์ œ๋ฅผ ์ „์‚ฐํ•™์ ์œผ๋กœ ํ•ด๊ฒฐํ–ˆ์Šต๋‹ˆ๋‹ค.


1. ์ตœ์ ํ™” ์—”์ง„: ๋‹จ์ผ ์œตํ•ฉ ์ปค๋„ ํ˜•์„ฑ (Optimization Engine: Single Fused Kernel Formulation)

โŒ ๊ตฌ ๋ฒ„์ „ (Conventional Baseline - CR_egregore_jax_test.py): ๋‹ค์ค‘ ๋ถ„๊ธฐ ๋ ˆ์ผ (Multi-Transform Rails)

[EN]

  • Implementation: Invoked optax.multi_transform to execute hardware-level physical branching over backbone and gate nodes based on Python dictionary key paths.
  • Flaw: The XLA compiler generated numerous dynamic instruction routing branches at the device level, triggering severe Graph Fragmentation and critical branch stalls.

[KR]

  • ๊ตฌํ˜„ ๋ฐฉ์‹: optax.multi_transform์„ ํ˜ธ์ถœํ•˜์—ฌ ํŒŒ์ด์ฌ ๋”•์…”๋„ˆ๋ฆฌ ํ‚ค ๊ฒฝ๋กœ๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ backbone๊ณผ gate ๋…ธ๋“œ๋ฅผ ๋ฌผ๋ฆฌ ๋ถ„๊ธฐํ–ˆ์Šต๋‹ˆ๋‹ค.
  • ๋ฌธ์ œ์ : XLA ์ปดํŒŒ์ผ๋Ÿฌ๊ฐ€ ์žฅ์น˜(Device) ๋‹จ์—์„œ ์ˆ˜๋งŽ์€ ๋ช…๋ น์–ด ๋ถ„๊ธฐ ํ๋ฆ„์„ ์ƒ์„ฑํ•˜์—ฌ ๊ทธ๋ž˜ํ”„ ํŒŒํŽธํ™”(Graph Fragmentation) ๋ฐ ๋ถ„๊ธฐ ์Šคํ†จ์„ ์œ ๋ฐœํ–ˆ์Šต๋‹ˆ๋‹ค.

โœจ ์‹  ๋ฒ„์ „ (Advanced Paradigm - CR_egregore_jax_test_v2.py): ์ˆœ์ˆ˜ ์‹ค๋ฆฌ์ฝ˜ MUX ๋ ˆ์ผ (Pure Silicon MUX Rails)

[EN]

  • Implementation: Spans a single underlying optax.adam(learning_rate=1.0) engine stripped of native weight decay to perfectly unify and track pristine momentum accumulation.
  • Improvement: Executes inline control entirely through dynamic f32 literal register masks and algebraic Hadamard Products, which are highly optimized for accelerator ALUs. This force-fuses a zero-stall Single Fused Kernel directly inside the on-chip memory layout.

[KR]

  • ๊ตฌํ˜„ ๋ฐฉ์‹: ๊ฐ€์ค‘์น˜ ๊ฐ์‡ ๋ฅผ ๋ฐฐ์ œํ•œ ๋‹จ์ผ optax.adam(learning_rate=1.0) ์—”์ง„์œผ๋กœ ์ ๋ฅ (Momentum)์„ ๊นจ๋—ํ•˜๊ฒŒ ํ†ตํ•ฉ ์ถ”์ ํ•ฉ๋‹ˆ๋‹ค.
  • ๊ฐœ์„  ํšจ๊ณผ: ์™ธ๋ถ€์—์„œ ๊ฐ€์†๊ธฐ ALU๊ฐ€ ๊ฐ€์žฅ ์„ ํ˜ธํ•˜๋Š” f32 ๋ฆฌํ„ฐ๋Ÿด ๋งˆ์Šคํฌ์™€ ์•„๋‹ค๋งˆ๋ฅด ๊ณฑ(Hadamard Product) ๋Œ€์ˆ˜์‹๋งŒ์œผ๋กœ ์ธ๋ผ์ธ ์ œ์–ดํ•ฉ๋‹ˆ๋‹ค. ์ด๋ฅผ ํ†ตํ•ด ๋ถ„๊ธฐ ์Šคํ†จ์ด ์กด์žฌํ•˜์ง€ ์•Š๋Š” **๋‹จ์ผ ์œตํ•ฉ ์ปค๋„(Fused Kernel)**์„ ๊ฐ•์ œ ํ˜•์„ฑํ•ฉ๋‹ˆ๋‹ค.

2. ๊ฐ€์ค‘์น˜ ๊ฐ์‡  ์ˆ˜๋ฆฌ ์—ญํ•™: ์ด์ค‘ ๊ฐ์‡  ๋ฐ•๋ฉธ (Weight Decay Mechanics: Eradicating Double-Dipping)

โŒ ๊ตฌ ๋ฒ„์ „ (Conventional Baseline - CR_egregore_jax_test.py)

[EN]

  • Implementation: Individually invoked optax.adamw within each divided sub-optimizer track.
  • Flaw: When integrated with the Layer-wise Learning Rate Decay (LLRD) mask, the weight decay coefficients were inherently distorted as they leaked directly into the Adam internal momentum equations, triggering a critical Double-Dipping defect.

[KR]

  • ๊ตฌํ˜„ ๋ฐฉ์‹: ๋ถ„๊ธฐ๋œ ํ•˜์œ„ ์˜ตํ‹ฐ๋งˆ์ด์ € ๋‚ด๋ถ€์—์„œ ๊ฐœ๋ณ„์ ์œผ๋กœ optax.adamw๋ฅผ ํ˜ธ์ถœํ–ˆ์Šต๋‹ˆ๋‹ค.
  • ๋ฌธ์ œ์ : ๊ณ„์ธต๋ณ„ ์ฐจ๋“ฑ ํ•™์Šต๋ฅ (LLRD) ๋งˆ์Šคํฌ์™€ ๊ฒฐํ•ฉํ•  ๋•Œ, Adam ๋‚ด๋ถ€ ๋ชจ๋ฉ˜ํ…€ ๊ณ„์‚ฐ ์‹์— ๊ฐ€์ค‘์น˜ ๊ฐ์‡  ๊ณ„์ˆ˜๊ฐ€ ์›์ฒœ ์™œ๊ณก๋˜์–ด ์œ ์ž…๋˜๋Š” ์ด์ค‘ ๊ฐ์‡ (Double-Dipping) ๊ฒฐํ•จ์ด ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค.

โœจ ์‹  ๋ฒ„์ „ (Advanced Paradigm - CR_egregore_jax_test_v2.py)

[EN]

  • Implementation: Implanted the algebraic sign synchronization formulation rigorously proved in (PJHkorea/egregore-core-jax/README_OPTIMIZERS.md) directly into the core segment.
  • Improvement: Reconstructs pristine, original AdamW LLRD specifications directly on accelerator memory layout without triggering any momentum vector distortions.

[KR]

  • ๊ตฌํ˜„ ๋ฐฉ์‹: (PJHkorea/egregore-core-jax/README_OPTIMIZERS.md)์— ์ฆ๋ช…๋œ ๋Œ€์ˆ˜์  ๋ถ€ํ˜ธ ํ•ฉ์น˜ ๊ณต์‹์„ ์ฝ”์–ด ์„ธ๊ทธ๋จผํŠธ์— ์ด์‹ํ–ˆ์Šต๋‹ˆ๋‹ค.
  • ๊ฐœ์„  ํšจ๊ณผ: ๊ฐ€์†๊ธฐ ๋ฉ”๋ชจ๋ฆฌ์ƒ์—์„œ ๋ชจ๋ฉ˜ํ…€ ์™œ๊ณก ์—†์ด ์˜ค๋ฆฌ์ง€๋„ AdamW LLRD ๊ณต์‹ ๊ทœ๊ฒฉ์„ ์žฌํ˜„ํ•ฉ๋‹ˆ๋‹ค.

$$\text{Update} = (u \times \text{lr}) + (p \times \text{wd} \times \text{wd-activation-gate} \times \text{lr})$$

[EN]

  • $u$: Adam momentum update delta vector
  • $\text{lr}$: Layer-wise Learning Rate Decay (LLRD) scaler
  • $p$: Current weight parameter tensor
  • $\text{wd}$: Weight decay coefficient

[KR]

  • $u$: Adam ๋ชจ๋ฉ˜ํ…€ ์—…๋ฐ์ดํŠธ ๋ฒกํ„ฐ
  • $\text{lr}$: ๊ณ„์ธต๋ณ„ ์ฐจ๋“ฑ ํ•™์Šต๋ฅ  (LLRD)
  • $p$: ํ˜„์žฌ ๊ฐ€์ค‘์น˜ ๋งค๊ฐœ๋ณ€์ˆ˜ (Parameter)
  • $\text{wd}$: ๊ฐ€์ค‘์น˜ ๊ฐ์‡  ๊ณ„์ˆ˜ (Weight Decay)

๐Ÿ’ก Computational Sign Synchronization Spec (Supplementary)

[EN] The raw updates ($u$) vector returned by the underlying optax.adam backend natively incorporates the Negative Gradient Direction so it can be directly integrated via parameter addition (params = params + updates). Therefore, to achieve seamless synchronization with the negative scaling trajectory of the Weight Decay componentโ€”which physically shrinks parameter magnitudeโ€”coupling the two components via algebraic addition ($+$) instead of subtraction ($-$) is the mathematically and numerically accurate implementation.

[KR] optax.adam ๋ฐฑ์—”๋“œ๊ฐ€ ์ž์ฒด ์—ฐ์‚ฐ์„ ๊ฑฐ์ณ ๋ฐ˜ํ™˜ํ•˜๋Š” updates ($u$) ๋ฒกํ„ฐ๋Š” ๊ฐ€์ค‘์น˜์— ๋ฐ”๋กœ ๋”ํ•ด์งˆ ์ˆ˜ ์žˆ๋„๋ก ์ด๋ฏธ **์Œ์ˆ˜ ๋ณ€์œ„ ๋ฐฉํ–ฅ์„ฑ(Negative Gradient Direction)**์ด ๋‚ด์žฅ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ ๊ฐ€์ค‘์น˜๋ฅผ ๋ฌผ๋ฆฌ์ ์œผ๋กœ ์ค„์—ฌ์•ผ ํ•˜๋Š” Weight Decay ์„ฑ๋ถ„์˜ ์Œ์ˆ˜ ์Šค์ผ€์ผ๋ง ๋ฐฉํ–ฅ๊ณผ ๋ฌด๊ฒฐํ•˜๊ฒŒ ๋™๊ธฐํ™”ํ•˜๊ธฐ ์œ„ํ•ด ๋Œ€์ˆ˜ํ•™์ ์œผ๋กœ ๋นผ๊ธฐ($-$)๊ฐ€ ์•„๋‹Œ ๋”ํ•˜๊ธฐ($+$) ๊ธฐํ˜ธ๋กœ ๊ฒฐํ•ฉํ•˜๋Š” ๊ฒƒ์ด ์ˆ˜์น˜ํ•ด์„์ ์œผ๋กœ ์™„์ „ํžˆ ์˜ฌ๋ฐ”๋ฅธ ๊ตฌํ˜„์ž…๋‹ˆ๋‹ค.


3. ํ˜ธ์ŠคํŠธ ๋ฉ”๋ชจ๋ฆฌ ์ธํ”„๋ผ: ์ค‘๋ณต ํŠธ๋ ˆ์ด์‹ฑ ๋ฐ ํƒ€์ž… ํฌ๋ž˜์‹œ ์ œ๋กœํ™” (Host Memory Infrastructure: Zero Tracing Overhead & Type Safety)

โŒ ๊ตฌ ๋ฒ„์ „ (Conventional Baseline - CR_egregore_jax_test.py)

[EN]

  • Implementation: Relied on heavy and complex hyperparameter conditional routing logic due to the lack of an embedded, standardized LLRD scaling mechanism.
  • Flaw: Exponentially inflated static tracing overhead over the host CPU when compiling large-scale deep learning models.

[KR]

  • ๊ตฌํ˜„ ๋ฐฉ์‹: LLRD ์Šค์ผ€์ผ๋Ÿฌ ์ž์ฒด๊ฐ€ ๋‚ด์žฅ๋˜์–ด ์žˆ์ง€ ์•Š์•„ ๋ณต์žกํ•œ ํ•˜์ดํผํŒŒ๋ผ๋ฏธํ„ฐ ๋ถ„๊ธฐ ๋กœ์ง์— ์˜์กดํ–ˆ์Šต๋‹ˆ๋‹ค.
  • ๋ฌธ์ œ์ : ๊ฑฐ๋Œ€ ๋ชจ๋ธ ์ปดํŒŒ์ผ ์‹œ ํ˜ธ์ŠคํŠธ CPU์˜ ์ •์  ํŠธ๋ ˆ์ด์‹ฑ ์˜ค๋ฒ„ํ—ค๋“œ๊ฐ€ ๊ธ‰์ฆํ–ˆ์Šต๋‹ˆ๋‹ค.

โœจ ์‹  ๋ฒ„์ „ (Advanced Paradigm - CR_egregore_jax_test_v2.py)

[EN]

  • Implementation: Structurally compressed and restricted the tree_flatten_with_path invocation to exactly a Single-Pass (1 Time) execution sequence inside the scheduler loop.
  • Mechanism: Established a high-density [LEAF-LEVEL TENSOR RECONSTRUCTION] pipeline that pairs lightweight mapped_scalars with original leaf weights (v) via zip primitives for deferred device-level tensor allocations.
  • Improvement: Computationally purged host-side CPU memory leaks and eliminated catastrophic Host OOM (Out-Of-Memory) Crashes during massive LLM and MoE model compilation phases.

[KR]

  • ๊ตฌํ˜„ ๋ฐฉ์‹: tree_flatten_with_path ํ˜ธ์ถœ์„ ์Šค์ผ€์ค„๋Ÿฌ ๋ฃจํ”„ ๋‚ด์—์„œ ์ •ํ™•ํžˆ ๋‹จ 1ํšŒ๋กœ ํ•œ๊ณ„ ์ˆ˜์ถ•ํ–ˆ์Šต๋‹ˆ๋‹ค.
  • ๊ธฐ๋ฏน ๋„์ž…: mapped_scalars์™€ ์›๋ณธ ๋ฆฌํ”„ ๊ฐ€์ค‘์น˜ v๋ฅผ zip์œผ๋กœ ๋ฌถ์–ด ํ…์„œ๋ฅผ ์‚ฌํ›„ ํ™•์žฅํ•˜๋Š” [LEAF-LEVEL TENSOR RECONSTRUCTION] ๋งค์ปค๋‹ˆ์ฆ˜์„ ์ •์ฐฉ์‹œ์ผฐ์Šต๋‹ˆ๋‹ค.
  • ๊ฐœ์„  ํšจ๊ณผ: ๊ฑฐ๋Œ€ LLM/MoE ๋ชจ๋ธ ์ปดํŒŒ์ผ ์‹œ ๋ฐœ์ƒํ•˜๋˜ ํ˜ธ์ŠคํŠธ CPU์˜ ๋ฉ”๋ชจ๋ฆฌ ๋ˆ„์ˆ˜ ๋ฐ Host OOM(Out-Of-Memory) ํฌ๋ž˜์‹œ๋ฅผ ์ „์‚ฐํ•™์ ์œผ๋กœ ํ•ด๊ฒฐํ–ˆ์Šต๋‹ˆ๋‹ค.

๐Ÿ“Š Architecture Summary & Metric Comparison

Evaluation Metric Baseline (CR_egregore_jax_test.py) Advanced Paradigm (CR_egregore_jax_test_v2.py) Architectural Impact
Optimizer Topology optax.multi_transform (Physical Branching) Single optax.adam + Inline Masking Compilation Graph Optimization
XLA Kernel Footprint Fragmented instruction routing paths Single Fused Kernel (Force-Fused) Zero Hardware Branch Stalls
Mathematical Precision Inherent momentum dynamics distortion 100% Exact AdamW LLRD Formulation Algebraic Sign Synchronization ($+$)
Host Compilation Stability Redundant tracing & Host OOM vulnerability Single-Pass Squeeze & Leaf-Level Reconstruction Total Elimination of CPU Memory Leaks

๐Ÿš€ ์˜ˆ์ƒ๋˜๋Š” ์‹œ์Šคํ…œ์  ์ด์  (Expected Architectural Benefits)

1. Optimizer Overhead Minimization (Up to 1.6x+ Speedup)

[EN]

  • v1 (optax.multi_transform): Navigating the parameter PyTree to separate backbone and gate nodes caused the XLA compiler to generate fragmented sub-graphs and induced repetitive host-interpreter interventions. This accumulated severe scheduling latency and device-level kernel launch overheads.
  • v2 (Silicon MUX Engine): Integrates the entire routing mechanics into a single, unified mathematical equation graph. By leveraging the pre-baked lr_mask_tree and wd_mask_tree, parameter updates are finalized inside a single-cycle Hadamard tensor product kernel. This thoroughly obliterates host-device synchronization bottlenecks, drastically shrinking optimizer execution time.

[KR]

  • v1 (optax.multi_transform): ํŒŒ๋ผ๋ฏธํ„ฐ ํŠธ๋ฆฌ๋ฅผ ์ˆœํšŒํ•˜๋ฉฐ backbone๊ณผ gate ๋…ธ๋“œ๋ฅผ ๋ถ„๊ธฐํ•  ๋•Œ, XLA๋Š” ๋‚ด๋ถ€์ ์œผ๋กœ ๋ถ„ํŒŒ๋œ ๊ฐ€์ƒ ์„œ๋ธŒ ๊ทธ๋ž˜ํ”„(Sub-graphs)๋“ค์„ ์ƒ์„ฑํ•˜๊ฑฐ๋‚˜ ํ˜ธ์ŠคํŠธ(Host) ์ธํ„ฐํ”„๋ฆฌํ„ฐ์˜ ๊ฐœ์ž…์„ ์œ ๋ฐœํ•ฉ๋‹ˆ๋‹ค. ์ด๋กœ ์ธํ•ด ๋””๋ฐ”์ด์Šค ์Šค์ผ€์ค„๋ง ๋ฐ ์ปค๋„ ๋Ÿฐ์น˜(Kernel Launch) ์˜ค๋ฒ„ํ—ค๋“œ๊ฐ€ ๋ˆ„์ ๋ฉ๋‹ˆ๋‹ค.
  • v2 (์‹ค๋ฆฌ์ฝ˜ MUX ์—”์ง„): ๋‹จ ํ•˜๋‚˜์˜ ๊ฑฐ๋Œ€ํ•œ ํ†ต์ผ๋œ ์ˆ˜์‹ ๊ทธ๋ž˜ํ”„๋กœ ํ†ตํ•ฉ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์ด๋ฏธ ์ƒ์„ฑ๋œ lr_mask_tree์™€ wd_mask_tree๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ๋‹จ ํ•œ ๋ฒˆ์˜ ์•„๋‹ค๋งˆ๋ฅด ํ–‰๋ ฌ๊ณฑ ์ปค๋„ ์•ˆ์—์„œ ๊ฐ€์ค‘์น˜ ์—…๋ฐ์ดํŠธ๊ฐ€ ๋๋‚ฉ๋‹ˆ๋‹ค. ํ˜ธ์ŠคํŠธ-๋””๋ฐ”์ด์Šค ๊ฐ„ ๋™๊ธฐํ™” ๋ณ‘๋ชฉ์ด ์™„์ „ํžˆ ๊ฑฐ์„ธ๋˜์–ด ์˜ตํ‹ฐ๋งˆ์ด์ € ๊ฐ€๋™ ์‹œ๊ฐ„์ด ํš๊ธฐ์ ์œผ๋กœ ๋‹จ์ถ•๋ฉ๋‹ˆ๋‹ค.

2. Elimination of String Manipulation Overheads (Pure FP32 Register Mixing)

[EN]

  • v1 (String-Product Algebraic Masking): Although v1 avoided conditional branches via string product masking ("gate" * (root_key_name == "gate")), it still relied heavily on string manipulation, variable-length text allocations, and dynamic sequence evaluation at the host-compiler boundary. This prevented the XLA compiler from achieving full register-level inline numerical scaling.
  • v2 (Pure FP32 Register MUX): Converts matching predicates directly into accelerator-native floating-point literals via is_gate = (root_key_name == "gate") * jnp.float32(1.0). By completely extinguishing string data execution footprints, the instruction stream forces the accelerator ALU to perform raw, single-cycle algebraic mixing over steady 32-bit register rails, maximizing raw silicon computing efficiency.

[KR]

  • v1 (๋ฌธ์ž์—ด ๊ณฑ์…ˆ ๋Œ€์ˆ˜ ๋งˆ์Šคํ‚น): ๊ตฌ ๋ฒ„์ „ ์—ญ์‹œ "gate" * (root_key_name == "gate") ์™€ ๊ฐ™์€ ๋ฌธ์ž์—ด ๊ณฑ์…ˆ ๊ธฐ๋ฏน์„ ํ†ตํ•ด ๋Ÿฐํƒ€์ž„ if/else ๋ถ„๊ธฐ๋ฌธ์€ ํšŒํ”ผํ–ˆ์œผ๋‚˜, ์—ฌ์ „ํžˆ ๋ฌธ์ž์—ด ๋ฐ์ดํ„ฐ์˜ ๋™์  ๋ฉ”๋ชจ๋ฆฌ ํ• ๋‹น๊ณผ ํ…์ŠคํŠธ ์‹œํ€€์Šค ์—ฐ์‚ฐ ์˜ค๋ฒ„ํ—ค๋“œ๊ฐ€ ์ปดํŒŒ์ผ๋Ÿฌ ๊ฒฝ๊ณ„๋ฉด์— ์ž”์กดํ•˜์—ฌ ์™„์ „ํ•œ ์ˆ˜์น˜ ํ•ด์„์  ์ธ๋ผ์ธํ™”๋ฅผ ๋‹ฌ์„ฑํ•˜์ง€ ๋ชปํ–ˆ์Šต๋‹ˆ๋‹ค.
  • v2 (์ˆœ์ˆ˜ FP32 ๋ ˆ์ง€์Šคํ„ฐ MUX): ์ผ์น˜ ์—ฌ๋ถ€ ํŒ์ • ๊ฒฐ๊ณผ๋ฅผ is_gate = (root_key_name == "gate") * jnp.float32(1.0) ์™€ ๊ฐ™์ด ๊ฐ€์†๊ธฐ ๋„ค์ดํ‹ฐ๋ธŒ ๋ถ€๋™์†Œ์ˆ˜์  ๋ฆฌํ„ฐ๋Ÿด ๋งˆ์Šคํฌ๋กœ ์ฆ‰์‹œ ์ˆ˜์ถ•์‹œ์ผฐ์Šต๋‹ˆ๋‹ค. ๋ฌธ์ž์—ด ์—ฐ์‚ฐ์˜ ํ”์ ์„ ์ „์‚ฐ๋ง์—์„œ ์™„๋ฒฝํžˆ ๋ฐ•๋ฉธํ•จ์œผ๋กœ์จ, ๊ฐ€์†๊ธฐ ALU๊ฐ€ 32๋น„ํŠธ ๋ ˆ์ง€์Šคํ„ฐ ๋ ˆ์ผ ์œ„์—์„œ ๋‹จ 1ํด๋Ÿญ์˜ ์ง€์—ฐ๋„ ์—†์ด ์ˆœ์ˆ˜ ๋ถ€๋™์†Œ์ˆ˜์  ๋Œ€์ˆ˜ ์—ฐ์‚ฐ๋งŒ์œผ๋กœ ์ฐจ๋“ฑ ๊ฐ€์ค‘์น˜ ์—…๋ฐ์ดํŠธ๋ฅผ ์ง‘ํ–‰ํ•˜๋„๋ก ํ•˜๋“œ์›จ์–ด ๋ฐ€์ฐฉํ˜• ์ตœ์ ํ™”๋ฅผ ์™„์„ฑํ–ˆ์Šต๋‹ˆ๋‹ค.

3. On-Chip Memory (SRAM) Efficiency & Gradient Guarding

[EN]

  • Aggressive Kernel Fusion: By purging explicit jnp.where conditional blocks and organically coupling XLA-native hardware primitives (jnp.sign, jnp.reciprocal, jnp.einsum), the XLA compiler executes highly aggressive 'Kernel Fusion'. Intermediate tensors are immediately consumed inside high-speed on-chip registers/SRAM instead of being redundantly read/written over the high-latency global memory (VRAM) bus.
  • Lazy Evaluation Contamination Shielding: Explicitly seals every telemetry metric and loss artifact with jax.lax.stop_gradient. This systematically cuts off unreferenced backpropagation computational graphs from permanently occupying device memory, preventing HBM leakage. It dramatically expands the system threshold when handling ultra-large batch configurations or high-dimensional latent space layers without triggering OOM (Out of Memory) exceptions.

[KR]

  • ๊ณต๊ฒฉ์  ์ปค๋„ ์œตํ•ฉ (Kernel Fusion): jnp.where ์กฐ๊ฑด์‹ ๋ถ„๊ธฐ๋ฅผ ์ง€์šฐ๊ณ  XLA ์ „์šฉ ํ”„๋ฆฌ๋ฏธํ‹ฐ๋ธŒ์ธ jnp.sign, jnp.reciprocal, jnp.einsum ๋“ฑ์„ ์œ ๊ธฐ์ ์œผ๋กœ ์—ฐ๊ฒฐํ–ˆ์Šต๋‹ˆ๋‹ค. ์ด ๋•๋ถ„์— XLA ์ปดํŒŒ์ผ๋Ÿฌ๋Š” ์ค‘๊ฐ„ ํ…์„œ(Intermediate Tensors)๋“ค์„ ๊ธ€๋กœ๋ฒŒ ๋ฉ”๋ชจ๋ฆฌ(VRAM)์— ์ผ๋‹ค ์ฝ์ง€ ์•Š๊ณ , ๊ณ ์† ์˜จ์นฉ ๋ ˆ์ง€์Šคํ„ฐ/SRAM ์•ˆ์—์„œ ์—ฐ์‚ฐ์„ ๋ฌถ์–ด ์ฒ˜๋ฆฌํ•˜๋Š” '์ปค๋„ ์œตํ•ฉ'์„ ํ›จ์”ฌ ๊ณต๊ฒฉ์ ์œผ๋กœ ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค.
  • ์ง€์—ฐ ํ‰๊ฐ€(Lazy Evaluation) ์˜ค์—ผ ๋ฐฉ์ง€: ๊ฐ ๋ฉ”ํŠธ๋ฆญ๊ณผ ์†์‹ค ํ•จ์ˆ˜ ์•„ํ‹ฐํŒฉํŠธ๋งˆ๋‹ค jax.lax.stop_gradient๋ฅผ ๊ผผ๊ผผํ•˜๊ฒŒ ๋ฐฐ์น˜ํ•˜์—ฌ, ๋ถˆํ•„์š”ํ•œ ์—ญ์ „ํŒŒ ๋ฏธ๋ถ„ ๊ทธ๋ž˜ํ”„๊ฐ€ ๊ฐ€์†๊ธฐ ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ์ ์œ ํ•˜๊ณ  ์žˆ๋Š” ํ˜„์ƒ(๋ฉ”๋ชจ๋ฆฌ ๋ˆ„์ˆ˜ ๋ฐ HBM ๊ณ ๊ฐˆ)์„ ์›์ฒœ ์ฐจ๋‹จํ–ˆ์Šต๋‹ˆ๋‹ค. ๋ฐฐ์น˜ ํฌ๊ธฐ๋ฅผ ๋” ํ‚ค์šฐ๊ฑฐ๋‚˜ ์ดˆ๊ณ ์ฐจ์› latent ์—ฐ์‚ฐ์„ ์ˆ˜ํ–‰ํ•  ๋•Œ OOM ๋ฐœ์ƒ ํ™•๋ฅ ์„ ํฌ๊ฒŒ ๋‚ฎ์ถฐ์ค๋‹ˆ๋‹ค.

โš– License

  • This project is governed by the GPLv3 License. Derivative models, framework re-engineering fork scripts, and computational extensions of identical architecture cannot be made proprietary; they must be fully disclosed and distributed to the public under the exact same open-source licensing terms.

About

Topological Manifold Control: A multi-paradigm (PyTorch/JAX) geometric morphing engine utilizing differentiable soft-gating, optimized via XLA fused kernels and autograd-isolated non-blocking pipelines.

Topics

Resources

License

Stars

4 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors

Languages