Skip to content

feat(data_classes): add BufferLog subclass and BufferAccessor#83

Merged
johnmarktaylor91 merged 1 commit intomainfrom
feat/buffer-log-subclass
Mar 2, 2026
Merged

feat(data_classes): add BufferLog subclass and BufferAccessor#83
johnmarktaylor91 merged 1 commit intomainfrom
feat/buffer-log-subclass

Conversation

@johnmarktaylor91
Copy link
Copy Markdown
Owner

Summary

  • BufferLog(TensorLog) subclass gives buffers a focused __repr__, name and module_address properties, while remaining full graph nodes (isinstance(buf, TensorLog) still True)
  • BufferAccessor provides ergonomic access via mh.buffers["addr"], mh.buffers[0], mh.buffers["running_mean"] — modeled on ParamAccessor
  • Scoped access via mh.modules["layer1.0.bn1"].buffers returns only that module's buffers
  • Fixes brittle type(node) == TensorLog checks in vis.py to use isinstance
  • Fixes TensorLog.copy() to preserve subclass type
  • Fixes cleanup.py property-before-callable check order

Test plan

  • All 385 tests pass (excluding real-world model tests)
  • isinstance(buffer, BufferLog) and isinstance(buffer, TensorLog) both True
  • BufferAccessor supports address, short name, and integer indexing
  • Scoped mh.modules[addr].buffers returns correct subset
  • Merged buffers (multi-pass BN) remain BufferLog instances
  • Graph participation preserved (parent_layers, child_layers)
  • Buffer repr sections added to aesthetic test reports (text + PDF)

…st-class buffer support

Buffers now get their own dedicated class (BufferLog) that subclasses TensorLog,
giving them focused repr, convenience properties (name, module_address), and
ergonomic access via BufferAccessor on both ModelLog and ModuleLog.

- BufferLog(TensorLog) subclass with clean __repr__ and computed properties
- BufferAccessor with indexing by address, short name, or ordinal position
- Scoped mh.modules["addr"].buffers for per-module buffer access
- Fix vis.py type(node) == TensorLog checks to use isinstance (supports subclasses)
- Fix TensorLog.copy() to preserve subclass type via type(self)(fields_dict)
- Fix cleanup.py property-before-callable check order to prevent AttributeError
- Add buffer repr sections to aesthetic test reports (text + PDF)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@johnmarktaylor91 johnmarktaylor91 merged commit 29e02e9 into main Mar 2, 2026
1 check passed
@johnmarktaylor91 johnmarktaylor91 deleted the feat/buffer-log-subclass branch March 2, 2026 19:02
johnmarktaylor91 added a commit that referenced this pull request Mar 4, 2026
- #95: fix mixed LayerLog/LayerPassLog format in vis module containment check
- #83: LayerLog.parent_layer_arg_locs returns strings (not sets) for consistency
- #99: warn on tensor shape mismatch in fast-path source tensor logging
- #23: add case-insensitive exact match and substring lookup for layers/modules
- #85: confirmed not-a-bug (any special arg correctly explains output invariance)
- #39, #41, #42: confirmed already fixed or correct as-is
- Add 6 regression tests for the above fixes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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