Skip to content

Commit

Permalink
Fix ascend set_device() invoking issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
pdx1989 committed Jan 18, 2024
1 parent 857b602 commit cf37c99
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dicp/dicp/vendor/AscendGraph/codegen/load_and_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ def release_memory(self):
self.work_ptr = None


memory_pool = MemoryPool()
zero_tensor = torch.randn(1).to(dipu_device_str)
memory_pool = MemoryPool()


class AscendExecutor(object):
Expand Down
10 changes: 10 additions & 0 deletions dicp/test/model/test_hf.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import torch_dipu


# monkey patch for pytorch
import importlib
tmp_variable_torch_module = importlib.import_module("torch._dynamo.variables.torch")
tmp_torch_variable = getattr(tmp_variable_torch_module, "TorchVariable")
Expand All @@ -16,12 +17,21 @@ def new_torch_variable_python_type(self):
return origin_torch_variable_python_type(self)
setattr(tmp_torch_variable, "python_type", new_torch_variable_python_type)

# some common config
models_dir = os.environ.get("LLAMA_MODEL_DIR")
assert models_dir is not None
dynamo.config.cache_size_limit = 4096
dynamo.config.dynamic_shapes = True
dynamo.config.assume_static_by_default = False

# trigger dipu current_device() for aclrtSetDevice() invoking
if os.environ.get("DIPU_MOCK_CUDA") == "True":
device_name = "cuda"
else:
device_name = torch_dipu.dipu.device.__dipu__
device = f"{device_name}:0"
torch_dipu.dipu.set_device(device)

cuda_results = [
[" ⁇ long long ago&ampiretsburgerirse Urs diggingestyle changed handsprints", ""],
[" ⁇ under the sky meteor crossingaps LO sometimes lapseedslingtoniginality hyper externospu windsurgeonshiregiarels Pirates Dienstelfinitiateavigationaillekaunixferringeredesoncourtneyodnise shipmentioned Holyoke deflectorship EastboundaryMagazineeringhusbandmicrosoft Wordimanuelledangelokindnesses Urbanizationally Soundtrack� Susan dynamic rangemu abide Sandy�eldom Brotherhoodзя Swindicator armaturedischemuirscriptstyleSu Douglassesствиore Raphairstenrystal clearance EvelynounceHandlerbarsrel shrines GLitteratiosidemixes MortgovernmentalismaticheckerTAGgedyardscapefaultyieldsperlhaps SUB$}}% altijd Scrolls downhillsidearmacyrifamilia☺️ceiverymanagingannelledgeraldromeampsitters Sibilitiesouthernmost tip Baker� RE NEVERthelessnesses Mallowsirectly�edy"],
Expand Down

0 comments on commit cf37c99

Please sign in to comment.