Repository navigation
[data][train] Mid-epoch resumption (4/n): Support generated ID columns - #66800
Merged
goutamvenkat-anyscale merged 2 commits intoOct 31, 2026
Conversation
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
justinvyu
force-pushed
the
justinvyu/generated-id-mid-epoch-resume
branch
2 times, most recently
from
October 7, 2026 17:27
35ffbc4 to
3030e3e
Compare
|
This pull request has been automatically marked as stale because it has not had You can always ask for help on our discussion forum or Ray's public slack channel. If you'd like to keep this open, just leave any comment, and the stale label will be removed. |
JasonLi1909
approved these changes
Oct 23, 2026
goutamvenkat-anyscale
added a commit
that referenced
this pull request
Oct 23, 2026
…() (#67157) ## Description `CheckpointConfig(generated_id_column=...)` can be set on a dataset after `read_parquet()` built it — Ray Train's `DatasetManager` does exactly this (see #66800). Previously `read_parquet()` snapshotted the config at call time and baked the generated ID column into the datasource constructor, so a config set afterwards never produced the column and checkpointing silently recorded nothing. This PR moves the binding to plan time: - New logical rule `BindGeneratedIdColumn`, run in `LogicalOptimizer._post_optimize` (after the rule loop, before `DeriveListFilesPushdown`): adds the column to the `ParquetScanner` and to `Project`s built before the config was set. - `read_parquet()` no longer binds the column; its call-time config snapshot and the `_add_generated_id_column` / `extra_synthesized_columns` plumbing are removed. - `_validate_generated_id_plan` now runs on every generated-ID plan and fails at planning if a scanner is missing the column. - `schema()` / `columns()` agree with execution: `_base_schema` applies `BindGeneratedIdColumn` when the configured column is missing from its answer (metadata is inferred from the unoptimized DAG, which doesn't run the rule), including over a schema cached before the config was set. ID *values* are unchanged (`GeneratedIdColumn.compute()` in the read tasks); only where the column attaches to the plan moved. ### Why plan time: who knows what, when This change exists for Ray Train's mid-epoch resumption (#66800): there, `DatasetManager` derives the `CheckpointConfig` from fit-time state — the restored `state_dict` and its restore filter — and stamps it onto the user's already-built dataset. That config cannot exist yet when the user calls `read_parquet()`, and since each dataset snapshots its own `DataContext` at build time, setting it globally afterwards would never reach an already-built dataset either. The only ordering that works is the one #66800 uses — stamp the built dataset — with Ray Data picking the config up when the executed plan is optimized: ```mermaid sequenceDiagram participant U as user code participant T as Ray Train (DatasetManager) participant D as dataset's DataContext / plan U->>D: ds = ray.data.read_parquet(...) Note over D: DataContext.copy() snapshot — checkpoint_config: None U->>T: trainer.fit(datasets={"train": ds}) rect rgba(66, 135, 245, 0.25) T->>T: rank 0 requests its shard: get_dataset_shard("train", state_dict=...) T->>D: ds.context.checkpoint_config = CheckpointConfig(generated_id_column=..., restore filter) end rect rgba(235, 140, 60, 0.3) loop each epoch D->>D: optimize plan — BindGeneratedIdColumn binds the column — then execute end end ``` 🟦 Train's mid-epoch-resume wiring (PR 66800) · 🟧 this PR (plan-time binding) · unshaded steps are pre-existing behavior. ### New flow ```mermaid flowchart TB subgraph build["Dataset build (lazy)"] RP["read_parquet()<br/>builds ListFiles → ReadFiles<br/><i>no column decision</i>"] CFG["ds.context.checkpoint_config = CheckpointConfig(generated_id_column=...)<br/><i>at any point before execution</i>"] end subgraph opt["Execution: LogicalOptimizer"] LOOP["Ruleset loop<br/>(projection pushdown, ...)"] BIND["<b>BindGeneratedIdColumn</b><br/>reads plan.context.checkpoint_config,<br/>appends GeneratedIdColumn to the ParquetScanner,<br/>keeps it through earlier-built Projects"] DLP["DeriveListFilesPushdown<br/>listing sees the bound projection"] end subgraph plan["Planner"] VAL["_validate_generated_id_plan<br/>every source is a V2 Parquet read<br/><b>and carries the column</b>, else<br/>InvalidCheckpointingConfig at planning"] end subgraph exec["Read tasks"] COMPUTE["GeneratedIdColumn.compute()<br/>stamps (file, row group, row offset)<br/>per batch — unchanged"] end RP --> CFG --> LOOP --> BIND --> DLP --> VAL --> COMPUTE ``` ## Testing ``` pytest python/ray/data/tests/unit/datasource_v2/test_bind_generated_id_column.py \ python/ray/data/tests/unit/datasource_v2/test_generated_id_column.py # 22 passed cd python/ray/data/tests && pytest test_checkpoint.py -k "generated_id" # 26 passed (includes new tests: config set after the dataset is built, with # select_columns / with_column / streaming_split, and plan-validation failures) ``` ## Notes - Not a duplicate: no open PR binds the generated ID column at plan time. #66800 (Train mid-epoch resumption) is a consumer of this behavior, not an implementation of it; coordinated with that stack. - AI assistance was used for this PR. I reviewed every changed line and ran the tests above locally. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Goutam <[email protected]> Co-authored-by: Claude Fable 5 <[email protected]>
goutamvenkat-anyscale
pushed a commit
that referenced
this pull request
Oct 31, 2026
…mark (#66680) > Stacked on #66562 (and #66563). Only review the last commit: "[Train] Add mid-epoch resumption release test". ## Description Adds a nightly release test for mid-epoch resumption with data iterator checkpointing: `mid_epoch_resume_benchmark_{10M,3B}`. `release/train_tests/mid_epoch_resume_benchmark/microbenchmark.py` runs a `TorchTrainer` with 16 mock-GPU workers over a Parquet dataset of 10M or 3B rows, using `DataConfig(dataset_checkpoint_configs={"train": DatasetCheckpointConfig(id_column="id", ...)})`. - It saves a data checkpoint with `DataIterator.state_dict()` every `checkpoint_interval` batches and at the end of each epoch, and stores it in the Ray Train checkpoint. - It injects a failure 90% of the way through the epoch (`--error_at=0.9`) and resumes from the latest checkpoint with `ray.train.get_dataset_shard("train", state_dict=...)`. - **Correctness:** after training, it checks that each epoch's checkpoint files cover exactly `total_dataset_rows` rows, so every row is seen exactly once per epoch, even across the restart. - **Performance:** it reports the total duration and the time to first batch with and without a data checkpoint, which includes the checkpoint load time. Release test config: - One test entry with a `scale` matrix (`10M`, `3B`), nightly, `byod: gpu`, `anyscale_sdk_2026: true`, and a 2700s timeout. - Compute configs (`compute_configs/{10M,3B}.yaml`): an `m5.2xlarge` head node with no CPUs, plus 10 or 50 `m5.8xlarge` workers with `MOCK_GPU: 4` and a 64 GB object store. - `--generate_id_column` is supported by the script but not passed, since `DatasetCheckpointConfig(generate_id_column=True)` isn't implemented yet (it depends on #65885–#65888). ## Related issues Not a duplicate: there's no existing release test for data iterator checkpointing or mid-epoch resumption. Generated ID column support (and `--generate_id_column` in this release test) is stacked on this PR: #66800 ## Additional information Testing: - `pre-commit run` on the changed files: passed. - The release test itself hasn't been run yet. I'll trigger it before marking this ready. AI assistance (Claude Code) was used to develop this change. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: Justin Yu <[email protected]>
goutamvenkat-anyscale
force-pushed
the
justinvyu/generated-id-mid-epoch-resume
branch
from
October 31, 2026 02:58
3030e3e to
d567ad5
Compare
Signed-off-by: Justin Yu <[email protected]>
goutamvenkat-anyscale
force-pushed
the
justinvyu/generated-id-mid-epoch-resume
branch
from
October 31, 2026 03:00
d567ad5 to
1866524
Compare
goutamvenkat-anyscale
marked this pull request as ready for review
October 31, 2026 03:02
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
goutamvenkat-anyscale
approved these changes
Oct 31, 2026
… unbound-name Signed-off-by: Goutam <[email protected]>
goutamvenkat-anyscale
enabled auto-merge (squash)
October 31, 2026 03:41
JasonLi1909
approved these changes
Oct 31, 2026
sai-miduthuri
approved these changes
Oct 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds
DatasetCheckpointConfig(generate_id_column=True)for mid-epoch resumption. Users whose datasets have no unique ID column can then checkpoint the data iterator with row IDs that Ray Data generates from each row's location in its Parquet file.Changes:
DatasetCheckpointConfig:generate_id_column=Trueno longer raisesNotImplementedError. Only Parquet reads on the V2 datasource path are supported.CheckpointingBatchIterator: when the ID column is generated, it's recorded inBatchMetadata.row_idsfor checkpointing, then removed from the batch before it's yielded, so users only see their own columns. A user-providedid_columnis kept.DatasetManager._build_restoration_checkpoint_config: builds the dataset'sCheckpointConfigwithgenerated_id_column=instead ofid_column=when generating. The config is set even when there's nothing to restore, because the reader needs it to generate the ID column.mid_epoch_resume_benchmark_{{scale}}passes--generate_id_column.Related issues
Not a duplicate: this adds Train-ingest support on top of the generated-ID checkpointing stack (#66732, #66733, #66736), which covers batch inference only.
Additional information
Tests (run locally, Python 3.11, macOS):
pytest python/ray/data/tests/test_data_iterator_checkpointer.py: 25 passed. This includes the newtest_generated_id_column_removed_from_batches, which checks that the column is removed from batches when generated and kept otherwise, and that the IDs are checkpointed either way.RAY_TRAIN_V2_ENABLED=1 pytest python/ray/train/v2/tests/test_dataset_checkpointing.py python/ray/train/v2/tests/test_dataset_manager.py:TypeError: CheckpointConfig.__init__() got an unexpected keyword argument 'generated_id_column', because that argument comes from [Data][Chkpt] [1/4] Addgenerated_id_columncheckpointing: row IDs as a DSv2 synthesized column #66732. This is expected until [Data][Chkpt] [1/4] Addgenerated_id_columncheckpointing: row IDs as a DSv2 synthesized column #66732 lands.generated_id_column=Noneparameter onCheckpointConfig(not committed): 12 passed. The only 2 failures were the twogenerate_id_column=Truee2e cases, which need the generated-ID reader support from that stack.pre-commit runon the changed files: passed.AI assistance (Claude Code) was used to develop this change.
🤖 Generated with Claude Code