Skip to content

v2: bars-rbm (CD-1) vs bars (wake-sleep) ByteDMD total cost comparison#60

Open
SethTS wants to merge 1 commit into
cybertronai:mainfrom
SethTS:v2/bars-cost-comparison
Open

v2: bars-rbm (CD-1) vs bars (wake-sleep) ByteDMD total cost comparison#60
SethTS wants to merge 1 commit into
cybertronai:mainfrom
SethTS:v2/bars-cost-comparison

Conversation

@SethTS
Copy link
Copy Markdown
Contributor

@SethTS SethTS commented May 11, 2026

Summary

Second algorithm pair in the v2-bytedmd measurement series, following the contract established in total_cost_comparison.py.

  • New file: v2-bytedmd/bars_cost_comparison.py — pure-Python kernels for bars-rbm CD-1 and bars Helmholtz wake-sleep, with ByteDMD per-step measurement and convergence counting
  • Updated: v2-bytedmd/validate_implementations.py — 7 new validation checks for the new kernels
  • Updated: v2-bytedmd/README.md — documents the second comparison and its verified results

Findings (verified 2026-05-11)

Per single-sample step:
  bars-rbm  CD-1  (W: 16×8 = 128 weights)   total:  6,928   2nd-pass: 2.18x
  bars wake-sleep (gen+rec: 306 weights)      total: 13,810   wake-sleep/recog: 6.18x

Convergence to 7/8 bars covered, 10 seeds:
  bars-rbm  CD-1 : 9/10 solved, median   30,000 samples
  bars wake-sleep: 3/10 solved, median  300,000 samples

Total ByteDMD to reference criterion:
  bars-rbm  CD-1 :    207,840,000
  bars wake-sleep:  4,143,000,000  (19.9x bars-rbm)

Wake-sleep costs ~20× more total data movement than CD-1 — driven by both ~2× higher per-step cost and ~10× more samples to converge.

Notes

  • Reference criterion is 7/8 bars covered (not 8/8): with n_hidden=8, the RBM rarely achieves perfect coverage due to duplicate detectors; 7/8 is reached by 9/10 seeds
  • The two stubs use different data distributions (independent bars for bars-rbm, hierarchical for bars Helmholtz), noted in the script header; per-step ByteDMD costs are distribution-independent and fully valid
  • wake-sleep convergence is highly stochastic: lr=0.1 used (vs CLI default 0.01 which rarely solves within 300K-step budget)

Test plan

  • python3 v2-bytedmd/validate_implementations.py passes all 14 checks (was 10)
  • python3 v2-bytedmd/bars_cost_comparison.py runs to completion and produces the output above

🤖 Generated with Claude Code

Adds bars_cost_comparison.py — the second algorithm pair in the v2-bytedmd
measurement series, following the contract established in total_cost_comparison.py.

Findings (verified 2026-05-11):
  Per single-sample step: CD-1 costs 6,928, wake-sleep costs 13,810 (2.0×)
  Convergence to 7/8 bars covered: CD-1 9/10 seeds at 30K samples median;
  wake-sleep 3/10 seeds at 300K samples median (lr=0.1; lr=0.01 rarely solves)
  Total ByteDMD: CD-1 208M vs wake-sleep 4.1B — 19.9× penalty

Also extends validate_implementations.py with 7 new checks for the
pure-Python CD-1 and Helmholtz recognition/generation kernels.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@0bserver07
Copy link
Copy Markdown
Contributor

Reviewed locally. Numbers reproduce: CD-1 = 6,928 ByteDMD/step, wake-sleep = 13,810 (ratio 1.99x), total cost 4.14B vs 208M = 19.9x. The 2x per-step is the architectural prediction (wake-sleep does both directions, CD-1 does one).

Follows Andy's v2-bytedmd/ measurement contract faithfully. Validation passes (26 array compares).

Two small nits, neither blocking:

  1. count_rbm_steps and count_helmholtz_steps docstrings say "8/8 bars covered" but code uses >= 7. Stale comment.
  2. The lr=0.1 override for Helmholtz (vs CLI default 0.01) deserves a sentence in the README about why default convergence is unreliable.

The 3/10 vs 9/10 solve rate is flagged in the PR body, good call.

Approving for merge.


agent-0bserver07 (Claude Code) on behalf of Yad

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.

2 participants