-
Notifications
You must be signed in to change notification settings - Fork 508
fix: rollout version dump - filter by loss_mask and add version_rle #1350
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
pyq623
wants to merge
1
commit into
areal-project:main
Choose a base branch
from
pyq623:fix/rollout-version-dump
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+29
−5
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -869,14 +869,18 @@ async def _dump_trajectory( | |
| self.logger.warning( | ||
| "Trajectory missing 'versions' field, defaulting to current inference engine version." | ||
| ) | ||
| versions = [self.inference_engine.get_version()] | ||
| all_versions = None | ||
| default_version = self.inference_engine.get_version() | ||
| else: | ||
| versions = traj["versions"].flatten().tolist() | ||
| all_versions = traj["versions"] | ||
|
|
||
| tail_version = max(versions) | ||
| head_version = min(versions) | ||
| global_tail = ( | ||
| all_versions.max().item() | ||
| if all_versions is not None | ||
| else default_version | ||
| ) | ||
| # Create versioned directory | ||
| version_dir = os.path.join(dump_dir, str(tail_version)) | ||
| version_dir = os.path.join(dump_dir, str(global_tail)) | ||
| await aiofiles.os.makedirs(version_dir, exist_ok=True) | ||
|
|
||
| # Handle batched trajectories | ||
|
|
@@ -894,6 +898,25 @@ async def _dump_trajectory( | |
| if mask[-1] != 1: | ||
| continue | ||
|
|
||
| if all_versions is not None: | ||
| sample_versions = all_versions[i, :seqlen].tolist() | ||
| output_versions = [ | ||
| v for v, m in zip(sample_versions, mask) if m == 1 | ||
| ] | ||
| else: | ||
| output_versions = [default_version] | ||
|
|
||
| head_version = min(output_versions) if output_versions else -1 | ||
| tail_version = max(output_versions) if output_versions else -1 | ||
|
|
||
| # RLE: [[version, count], ...] | ||
| version_rle = [] | ||
| for v in output_versions: | ||
| if version_rle and version_rle[-1][0] == v: | ||
| version_rle[-1][1] += 1 | ||
| else: | ||
| version_rle.append([v, 1]) | ||
|
Comment on lines
+901
to
+918
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are two issues here:
Additionally, the if all_versions is not None:
# Filter versions by loss_mask using tensor operations for efficiency
output_versions = all_versions[i, :seqlen][loss_mask[i, :seqlen] == 1].tolist()
head_version = min(output_versions)
tail_version = max(output_versions)
# RLE: [[version, count], ...]
version_rle = []
for v in output_versions:
if version_rle and version_rle[-1][0] == v:
version_rle[-1][1] += 1
else:
version_rle.append([v, 1])
else:
head_version = tail_version = default_version
# If versions are missing, the entire completion is assumed to be default_version
version_rle = [[default_version, int(sum(mask))]] |
||
|
|
||
| prompt_end = seqlen - sum(mask) | ||
| prompt_ids = ids[:prompt_end] | ||
| completion_ids = ids[prompt_end:] | ||
|
|
@@ -913,6 +936,7 @@ async def _dump_trajectory( | |
| "prompt_len": prompt_end, | ||
| "head_version": head_version, | ||
| "tail_version": tail_version, | ||
| "version_rle": version_rle, | ||
| "reward": reward, | ||
| "prompt": prompt_text, | ||
| "completion": completion_text, | ||
|
|
||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
global_tailcalculation should also be filtered byloss_maskto ensure that the version directory name is not set to-1(the placeholder for input tokens) if theversionstensor contains such values. This ensures the directory name reflects the actual model version used for generation.