Repository: pytorch/ignite

Issue:
Update the "Concepts" part in the documentation
Recently we've added a possibility to handle custom events, so we need to keep "Concepts" documentation updated.

There is also a bad docstring rendering of parameters on methods
- [add_event_handler](https://pytorch.org/ignite/engine.html#ignite.engine.Engine.add_event_handler)
- [fire_event](https://pytorch.org/ignite/engine.html#ignite.engine.Engine.fire_event)
- [on](https://pytorch.org/ignite/engine.html#ignite.engine.Engine.fire_event)
- [register_events](https://pytorch.org/ignite/engine.html#ignite.engine.Engine.register_events)

Discussion:

Patch:
diff --git a/.travis.yml b/.travis.yml
index c744c8e1..f9d05c1d 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -78,7 +78,7 @@ jobs:
       install:
         # Minimal install : ignite and dependencies just to build the docs
         - pip install -r docs/requirements.txt
-        - pip install http://download.pytorch.org/whl/cpu/torch-0.4.0-cp35-cp35m-linux_x86_64.whl
+        - pip install http://download.pytorch.org/whl/cpu/torch-0.4.1-cp35-cp35m-linux_x86_64.whl
         # `pip install .` vs `python setup.py install` : 1st works better to produce _module/ignite with source links
         - pip install .
       script:
diff --git a/examples/mnist/mnist_with_visdom.py b/examples/mnist/mnist_with_visdom.py
index 78ccdb43..9758333e 100644
--- a/examples/mnist/mnist_with_visdom.py
+++ b/examples/mnist/mnist_with_visdom.py
@@ -54,8 +54,9 @@ def create_plot_window(vis, xlabel, ylabel, title):
 
 def run(train_batch_size, val_batch_size, epochs, lr, momentum, log_interval):
     vis = visdom.Visdom()
-    if not vis.check_connection():
-        raise RuntimeError("Visdom server not running. Please run python -m visdom.server")
+
+    # if not vis.check_connection():
+    #     raise RuntimeError("Visdom server not running. Please run python -m visdom.server")
 
     train_loader, val_loader = get_data_loaders(train_batch_size, val_batch_size)
     model = Net()
diff --git a/ignite/_utils.py b/ignite/_utils.py
index 60cd14ec..7daad7a7 100644
--- a/ignite/_utils.py
+++ b/ignite/_utils.py
@@ -11,10 +11,10 @@ def _to_hours_mins_secs(time_taken):
     return hours, mins, secs
 
 
-def convert_tensor(input_, device=None):
+def convert_tensor(input_, device=None, non_blocking=False):
     """Move tensors to relevant device."""
     def _func(tensor):
-        return tensor.to(device=device) if device else tensor
+        return tensor.to(device=device, non_blocking=non_blocking) if device else tensor
 
     return apply_to_tensor(input_, _func)
 
diff --git a/ignite/engine/__init__.py b/ignite/engine/__init__.py
index a943a8dc..5333c5e0 100644
--- a/ignite/engine/__init__.py
+++ b/ignite/engine/__init__.py
@@ -4,12 +4,13 @@ from ignite.engine.engine import Engine, State, Events
 from ignite._utils import convert_tensor
 
 
-def _prepare_batch(batch, device=None):
+def _prepare_batch(batch, device=None, non_blocking=False):
     x, y = batch
-    return convert_tensor(x, device=device), convert_tensor(y, device=device)
+    return (convert_tensor(x, device=device, non_blocking=non_blocking),
+            convert_tensor(y, device=device, non_blocking=non_blocking))
 
 
-def create_supervised_trainer(model, optimizer, loss_fn, device=None):
+def create_supervised_trainer(model, optimizer, loss_fn, device=None, non_blocking=False):
     """
     Factory function for creating a trainer for supervised models
 
@@ -19,6 +20,8 @@ def create_supervised_trainer(model, optimizer, loss_fn, device=None):
         loss_fn (torch.nn loss function): the loss function to use
         device (str, optional): device type specification (default: None).
             Applies to both model and batches.
+        non_blocking (bool, optional): if True and this copy is between CPU and GPU, the copy may occur asynchronously
+            with respect to the host. For other cases, this argument has no effect.
 
     Returns:
         Engine: a trainer engine with supervised update function
@@ -29,7 +32,7 @@ def create_supervised_trainer(model, optimizer, loss_fn, device=None):
     def _update(engine, batch):
         model.train()
         optimizer.zero_grad()
-        x, y = _prepare_batch(batch, device=device)
+        x, y = _prepare_batch(batch, device=device, non_blocking=non_blocking)
         y_pred = model(x)
         loss = loss_fn(y_pred, y)
         loss.backward()
diff --git a/ignite/handlers/checkpoint.py b/ignite/handlers/checkpoint.py
index 946d22fa..4e68a4e1 100644
--- a/ignite/handlers/checkpoint.py
+++ b/ignite/handlers/checkpoint.py
@@ -42,6 +42,8 @@ class ModelCheckpoint(object):
             in the directory 'dirname'
         create_dir (bool, optional):
             If True, will create directory 'dirname' if it doesnt exist.
+        save_as_state_dict (bool, optional):
+            If True, will save only the `state_dict` of the objects specified, otherwise the whole object will be saved.
 
     Notes:
           This handler expects two arguments: an `Engine` object and a `dict`


Test patch:
diff --git a/tests/ignite/test__utils.py b/tests/ignite/test__utils.py
index 3a1c8eab..6f5b7f67 100644
--- a/tests/ignite/test__utils.py
+++ b/tests/ignite/test__utils.py
@@ -8,6 +8,14 @@ def test_convert_tensor():
     tensor = convert_tensor(x)
     assert torch.is_tensor(tensor)
 
+    x = torch.Tensor([0.0])
+    tensor = convert_tensor(x, device='cpu', non_blocking=True)
+    assert torch.is_tensor(tensor)
+
+    x = torch.Tensor([0.0])
+    tensor = convert_tensor(x, device='cpu', non_blocking=False)
+    assert torch.is_tensor(tensor)
+
     x = (torch.Tensor([0.0]), torch.Tensor([0.0]))
     list_ = convert_tensor(x)
     assert isinstance(list_, list)