Inference Pipeline Optimization - hpy_splits - #2779
Closed
javak87 wants to merge 2 commits into
Closed
Conversation
Collaborator
|
I tested the code and get: Old: 17:39:13 -> 17:47:51 Different branch, though: |
Contributor
Author
Thanks for the test. |
Contributor
Author
|
Close the PR due to incorrect timing! |
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
Inference Pipeline Optimization
Tokenizer CPU time was dominated by
hpy_splits: a Python loop over every HEALPix cell (12 * 4**hl) with a tinytorch.argsort/cat/splitper cell. This replaces that with a vectorized NumPy path while preserving the same token index lists.hpy_cell_splits: Uses onenp.lexsort((theta, cell_id))to group points by cell and sort them by latitude within each cell. Occupancy is computed usingnp.bincount(..., minlength=12 * 4**hl). It returns packed(idxs_ord, counts)instead of a Python list of per-cell arrays.hpy_splits: Scatters the packed indices into one padded buffer, splits once into tokens, and then slices the tokens back per cell. The same padding (index 0) andoffset_stepbehavior are preserved.tokenize_space/tokenize_spacetime: Unchanged; they continue to consume the same nested token lists.tests/test_hpy_splits.pyfreezes the original implementations and checkstorch.equalon tokens for padded and unpadded cases,offset_step, tied coordinates, remainder tokens, andhl=5.hpy_cell_splitsis only used byhpy_splitsin this tree.Inference Timing
Environment: Jupiter, 1 node, mini-epoch 8 from
cw6a4szuThe following command was used for both branches.
test_config.output.num_samples=0is required to avoid OOM.About 30% faster. Validation loss on j6dsiw2c: 0.0329427495598793 (unchanged vs baseline).
Note: These timings only show up if the job tree is running
javad/optimize-hpy_splitsbranch on private repo.launch-slurm.py --from-run-id cw6a4szucopies Python from that training run, not from your checkout, so launching from the optimized branch alone does not change the tokenizer unless those files are overlaid (or otherwise copied) into the new job directory.Issue Number
#2778
Is this PR a draft? Mark it as draft.
Checklist before asking for review
./scripts/actions.sh lint./scripts/actions.sh unit-test./scripts/actions.sh integration-testlaunch-slurm.py --time 60FastEvaluation