Conversation
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.
Fixes #6454
Three call sites still picked the device by hand instead of using ColossalAI's own accelerator abstraction, so on a non-CUDA accelerator they silently fell back to the CPU (fx tracer) or raised (rope cache).
Changes
colossalai/fx/tracer/experimental.py::default_device()torch.device("cuda:0") if torch.cuda.is_available() else torch.device("cpu")get_accelerator().get_current_device()colossalai/fx/passes/meta_info_prop.py::metainfo_trace()get_accelerator().get_current_device()colossalai/inference/utils.py::init_to_get_rotary()torch.cos(freqs).to(self.dtype).cuda()torch.cos(freqs).to(self.dtype).to(device),device = get_accelerator().get_current_device()CUDA behaviour is unchanged:
get_current_device()iscuda:<current device>there (the previous expression hard-codedcuda:0), and the rope cache still lands on the current CUDA device.Verification — Ascend 910B4, torch 2.15.0.dev20260917+cpu + torch_npu, CANN, single process
Before:
After (same script, same box, only the three files swapped):
The before/after files were md5-compared with the files in this PR after upload, so the code exercised on the box is byte-identical to the code being submitted.
Not tested
galore_torch,bitsandbytes,diffusers,PILare absent), so those imports were stubbed while loading the package. No ColossalAI source was modified for the test.