Lightning-AI / Lightning-AI/litData
The config isn't consistent between chunks
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 614
- Forks
- 106
- Avg merge
- 15h 8m
- Merged PRs (30d)
- 22
Description
I was processing large files and received the following error. It failed at around ~80% of the data after about ~1h 20min. The full error is really long, but this is the beginning of it. I'm essentially storing 5 columns where the type of each column is a numpy array. Arrays are of variable length.
## 🐛 Bug
```
File "/root/.nextflow-bin/litdata_dataset.py", line 91, in
main(
File "/root/.nextflow-bin/litdata_dataset.py", line 37, in main
ld.optimize(
File "/usr/local/lib/python3.12/site-packages/litdata/processing/functions.py", line 445, in optimize
data_processor.run(
File "/usr/local/lib/python3.12/site-packages/litdata/processing/data_processor.py", line 1134, in run
result = data_recipe._done(len(user_items), self.delete_cached_files, self.output_dir)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/litdata/processing/data_processor.py", line 802, in _done
merge_cache._merge_no_wait(node_rank if num_nodes > 1 else None, getattr(self, "existing_index", None))
File "/usr/local/lib/python3.12/site-packages/litdata/streaming/cache.py", line 156, in _merge_no_wait
self._writer._merge_no_wait(node_rank=node_rank, existing_index=existing_index)
File "/usr/local/lib/python3.12/site-packages/litdata/streaming/writer.py", line 470, in _merge_no_wait
raise Exception(
Exception: The config isn't consistent between chunks. This shouldn't have happened.Found {'chunk_bytes': 64000000, 'chunk_size': None, 'compression': 'zstd', 'data_format': ['int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int'], 'data_spec': '[1, {"type": "builtins.dict", "context": "[\\"input_ids\\", \\"chromosome_idx\\", \\"pos_in_chr_ones\\",...
```
### To Reproduce
Unfortunately I'm not sure how to show how to reproduce without sharing ~100gb dataset.
Code sample
```python
def get_data_from_file_row_group(group):
"""
Concurrency safe batch samples from parquet row groups.
"""
file_path, row_group = group
with pq.ParquetFile(file_path) as pf:
yield from pf.read_row_groups([row_group]).to_pylist()
def get_data_from_file_row_group(group):
"""
Concurrency safe batch samples from parquet row groups.
"""
file_path, row_group = group
with pq.ParquetFile(file_path) as pf:
yield from pf.read_row_groups([row_group]).to_pylist()
file_paths = glob.glob(f"{input_dir}/*.parquet")
groups = generate_file_row_groups(file_paths)
ld.optimize(
fn=get_data_from_file_row_group,
inputs=groups,
chunk_bytes="64MB",
num_workers=num_workers,
output_dir=f"./output/{dir_prefix}",
compression="zstd",
)
```
### Additional context
Environment detail
- PyTorch Version: 2.4.1
- OS (e.g., Linux): Debian 11
- Lit data version: 0.2.26
- Python version: 3.10
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the optimize call and the reported merge path in litdata/processing/data_processor.py and litdata/streaming/writer.py, especially _merge_no_wait. Reproduce the inconsistent chunk configuration with a smaller dataset or focused fixture; done means identifying why chunks differ and confirming that the merge completes consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data-engineering
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 32/100