Skip to content

[Claude-led] Feature/training - #7

Draft
dougbrn wants to merge 5 commits into
devfrom
feature/training
Draft

dougbrn wants to merge 5 commits into
devfrom
feature/training

Conversation

@dougbrn

@dougbrn dougbrn commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator

Change Description

Training path from the initial design (§5–6). Stacked on the spec/collate PR; merge that first.

Solution Description

  • CatalogIterableDataset: streams collated batches from an LSDB catalog through lsdb's CatalogStream. Partitions are sharded across DDP ranks and DataLoader workers from a shared per-epoch permutation, so every row appears exactly once per epoch for any num_workers and world size. Batches never span a chunk; batch_size=None yields whole chunks. Supports epochs=N (reshuffled per epoch) and epochs=None (open-ended).
  • TrainSession: context-manager loop modeled on Hyrax's train_stream — iterate (batch, metrics), stop(), close() returns the model. Skips empty and below-min_batch_size batches; periodic and final atomic checkpoints (rank 0 only); resume_from; callbacks as the logging hook; DDP runs under model.join().
  • SupervisedStep covers loss + optimizer; any step(model, batch) -> metrics callable works, which is the seam for a future Hyrax backend.
  • Example: docs/examples/train_from_catalog.py.

Tests: no duplicated or dropped rows across workers and simulated ranks, epoch reshuffling and reproducibility, batches staying within chunks, empty partitions, distributed client path, session behaviour, and a real 2-process gloo DDP test with uneven batch counts.

🤖 Generated with Claude Code

dougbrn and others added 5 commits October 15, 2026 11:58
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ColumnSpec maps flat and nested catalog columns to tensors. resolve()
validates against catalog meta (nested sub-column dtypes come from
NestedDtype.column_dtypes) without computing data, and reports every
problem at once. Nested columns are padded to the batch maximum with a
mask and lengths, fully vectorized via nest.len() and nest.to_flat().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Partitions are sharded across DDP ranks and DataLoader workers from a
shared per-epoch permutation, so every row is read exactly once per
epoch for any worker count and world size. Each shard streams its
partitions through lsdb's CatalogStream; batches are cut within a chunk
and never span chunks. Supports fixed epochs and open-ended streaming.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Context-manager session modeled on Hyrax's train_stream: iterate
(batch, metrics), stop(), close() returns the model. The optimization
step is a user callable (SupervisedStep covers the common case).
Periodic and final atomic checkpoints, rank-0 only; DDP runs under
model.join() so uneven batch counts across ranks do not hang.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dougbrn
dougbrn changed the base branch from main to dev October 15, 2026 19:45
@codecov

codecov Bot commented Oct 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.38217% with 29 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.42%. Comparing base (c9ed114) to head (a500c30).

Files with missing lines Patch % Lines
src/lsdb_ml/spec.py 95.79% 9 Missing ⚠️
src/lsdb_ml/data/source.py 91.07% 5 Missing ⚠️
src/lsdb_ml/device.py 86.36% 3 Missing ⚠️
src/lsdb_ml/training/checkpoint.py 90.62% 3 Missing ⚠️
src/lsdb_ml/training/session.py 97.16% 3 Missing ⚠️
src/lsdb_ml/training/steps.py 91.17% 3 Missing ⚠️
src/lsdb_ml/collate.py 98.00% 1 Missing ⚠️
src/lsdb_ml/data/dataset.py 98.50% 1 Missing ⚠️
src/lsdb_ml/data/sharding.py 95.45% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##               dev       #7      +/-   ##
===========================================
- Coverage   100.00%   95.42%   -4.58%     
===========================================
  Files            2       14      +12     
  Lines            7      634     +627     
===========================================
+ Hits             7      605     +598     
- Misses           0       29      +29     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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