mirror of
https://github.com/microsoft/mscclpp.git
synced 2026-04-20 06:49:29 +00:00
update readme, build python package dir
This commit is contained in:
@@ -51,3 +51,22 @@ target_link_libraries(
|
||||
mscclpp
|
||||
)
|
||||
|
||||
add_custom_target(build-package ALL DEPENDS _py_mscclpp)
|
||||
add_custom_command(
|
||||
TARGET build-package POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/mscclpp
|
||||
${CMAKE_CURRENT_BINARY_DIR}/mscclpp)
|
||||
|
||||
add_custom_command(
|
||||
TARGET build-package POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy
|
||||
$<TARGET_FILE:_py_mscclpp>
|
||||
${CMAKE_CURRENT_BINARY_DIR}/mscclpp/)
|
||||
|
||||
add_custom_command(
|
||||
TARGET build-package POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy
|
||||
${MSCCLPP_DIR}/lib/libmscclpp.so
|
||||
${CMAKE_CURRENT_BINARY_DIR}/mscclpp/)
|
||||
|
||||
|
||||
@@ -1,3 +1,30 @@
|
||||
# Python bindings
|
||||
|
||||
Test instructions:
|
||||
* Compile the `libmscclpp.so` library.
|
||||
* setup a python virtual env
|
||||
* `pip install -r requirements.txt`
|
||||
* `./tesh.sh`
|
||||
|
||||
Rough build attemtps
|
||||
```
|
||||
# cd to this directory:
|
||||
|
||||
# setup/enter pyenv environment for python 3.9
|
||||
|
||||
# install nanabind and the test requirements.
|
||||
pip install -r requirements.txt
|
||||
|
||||
# setup and build the CMake environments.
|
||||
# this requires nanobind, installed above.
|
||||
./setup.sh
|
||||
|
||||
# test the module
|
||||
pytest build/mscclpp
|
||||
```
|
||||
|
||||
|
||||
## Installing `gdrcopy` and `mpi`
|
||||
This assumes that some things are built/installed
|
||||
```
|
||||
# assumes WORKDIR has:
|
||||
@@ -42,19 +69,3 @@ apt install -y numactl libnuma-dev libnuma1
|
||||
# if not mpi testing
|
||||
USE_MPI_FOR_TESTS=0 make -j
|
||||
```
|
||||
|
||||
|
||||
Rough build attemtps
|
||||
```
|
||||
# cd to this directory:
|
||||
|
||||
cmake -S . -B build
|
||||
cmake --build build --clean-first -v
|
||||
|
||||
# this should contain libmscclpp.so, but does not
|
||||
ldd build/py_mscclpp.cpython-39-x86_64-linux-gnu.so
|
||||
|
||||
# this will fail due to a missing symbol
|
||||
( cd build;
|
||||
LD_LIBRARY_PATH="$PWD/../../build/lib:$LD_LIBRARY_PATH" python -c 'import py_mscclpp' )
|
||||
```
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
clang-format \
|
||||
-style='{"BasedOnStyle": "google", "BinPackParameters": false, "BinPackArguments": false, "AlignAfterOpenBracket": "AlwaysBreak"}' \
|
||||
-i src/*
|
||||
clang-format -style='{
|
||||
"BasedOnStyle": "google",
|
||||
"BinPackParameters": false,
|
||||
"BinPackArguments": false,
|
||||
"AlignAfterOpenBracket": "AlwaysBreak"
|
||||
}' -i src/*.cpp
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
from . import _py_mscclpp
|
||||
|
||||
__all__ = (
|
||||
"MscclppUniqueId",
|
||||
"MSCCLPP_UNIQUE_ID_BYTES",
|
||||
"MscclppComm",
|
||||
)
|
||||
|
||||
MscclppUniqueId = _py_mscclpp.MscclppUniqueId
|
||||
MSCCLPP_UNIQUE_ID_BYTES = _py_mscclpp.MSCCLPP_UNIQUE_ID_BYTES
|
||||
|
||||
MscclppComm = _py_mscclpp.MscclppComm
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1 +0,0 @@
|
||||
../build/_py_mscclpp.cpython-39-x86_64-linux-gnu.so
|
||||
@@ -1,49 +0,0 @@
|
||||
import unittest
|
||||
import hamcrest
|
||||
|
||||
import mscclpp
|
||||
|
||||
class UniqueIdTest(unittest.TestCase):
|
||||
def test_no_constructor(self) -> None:
|
||||
hamcrest.assert_that(
|
||||
hamcrest.calling(mscclpp.MscclppUniqueId).with_args(),
|
||||
hamcrest.raises(
|
||||
TypeError,
|
||||
"no constructor",
|
||||
),
|
||||
)
|
||||
|
||||
def test_getUniqueId(self) -> None:
|
||||
myId = mscclpp.MscclppUniqueId.from_context()
|
||||
|
||||
hamcrest.assert_that(
|
||||
myId.bytes(),
|
||||
hamcrest.has_length(mscclpp.MSCCLPP_UNIQUE_ID_BYTES),
|
||||
)
|
||||
|
||||
# from_bytes should work
|
||||
copy = mscclpp.MscclppUniqueId.from_bytes(myId.bytes())
|
||||
hamcrest.assert_that(
|
||||
copy.bytes(),
|
||||
hamcrest.equal_to(myId.bytes()),
|
||||
)
|
||||
|
||||
# bad size
|
||||
hamcrest.assert_that(
|
||||
hamcrest.calling(mscclpp.MscclppUniqueId.from_bytes).with_args(b'abc'),
|
||||
hamcrest.raises(
|
||||
ValueError,
|
||||
f"Requires exactly {mscclpp.MSCCLPP_UNIQUE_ID_BYTES} bytes; found 3"
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
class CommsTest(unittest.TestCase):
|
||||
def _test(self) -> None:
|
||||
# this hangs forever
|
||||
comm = mscclpp.MscclppComm.init_rank_from_address(
|
||||
address="127.0.0.1:50000",
|
||||
rank=0,
|
||||
world_size=2,
|
||||
)
|
||||
comm.close()
|
||||
@@ -3,5 +3,4 @@
|
||||
set -ex
|
||||
cmake -S . -B build
|
||||
cmake --build build --clean-first -v
|
||||
ldd build/py_mscclpp.cpython-39-x86_64-linux-gnu.so
|
||||
|
||||
|
||||
@@ -8,4 +8,4 @@ fi
|
||||
|
||||
cmake --build build
|
||||
|
||||
pytest mscclpp
|
||||
pytest build/mscclpp
|
||||
|
||||
Reference in New Issue
Block a user