Skip to content

Commit

Permalink
add ipu_build_use_ipumodel (PaddlePaddle#430)
Browse files Browse the repository at this point in the history
* add ipu_build_use_ipumodel

* up 0

* fix using ipumodels

* disable real ipu ci

* add use_ipumodel flag for ut

* restore ci

* up x
  • Loading branch information
gglin001 authored Feb 15, 2022
1 parent 4f45f44 commit 2807880
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 3 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/build_ipumodel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: ipu_build_use_ipumodel

on:
pull_request:
branches:
- develop-ipu

jobs:
build_py_wheel:
runs-on: self-hosted

steps:
- name: clean space
run: |
docker run \
-v $PWD:/checkout \
--rm \
paddle_ipu_ci:2.3.0 \
bash -c "cd /checkout && pwd && ls -l /checkout && rm -rf *"
- uses: actions/checkout@v2

- name: build
run: |
gc-docker -- \
-v /tmp:/host_tmp \
-v $PWD:/checkout \
-v paddle_ccahe:/paddle_ccahe \
-e CCACHE_DIR=/paddle_ccahe \
-e CCACHE_MAXSIZE=20G \
-v paddle_ipuof:/ipuof \
-e GITHUB_SHA=${GITHUB_SHA} \
-v paddle_wheels:/paddle_wheels \
-e IPUOF_CONFIG_PATH=/ipuof/ipu.conf \
-e POPLAR_IPUMODEL=1 \
--workdir /checkout \
--rm \
paddle_ipu_ci:2.3.0 \
bash /checkout/paddle/scripts/ipu/github_action/action_build_and_test.sh
7 changes: 6 additions & 1 deletion paddle/fluid/platform/device/ipu/ipu_executor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,12 @@ void Executor::AcquireDevice() {

bool use_ipu_model = GetBoolEnv("POPLAR_IPUMODEL");
if (use_ipu_model) {
std::map<std::string, std::string> deviceOpts{{"numIPUs", "1 "}};
std::map<std::string, std::string> deviceOpts{
{
"numIPUs", std::to_string(ipu_strategy_->num_ipus),
},
{"ipuVersion", "ipu2"},
};
device_ = popart::DeviceManager::createDeviceManager().createIpuModelDevice(
deviceOpts);
} else {
Expand Down
10 changes: 10 additions & 0 deletions python/paddle/fluid/tests/unittests/ipu/op_test_ipu.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import random
import unittest
import numpy as np
Expand Down Expand Up @@ -79,6 +80,15 @@ def tearDownClass(cls):

_set_use_system_allocator(cls._use_system_allocator)

@property
def use_ipumodel():
if 'POPLAR_IPUMODEL' not in os.environ:
return False
else:
flag = os.environ['POPLAR_IPUMODEL']
if flag.upper() in ['1', "TRUE"]:
return True

def set_atol(self):
self.atol = 1e-10
self.rtol = 1e-6
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ def setUp(self):

@property
def fp16_enabled(self):
return True
if IPUOpTest.use_ipumodel:
return False
else:
return True

def set_test_op(self):
self.op = paddle.fluid.layers.elementwise_mul
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def set_serialize_factor(serialize_factor):
op._set_attr('serialize_factor', serialize_factor)


@unittest.skipIf(not paddle.is_compiled_with_ipu(),
@unittest.skipIf(not paddle.is_compiled_with_ipu() or IPUOpTest.use_ipumodel,
"core is not compiled with IPU")
class TestBase(IPUOpTest):
def setUp(self):
Expand Down
3 changes: 3 additions & 0 deletions python/paddle/fluid/tests/unittests/ipu/test_save_load_ipu.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ def set_op_attrs(self):
self.attrs['model_path'] = tempfile.TemporaryDirectory().name


@unittest.skipIf(IPUOpTest.use_ipumodel, "skip for ipumodel")
class TestSGDFP16(TestBase):
def set_op_attrs(self):
self.attrs = {}
Expand All @@ -168,6 +169,7 @@ def set_op_attrs(self):
self.attrs['model_path'] = tempfile.TemporaryDirectory().name


@unittest.skipIf(IPUOpTest.use_ipumodel, "skip for ipumodel")
class TestAdamFP16(TestBase):
def set_op_attrs(self):
self.attrs = {}
Expand All @@ -179,6 +181,7 @@ def set_op_attrs(self):
self.attrs['model_path'] = tempfile.TemporaryDirectory().name


@unittest.skipIf(IPUOpTest.use_ipumodel, "skip for ipumodel")
class TestLambFP16(TestBase):
def set_op_attrs(self):
self.attrs = {}
Expand Down

0 comments on commit 2807880

Please sign in to comment.