def test_memory_sharing_disabled(tmp_path):
    """Test that the multiprocessing launcher disables memory sharing on model parameters and buffers to avoid race
    conditions on model updates."""
    model = SimpleModel()
    assert not model.layer.weight.is_shared()
    assert model.layer.weight.data_ptr() == model.tied_layer.weight.data_ptr()

    trainer = Trainer(
        default_root_dir=tmp_path, logger=False, accelerator="cpu", devices=2, strategy="ddp_spawn", max_steps=0
    )
    trainer.fit(model)
Test that the multiprocessing launcher disables memory sharing on model parameters and buffers to avoid race
    conditions on model updates.
tests/tests_pytorch/strategies/launchers/test_multiprocessing.py