[speechm2] Support indexed sharegpt JSONL and webdataset formats#15410
[speechm2] Support indexed sharegpt JSONL and webdataset formats#15410
Conversation
Signed-off-by: Piotr Żelasko <petezor@gmail.com>
|
[🤖]: Hi @pzelasko 👋, We wanted to let you know that a CICD pipeline for this PR just finished successfully. So it might be time to merge this PR or get some approvals. |
tbartley94
left a comment
There was a problem hiding this comment.
Formatting and structural changes. General logic looks good though.
| shard_seed=config.shard_seed, | ||
| ) | ||
| ) | ||
| if not config.get("force_finite", False): |
There was a problem hiding this comment.
add quick comment for this flag (when going through dataloaders, we have a bit of a depth issue where the purpose of flags can get sidetracked.)
| ) | ||
| if not config.get("force_finite", False): | ||
| cuts = cuts.repeat(preserve_id=True) | ||
| return cuts, True |
There was a problem hiding this comment.
where do we need this bool for compatibility? curious if the same function can get achieved by just checking config
| bits += 1 | ||
| self._half = bits // 2 | ||
| self._mask = (1 << self._half) - 1 | ||
| self._rounds = 6 |
| left = (x >> self._half) & self._mask | ||
| right = x & self._mask | ||
| for key in self._keys: | ||
| left, right = right, left ^ (((right * 2654435761) ^ key) >> 32 & self._mask) |
There was a problem hiding this comment.
make global var at top of file.
| self._rounds = 6 | ||
| self._keys = [rng.getrandbits(64) for _ in range(self._rounds)] | ||
|
|
||
| def _permute_one(self, x: int) -> int: |
There was a problem hiding this comment.
is there no numpy methods you can crib for this? or is the native Cython bitshift for efficient?
| for line in f_in: | ||
| current_offset += len(line) | ||
| write_buffer.extend(struct.pack('<Q', current_offset)) | ||
| if len(write_buffer) > 8 * 1024 * 1024: |
There was a problem hiding this comment.
very nitpicky, but just write out the full multiplication as a var above and comment. no need to do the extra ops for every line.
| "offset": turn.get("offset", 0.0), | ||
| } | ||
| ) | ||
| if len(parts) > 1 and parts[1].strip(): |
There was a problem hiding this comment.
Needs catch to prevent silent fall throughs
|
|
||
| { | ||
| "id": str, | ||
| "id": str, # not optional, but we will tolerate if it's missing |
There was a problem hiding this comment.
bit cryptic, provide line where we tolerate this?
| elif isinstance(self.audio_placeholders, str): | ||
| self.audio_placeholders = [self.audio_placeholders] | ||
| self.audio_placeholders = _normalize_audio_placeholders(self.audio_placeholders) | ||
| self._has_index = all(Path(p + ".idx").exists() for p in self.manifest_filepath) |
There was a problem hiding this comment.
so been thinking: would the extension make more sense as manifest.idx/audio.idx instead of manifest.jsonl.idx '''.
| raise FileNotFoundError(f"No wids-meta.json and no .tar files found under {self.data_dir}") | ||
| self.audio_placeholders = _normalize_audio_placeholders(self.audio_placeholders) | ||
| self._has_index = all(Path(p + ".idx").exists() for p in self._shard_paths) | ||
| self.epoch = 0 |
There was a problem hiding this comment.
hmm, is there anyway we can sync this with the trainer? having an adapter maintaining epoch on its lonesome sounds like a pending desync issue that will be annoying to hunt down
|
Thanks. This PR looks good to me! |
Important
The
Update branchbutton must only be pressed in very rare occassions.An outdated branch is never blocking the merge of a PR.
Please reach out to the automation team before pressing that button.
What does this PR do ?
The first PR to support indexed datasets. It reads a binary index (sequence of uint64 byte offsets marking beginning of each sample in a file), generates random permutation of indexes on the fly, and looks up the right sample.
This implementation pretends it's a sequential IO dataset for compatibility, but will be used as a building block for a resumable dataloader in the future.
Supported formats:
share_gptdata.jsonlanddata.jsonl.idx{ "id": f"audio_convo", "sound": f"audio.wav", "conversations": [ {"from": "human", "value": f"Listen to this: <sound> What do you think?"}, {"from": "gpt", "value": f"Response"}, ], }share_gpt_webdatasetshard_0.tar+shard_0.tar.idxshare_gptCollection: speechlm2
Changelog
Usage
# Add a code snippet demonstrating how to use thisGitHub Actions CI
The Jenkins CI system has been replaced by GitHub Actions self-hosted runners.
The GitHub Actions CI will run automatically when the "Run CICD" label is added to the PR.
To re-run CI remove and add the label again.
To run CI on an untrusted fork, a NeMo user with write access must first click "Approve and run".
Before your PR is "Ready for review"
Pre checks:
PR Type:
If you haven't finished some of the above items you can still open "Draft" PR.
Who can review?
Anyone in the community is free to review the PR once the checks have passed.
Contributor guidelines contains specific people who can review PRs to various areas.
Additional Information