Repository navigation
Conversation
`kernelize` stores the kernel's forward on each layer, bound to it, and `nn.DataParallel` replicas copy it: every replica then runs the layers of the first device. Training silently diverges, or crashes when the GPUs can't read each other's memory. `model.use_kernels = False` now undoes `kernelize` (it was a no-op), and `Trainer` disables kernels before wrapping the model in `nn.DataParallel`.
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
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.
What does this PR do?
With kernels on,
nn.DataParallelreplicas run the layers of the first device:kernelizestores the kernel'sforwardon each layer, bound to it, and the replicas copy it. Training then silently diverges, or crashes withExpected all tensors to be on the same devicewhen the GPUs can't read each other's memory.This PR:
model.use_kernels = Falseundokernelize(it was a no-op with a warning):unkernelizeremoves the forwardkernelizestored on each layer, and keeps accelerate's hooks.Trainer, with a warning, before wrapping the model innn.DataParallel. DDP (torchrun,accelerate launch) is not affected and keeps the kernels.Reproducer
Traineron 2 GPUs launched withpython(sonn.DataParallel), a tiny Llama loaded withdevice_map="cuda:0", 20 steps:use_kernels=Falseuse_kernels=True, mainuse_kernels=True, this PRTests
test_unkernelizenow checks that disabling kernels removes them, instead of the old no-op warning.test_unkernelize_restores_class_forward: CPU test with a patchedkernelize.