Port Protein to CUDA C#601
Open
vyeoms wants to merge 12 commits into
Open
Conversation
This change defines __setstate__ and __getstate__ in Protein to handle CUDA graph capture in child processes spawned by multiprocessing. The child processes don't handle GP training or updates, so they don't need to be calling CudaMalloc. Stripping the CUDA-heavy parameters for the child processes reduces the graph capture load
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.
Summary
Building on top of #587, so the diff will be updated once the GP port PR is accepted. Porting Protein to pure CUDA C:
src/protein_util.h: Pure C utilities for Protein. Defines the search space type (linear, log, pow2, logit), normalizations, Pareto front utilities, and other numeric helpers (for example the Nelder Mead minimizer used here).src/protein.cu: Core implementation for Protein, implements the original as faithfully as I could make it. Has code for reqs like Adam, acquisition scoring, and other device-side numeric operations (e.g. for the classifier), which I don't know if would be preferred in a separate file. Currently ~1200 LoC.tests/test_protein.cu: Unit testing the components fromsrc/protein.cu. Build withnvcc -o test_protein tests/test_protein.cu -I src/ -lcublas -lcusolver -lcurandand run with./test_protein.tests/test_protein_sweep.cu: Replicates the synthetic sweep test fromtests/test_sweep.py. Outputs an HTML with the plot, and a CSV with the results for registry. Build withnvcc -o test_protein_sweep tests/test_protein_sweep.cu -I src/ -lcublas -lcusolver -lcurandand run with./test_protein_sweep.Notes
Fair to note, this is a pure CUDA implementation. Unlike the GP port I mentioned in #587, I don't have a pure C CPU version for Protein currently.
This should build natively with PufferLib to run with
puffer sweep <env>, but falls back to the original python implementation in case the Protein CUDA build isn't available.Numeric and qualitative results
Unit testing
tests/test_protein.cugenerally tests the following aspects:Plus a small integration test fitting a toy cost function.
Synthetic test
tests/test_protein_sweep.cureplicates the synthetic eval fromtests/test_sweep.py. Output from the CUDA C test:Original implementation with gpytorch:
Breakout
Ran a 20 iteration sweep on Breakout. Sweep result on my laptop with one A100 GPU:
Playing with the top score hyperparameters: