Skip to content

[11/n] tensor engine, fix bugs to make test_remote_functions pass #451

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: gh/zdevito/24/base
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,3 @@ members = [
"nccl-sys",
"torch-sys",
]

[profile.release]
incremental = true
2 changes: 1 addition & 1 deletion monarch_tensor_worker/src/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@ impl StreamActor {
}
let err = err.unwrap_dependent_error().unwrap_or(err);
WorkerError {
backtrace: format!("{:?}", err),
backtrace: err.to_string(),
worker_actor_id: worker_actor_id.clone(),
}
})
Expand Down
4 changes: 3 additions & 1 deletion python/monarch/mesh_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ def _initialize_env(worker_point: Point, proc_id: str) -> None:
}
os.environ.update(process_env)
pdb.set_trace = _set_trace
# workaround for set_manual_seed somehow not working if cuda is not initialized
torch.cuda.init()
except Exception:
traceback.print_exc()
raise
Expand Down Expand Up @@ -248,7 +250,7 @@ def __str__(self):
return (
f"A remote function has failed asynchronously on rank {self.rank}.\n"
f"Traceback of where the remote function was issued on controller (most recent call last):\n{controller_tb}"
f"Error as reported from worker!!!!!!!:\n{self.worker_error_string}"
f"Error as reported from worker:\n{self.worker_error_string}"
)
except Exception:
traceback.print_exc()
Expand Down
10 changes: 8 additions & 2 deletions python/monarch/proc_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,10 @@ async def proc_mesh_nonblocking(
) -> ProcMesh:
if gpus is None:
gpus = _local_device_count()
spec = AllocSpec(AllocConstraints(), gpus=gpus, hosts=hosts)
# gpus must come last in this order otherwise test_remote_function_all_gather
# because test_remote_function_all_gather expects that hosts comes before gpus
# in the order of the dimensions.
spec = AllocSpec(AllocConstraints(), hosts=hosts, gpus=gpus)
env = env or {}
cmd, args, base_env = _get_bootstrap_args()
env.update(base_env)
Expand All @@ -313,7 +316,10 @@ def proc_mesh_blocking(
) -> ProcMesh:
if gpus is None:
gpus = _local_device_count()
spec = AllocSpec(AllocConstraints(), gpus=gpus, hosts=hosts)
# gpus must come last in this order otherwise test_remote_function_all_gather
# because test_remote_function_all_gather expects that hosts comes before gpus
# in the order of the dimensions.
spec = AllocSpec(AllocConstraints(), hosts=hosts, gpus=gpus)
env = env or {}
cmd, args, base_env = _get_bootstrap_args()
env.update(base_env)
Expand Down
9 changes: 7 additions & 2 deletions python/tests/test_remote_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,9 @@ def local_device_mesh(
# out is not counted as a failure, so we set a more restrictive timeout to
# ensure we see a hard failure in CI.
@pytest.mark.timeout(120)
@pytest.mark.parametrize("backend_type", [BackendType.PY, BackendType.RS])
@pytest.mark.parametrize(
"backend_type", [BackendType.PY, BackendType.RS, BackendType.MESH]
)
class TestRemoteFunctions(RemoteFunctionsTestBase):
@classmethod
def do_test_reduce_scatter_tensor(cls, backend_type, reduce_op, expected_tensor):
Expand Down Expand Up @@ -952,10 +954,13 @@ def test_remote_function_failure_message_contains_traceback(self, backend_type):
x = outer_remote_function_that_calls_inner()
try:
inspect(x)
except RemoteException as e:
except OldRemoteException as e:
backtrace = "\n".join([frame.name for frame in e.worker_frames])
assert "outer_remote_function" in backtrace
assert "inner_remote_function" in backtrace
except NewRemoteException as e:
assert "outer_remote_function" in e.worker_error_string
assert "inner_remote_function" in e.worker_error_string

def test_remote_function_broadcast(self, backend_type):
with self.local_device_mesh(2, 2, backend_type) as device_mesh:
Expand Down
3 changes: 2 additions & 1 deletion torch-sys/src/ivalue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ impl Clone for OpaqueIValue {
/// This creates a deep copy of the underlying data and can be expensive.
/// It might also panic if the `IValue` is not cloneable.
fn clone(&self) -> Self {
Self(ffi::ivalue_deepcopy(&self.0).unwrap())
let serialized = bincode::serialize(&self.0).unwrap();
bincode::deserialize(&serialized).unwrap()
}
}

Expand Down
Loading