optuna: `JSONDecodeError` in `JournalStorage`

Expected behavior

The all CIs should be passed but test_pop_waiting_trial_multiprocess_safe in tests/storages_tests/test_journal.py sometimes fails. https://github.com/optuna/optuna/actions/runs/7079914046/job/19267103786

Environment

  • Optuna version: master
  • Python version: (at least) 3.7 & 3.8
  • OS: Ubuntu
  • (Optional) Other libraries and their versions:

Error messages, stack traces, or logs

___________________ test_pop_waiting_trial_multiprocess_safe ___________________
concurrent.futures.process._RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/concurrent/futures/process.py", line 239, in _process_worker
    r = call_item.fn(*call_item.args, **call_item.kwargs)
  File "/home/runner/work/optuna/optuna/tests/storages_tests/test_journal.py", line 103, in pop_waiting_trial
    study = optuna.load_study(storage=storage, study_name=study_name)
  File "/home/runner/work/optuna/optuna/optuna/_convert_positional_args.py", line 83, in converter_wrapper
    return func(**kwargs)
  File "/home/runner/work/optuna/optuna/optuna/study/study.py", line 1350, in load_study
    return Study(study_name=study_name, storage=storage, sampler=sampler, pruner=pruner)
  File "/home/runner/work/optuna/optuna/optuna/study/study.py", line 85, in __init__
    self._directions = storage.get_study_directions(study_id)
  File "/home/runner/work/optuna/optuna/optuna/storages/_journal/storage.py", line 213, in get_study_directions
    self._sync_with_backend()
  File "/home/runner/work/optuna/optuna/optuna/storages/_journal/storage.py", line 149, in _sync_with_backend
    logs = self._backend.read_logs(self._replay_result.log_number_read)
  File "/home/runner/work/optuna/optuna/optuna/storages/_journal/file.py", line 175, in read_logs
    raise last_decode_error
  File "/home/runner/work/optuna/optuna/optuna/storages/_journal/file.py", line 184, in read_logs
    logs.append(json.loads(line))
  File "/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/json/decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Unterminated string starting at: line 1 column 146 (char 145)
"""

The above exception was the direct cause of the following exception:

    def test_pop_waiting_trial_multiprocess_safe() -> None:
        with NamedTemporaryFilePool() as file:
            file_storage = optuna.storages.JournalFileStorage(file.name)
            storage = optuna.storages.JournalStorage(file_storage)
            study = optuna.create_study(storage=storage)
            num_enqueued = 10
            for i in range(num_enqueued):
                study.enqueue_trial({"i": i})
    
            trial_id_set = set()
            with ProcessPoolExecutor(10) as pool:
                futures = []
                for i in range(num_enqueued):
                    future = pool.submit(pop_waiting_trial, file.name, study.study_name)
                    futures.append(future)
    
                for future in as_completed(futures):
>                   trial_id = future.result()

tests/storages_tests/test_journal.py:124: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/concurrent/futures/_base.py:437: in result
    return self.__get_result()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = None

    def __get_result(self):
        if self._exception:
            try:
>               raise self._exception
E               json.decoder.JSONDecodeError: Unterminated string starting at: line 1 column 146 (char 145)

/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/concurrent/futures/_base.py:389: JSONDecodeError

Steps to reproduce

Run test_pop_waiting_trial_multiprocess_safe in tests/storages_tests/test_journal.py.

Additional context (optional)

No response

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 2
  • Comments: 24 (12 by maintainers)

Commits related to this issue

Most upvoted comments

Okay, turns our the file system is something called juicefs.

#5195 fixed this error. It will be included in the next minor release. Thank you for your reports and contributions!

Thank you for your reports. I investigated this bug and found that it is caused by the wrong reading log logic. We plan to fix it until the next minor release.

It’s the latest. Here is the docker image.

I deleted the corrupted log file generated earlier. However, when I was trying to reproduce the problem, a different error showed up:

Traceback (most recent call last):
  File "/opt/conda/lib/python3.10/site-packages/optuna/study/_optimize.py", line 216, in _run_trial
    frozen_trial = study._storage.get_trial(trial._trial_id)
  File "/opt/conda/lib/python3.10/site-packages/optuna/storages/_journal/storage.py", line 368, in get_trial
    self._sync_with_backend()
  File "/opt/conda/lib/python3.10/site-packages/optuna/storages/_journal/storage.py", line 148, in _sync_with_backend
    logs = self._backend.read_logs(self._replay_result.log_number_read)
  File "/opt/conda/lib/python3.10/site-packages/optuna/storages/_journal/file.py", line 183, in read_logs
    raise last_decode_error
  File "/opt/conda/lib/python3.10/site-packages/optuna/storages/_journal/file.py", line 197, in read_logs
    logs.append(json.loads(line))
  File "/opt/conda/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/opt/conda/lib/python3.10/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/opt/conda/lib/python3.10/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/juicefs-algorithm/workspace/nlp/li_wang/internevo/train.py", line 372, in <module>
    study.optimize(objective, n_trials=1)
  File "/opt/conda/lib/python3.10/site-packages/optuna/study/study.py", line 453, in optimize
    _optimize(
  File "/opt/conda/lib/python3.10/site-packages/optuna/study/_optimize.py", line 62, in _optimize
    _optimize_sequential(
  File "/opt/conda/lib/python3.10/site-packages/optuna/study/_optimize.py", line 159, in _optimize_sequential
    frozen_trial = _run_trial(study, func, catch)
  File "/opt/conda/lib/python3.10/site-packages/optuna/study/_optimize.py", line 219, in _run_trial
    if frozen_trial.state == TrialState.COMPLETE:
UnboundLocalError: local variable 'frozen_trial' referenced before assignment

2024-05-21 16:21:39,758	ERROR train.py:379 in <module> -- Raise exception from ubuntu-DeepLearning-4806044 with rank id: 1
Traceback (most recent call last):
  File "/opt/conda/lib/python3.10/site-packages/optuna_integration/pytorch_distributed.py", line 67, in wrapped
    return f(*args, **kwargs)
  File "/opt/conda/lib/python3.10/site-packages/optuna_integration/pytorch_distributed.py", line 237, in report
    raise err
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/juicefs-algorithm/workspace/nlp/li_wang/internevo/train.py", line 375, in <module>
    objective(None)
  File "/juicefs-algorithm/workspace/nlp/li_wang/internevo/sweep.py", line 13, in intern_5m_sweep_objective
    return fn(args, trial)
  File "/juicefs-algorithm/workspace/nlp/li_wang/internevo/train.py", line 305, in main
    trial.report(loss.item(), batch_count)
  File "/opt/conda/lib/python3.10/site-packages/optuna_integration/pytorch_distributed.py", line 76, in wrapped
    ) = self._call_and_communicate_obj(fetch_properties)
  File "/opt/conda/lib/python3.10/site-packages/optuna_integration/pytorch_distributed.py", line 323, in _call_and_communicate_obj
    return self._broadcast(result)
  File "/opt/conda/lib/python3.10/site-packages/optuna_integration/pytorch_distributed.py", line 332, in _broadcast
    dist.broadcast(size_buffer, src=0, group=self._group)
  File "/opt/conda/lib/python3.10/site-packages/torch/distributed/c10d_logger.py", line 47, in wrapper
    return func(*args, **kwargs)
  File "/opt/conda/lib/python3.10/site-packages/torch/distributed/distributed_c10d.py", line 1914, in broadcast
    work.wait()
RuntimeError: [../third_party/gloo/gloo/transport/tcp/pair.cc:534] Connection closed by peer [127.0.0.1]:26836

2024-05-21 16:21:39,764	ERROR train.py:379 in <module> -- Raise exception from ubuntu-DeepLearning-4806044 with rank id: 2
Traceback (most recent call last):
  File "/opt/conda/lib/python3.10/site-packages/optuna_integration/pytorch_distributed.py", line 67, in wrapped
    return f(*args, **kwargs)
  File "/opt/conda/lib/python3.10/site-packages/optuna_integration/pytorch_distributed.py", line 237, in report
    raise err
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

I started two processes, the first one stoped due to the error while the second one seem to run just fine. Here is the log file generated by optuna:

{"op_code": 0, "worker_id": "617e716b-c149-4ef3-a684-45456cda0aa4-139940470409024", "study_name": "intern_5m_muP_sweep_debug", "directions": [1]}
{"op_code": 4, "worker_id": "617e716b-c149-4ef3-a684-45456cda0aa4-139940470409024", "study_id": 0, "datetime_start": "2024-05-21T16:16:48.404352"}
{"op_code": 5, "worker_id": "617e716b-c149-4ef3-a684-45456cda0aa4-139940470409024", "trial_id": 0, "param_name": "scale_emb", "param_value_internal": 5.0427348880931415, "distribution": "{\"name\": \"FloatDistribution\", \"attributes\": {\"step\": null, \"low\": 0.0, \"high\": 20.0, \"log\": false}}"}
{"op_code": 5, "worker_id": "617e716b-c149-4ef3-a684-45456cda0aa4-139940470409024", "trial_id": 0, "param_name": "scale_depth", "param_value_internal": 0.21607731322222934, "distribution": "{\"name\": \"FloatDistribution\", \"attributes\": {\"step\": null, \"low\": 0.0, \"high\": 10.0, \"log\": false}}"}
{"op_code": 5, "worker_id": "617e716b-c149-4ef3-a684-45456cda0aa4-139940470409024", "trial_id": 0, "param_name": "init_std", "param_value_internal": 0.9481608230815018, "distribution": "{\"name\": \"FloatDistribution\", \"attributes\": {\"step\": null, \"low\": 0.0, \"high\": 1.0, \"log\": false}}"}
{"op_code": 5, "worker_id": "617e716b-c149-4ef3-a684-45456cda0aa4-139940470409024", "trial_id": 0, "param_name": "lr", "param_value_internal": 0.03880828519140931, "distribution": "{\"name\": \"FloatDistribution\", \"attributes\": {\"step\": null, \"low\": 0.0, \"high\": 0.2, \"log\": false}}"}
{"op_code": 7, "worker_id": "617e716b-c149-4ef3-a684-45456cda0aa4-139940470409024", "trial_id": 0, "step": 0, "intermediate_value": 12.879324913024902}
{"op_code": 7, "worker_id": "617e716b-c149-4ef3-a684-45456cda0aa4-139940470409024", "trial_id": 0, "step": 1, "intermediate_value": 12.788047790527344}
{"op_code": 7, "worker_id": "617e716b-c149-4ef3-a684-45456cda0aa4-139940470409024", "trial_id": 0, "step": 2, "intermediate_value": 12.511056900024414}
...
{"op_code": 7, "worker_id": "617e716b-c149-4ef3-a684-45456cda0aa4-139940470409024", "trial_id": 0, "step": 1063, "intermediate_value": 6.470120429992676}

Note that there seems to be an empty line at the end of the file, which could be the problem here.

Yes of course:) The error looks like similar to the one reported earlier. It seems that the trial can start running for a while until another process started can corrupt the log file.

2024-05-20 19:06:47,578	INFO training_internlm.py:771 in record_current_batch_training_metrics -- tflops=5.335465091592829 step=5 loss=8.54883098602295 tgs (tokens/gpu/second)=24316.07 tgs/last_tgs_1=24316.12 tgs/tgs_all=12025.95 tgs/tgs_avg=13717.84 tgs/tgs_SMA=12025.95 tgs/last_tgs_10=0 tgs/last_tgs_50=0 lr=0.010262852534651756 loss_scale=65536.0 grad_norm={'0_default': 0.2240985285550442, '1_default': 1.5120175088595298} epoch=0 micro_num=8 num_consumed_tokens=12582912 inf_nan_skip_batches=0 num_samples_in_batch=286 largest_length=2048 largest_batch=44 smallest_batch=24 adam_beta2=0.95 fwd_bwd_time=0.87 acc=0.0348 perplexity=5038.9927 acc//juicefs-algorithm/workspace/nlp/jinquan_ding/InternEvo/data_local/cn=0.0348 acc//juicefs-algorithm/workspace/nlp/jinquan_ding/InternEvo/data_local/test=0.0 tokens//juicefs-algorithm/workspace/nlp/jinquan_ding/InternEvo/data_local/cn=2095388 tokens//juicefs-algorithm/workspace/nlp/jinquan_ding/InternEvo/data_local/test=0 loss_from_metric=8.525 loss//juicefs-algorithm/workspace/nlp/jinquan_ding/InternEvo/data_local/cn=8.525 loss//juicefs-algorithm/workspace/nlp/jinquan_ding/InternEvo/data_local/test=nan 
2024-05-20 19:07:00,953	INFO training_internlm.py:771 in record_current_batch_training_metrics -- tflops=4.3471425289503625 step=6 loss=8.242281913757324 tgs (tokens/gpu/second)=19811.85 tgs/last_tgs_1=19811.88 tgs/tgs_all=12741.27 tgs/tgs_avg=14588.42 tgs/tgs_SMA=12741.27 tgs/last_tgs_10=0 tgs/last_tgs_50=0 lr=0.011728974325316293 loss_scale=65536.0 grad_norm={'0_default': 0.22520167994368076, '1_default': 1.6574819050026992} epoch=0 micro_num=8 num_consumed_tokens=14680064 inf_nan_skip_batches=0 num_samples_in_batch=259 largest_length=2048 largest_batch=51 smallest_batch=16 adam_beta2=0.95 fwd_bwd_time=0.91 acc=0.0216 perplexity=3487.989 acc//juicefs-algorithm/workspace/nlp/jinquan_ding/InternEvo/data_local/cn=0.0216 acc//juicefs-algorithm/workspace/nlp/jinquan_ding/InternEvo/data_local/test=0.0 tokens//juicefs-algorithm/workspace/nlp/jinquan_ding/InternEvo/data_local/cn=2095603 tokens//juicefs-algorithm/workspace/nlp/jinquan_ding/InternEvo/data_local/test=0 loss_from_metric=8.1571 loss//juicefs-algorithm/workspace/nlp/jinquan_ding/InternEvo/data_local/cn=8.1571 loss//juicefs-algorithm/workspace/nlp/jinquan_ding/InternEvo/data_local/test=nan 
2024-05-20 19:07:21,367	INFO training_internlm.py:771 in record_current_batch_training_metrics -- tflops=2.8371251887611044 step=7 loss=8.092676162719727 tgs (tokens/gpu/second)=12930.04 tgs/last_tgs_1=12930.05 tgs/tgs_all=12764.57 tgs/tgs_avg=14381.12 tgs/tgs_SMA=12764.57 tgs/last_tgs_10=0 tgs/last_tgs_50=0 lr=0.01319509611598083 loss_scale=65536.0 grad_norm={'0_default': 0.11347788975738815, '1_default': 1.038763763391638} epoch=0 micro_num=8 num_consumed_tokens=16777216 inf_nan_skip_batches=0 num_samples_in_batch=352 largest_length=2048 largest_batch=51 smallest_batch=38 adam_beta2=0.95 fwd_bwd_time=0.9 acc=0.0234 perplexity=3627.1111 acc//juicefs-algorithm/workspace/nlp/jinquan_ding/InternEvo/data_local/cn=0.0234 acc//juicefs-algorithm/workspace/nlp/jinquan_ding/InternEvo/data_local/test=0.0 tokens//juicefs-algorithm/workspace/nlp/jinquan_ding/InternEvo/data_local/cn=2095289 tokens//juicefs-algorithm/workspace/nlp/jinquan_ding/InternEvo/data_local/test=0 loss_from_metric=8.1962 loss//juicefs-algorithm/workspace/nlp/jinquan_ding/InternEvo/data_local/cn=8.1962 loss//juicefs-algorithm/workspace/nlp/jinquan_ding/InternEvo/data_local/test=nan 
2024-05-20 19:07:34,388	INFO training_internlm.py:771 in record_current_batch_training_metrics -- tflops=4.459795912168429 step=8 loss=8.514721870422363 tgs (tokens/gpu/second)=20325.27 tgs/last_tgs_1=20325.29 tgs/tgs_all=13314.9 tgs/tgs_avg=15041.59 tgs/tgs_SMA=13314.9 tgs/last_tgs_10=0 tgs/last_tgs_50=0 lr=0.014661217906645367 loss_scale=65536.0 grad_norm={'0_default': 0.09711209324832443, '1_default': 0.9855694260589425} epoch=0 micro_num=8 num_consumed_tokens=18874368 inf_nan_skip_batches=0 num_samples_in_batch=306 largest_length=2048 largest_batch=48 smallest_batch=27 adam_beta2=0.95 fwd_bwd_time=0.89 acc=0.0343 perplexity=3715.2295 acc//juicefs-algorithm/workspace/nlp/jinquan_ding/InternEvo/data_local/cn=0.0343 acc//juicefs-algorithm/workspace/nlp/jinquan_ding/InternEvo/data_local/test=0.0 tokens//juicefs-algorithm/workspace/nlp/jinquan_ding/InternEvo/data_local/cn=2095257 tokens//juicefs-algorithm/workspace/nlp/jinquan_ding/InternEvo/data_local/test=0 loss_from_metric=8.2202 loss//juicefs-algorithm/workspace/nlp/jinquan_ding/InternEvo/data_local/cn=8.2202 loss//juicefs-algorithm/workspace/nlp/jinquan_ding/InternEvo/data_local/test=nan 
2024-05-20 19:07:34,544	ERROR train.py:379 in <module> -- Raise exception from ubuntu-DeepLearning-4806050 with rank id: 0
Traceback (most recent call last):
  File "/opt/conda/lib/python3.10/site-packages/optuna/study/_optimize.py", line 208, in _run_trial
    frozen_trial = _tell_with_warning(
  File "/opt/conda/lib/python3.10/site-packages/optuna/study/_tell.py", line 113, in _tell_with_warning
    frozen_trial = _get_frozen_trial(study, trial)
  File "/opt/conda/lib/python3.10/site-packages/optuna/study/_tell.py", line 47, in _get_frozen_trial
    return study._storage.get_trial(trial_id)
  File "/opt/conda/lib/python3.10/site-packages/optuna/storages/_journal/storage.py", line 368, in get_trial
    self._sync_with_backend()
  File "/opt/conda/lib/python3.10/site-packages/optuna/storages/_journal/storage.py", line 148, in _sync_with_backend
    logs = self._backend.read_logs(self._replay_result.log_number_read)
  File "/opt/conda/lib/python3.10/site-packages/optuna/storages/_journal/file.py", line 183, in read_logs
    raise last_decode_error
  File "/opt/conda/lib/python3.10/site-packages/optuna/storages/_journal/file.py", line 197, in read_logs
    logs.append(json.loads(line))
  File "/opt/conda/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/opt/conda/lib/python3.10/json/decoder.py", line 340, in decode
    raise JSONDecodeError("Extra data", s, end)
json.decoder.JSONDecodeError: Extra data: line 1 column 2 (char 1)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/conda/lib/python3.10/site-packages/optuna/study/_optimize.py", line 216, in _run_trial
    frozen_trial = study._storage.get_trial(trial._trial_id)
  File "/opt/conda/lib/python3.10/site-packages/optuna/storages/_journal/storage.py", line 368, in get_trial
    self._sync_with_backend()
  File "/opt/conda/lib/python3.10/site-packages/optuna/storages/_journal/storage.py", line 148, in _sync_with_backend
    logs = self._backend.read_logs(self._replay_result.log_number_read)
  File "/opt/conda/lib/python3.10/site-packages/optuna/storages/_journal/file.py", line 183, in read_logs
    raise last_decode_error
  File "/opt/conda/lib/python3.10/site-packages/optuna/storages/_journal/file.py", line 197, in read_logs
    logs.append(json.loads(line))
  File "/opt/conda/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/opt/conda/lib/python3.10/json/decoder.py", line 340, in decode
    raise JSONDecodeError("Extra data", s, end)
json.decoder.JSONDecodeError: Extra data: line 1 column 2 (char 1)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/juicefs-algorithm/workspace/nlp/li_wang/internevo/train.py", line 372, in <module>
    study.optimize(objective, n_trials=1)
  File "/opt/conda/lib/python3.10/site-packages/optuna/study/study.py", line 453, in optimize
    _optimize(
  File "/opt/conda/lib/python3.10/site-packages/optuna/study/_optimize.py", line 62, in _optimize
    _optimize_sequential(
  File "/opt/conda/lib/python3.10/site-packages/optuna/study/_optimize.py", line 159, in _optimize_sequential
    frozen_trial = _run_trial(study, func, catch)
  File "/opt/conda/lib/python3.10/site-packages/optuna/study/_optimize.py", line 219, in _run_trial
    if frozen_trial.state == TrialState.COMPLETE:
UnboundLocalError: local variable 'frozen_trial' referenced before assignment

Exception in thread Thread-3 (_pin_memory_loop):
Traceback (most recent call last):
  File "/opt/conda/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "/opt/conda/lib/python3.10/threading.py", line 953, in run
2024-05-20 19:07:39,952	ERROR train.py:379 in <module> -- Raise exception from ubuntu-DeepLearning-4806050 with rank id: 1
Traceback (most recent call last):
  File "/opt/conda/lib/python3.10/site-packages/optuna_integration/pytorch_distributed.py", line 67, in wrapped
    return f(*args, **kwargs)
  File "/opt/conda/lib/python3.10/site-packages/optuna_integration/pytorch_distributed.py", line 237, in report
    raise err
json.decoder.JSONDecodeError: Extra data: line 1 column 2 (char 1)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/juicefs-algorithm/workspace/nlp/li_wang/internevo/train.py", line 375, in <module>
    objective(None)
  File "/juicefs-algorithm/workspace/nlp/li_wang/internevo/sweep.py", line 13, in intern_5m_sweep_objective
    return fn(args, trial)
  File "/juicefs-algorithm/workspace/nlp/li_wang/internevo/train.py", line 305, in main
    trial.report(loss.item(), batch_count)
  File "/opt/conda/lib/python3.10/site-packages/optuna_integration/pytorch_distributed.py", line 76, in wrapped
    ) = self._call_and_communicate_obj(fetch_properties)
  File "/opt/conda/lib/python3.10/site-packages/optuna_integration/pytorch_distributed.py", line 323, in _call_and_communicate_obj
    return self._broadcast(result)
  File "/opt/conda/lib/python3.10/site-packages/optuna_integration/pytorch_distributed.py", line 332, in _broadcast
    dist.broadcast(size_buffer, src=0, group=self._group)
  File "/opt/conda/lib/python3.10/site-packages/torch/distributed/c10d_logger.py", line 47, in wrapper
    return func(*args, **kwargs)
  File "/opt/conda/lib/python3.10/site-packages/torch/distributed/distributed_c10d.py", line 1914, in broadcast
    work.wait()
RuntimeError: [../third_party/gloo/gloo/transport/tcp/pair.cc:534] Connection closed by peer [127.0.0.1]:62127

2024-05-20 19:07:39,962	ERROR train.py:379 in <module> -- Raise exception from ubuntu-DeepLearning-4806050 with rank id: 2
Traceback (most recent call last):
  File "/opt/conda/lib/python3.10/site-packages/optuna_integration/pytorch_distributed.py", line 67, in wrapped
    return f(*args, **kwargs)
  File "/opt/conda/lib/python3.10/site-packages/optuna_integration/pytorch_distributed.py", line 237, in report
    raise err
json.decoder.JSONDecodeError: Extra data: line 1 column 2 (char 1)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/juicefs-algorithm/workspace/nlp/li_wang/internevo/train.py", line 375, in <module>
    objective(None)
  File "/juicefs-algorithm/workspace/nlp/li_wang/internevo/sweep.py", line 13, in intern_5m_sweep_objective
    return fn(args, trial)
  File "/juicefs-algorithm/workspace/nlp/li_wang/internevo/train.py", line 305, in main
    trial.report(loss.item(), batch_count)
  File "/opt/conda/lib/python3.10/site-packages/optuna_integration/pytorch_distributed.py", line 76, in wrapped
    ) = self._call_and_communicate_obj(fetch_properties)
  File "/opt/conda/lib/python3.10/site-packages/optuna_integration/pytorch_distributed.py", line 323, in _call_and_communicate_obj
    return self._broadcast(result)
  File "/opt/conda/lib/python3.10/site-packages/optuna_integration/pytorch_distributed.py", line 332, in _broadcast
    dist.broadcast(size_buffer, src=0, group=self._group)
  File "/opt/conda/lib/python3.10/site-packages/torch/distributed/c10d_logger.py", line 47, in wrapper
    return func(*args, **kwargs)
  File "/opt/conda/lib/python3.10/site-packages/torch/distributed/distributed_c10d.py", line 1914, in broadcast
    work.wait()
RuntimeError: [../third_party/gloo/gloo/transport/tcp/pair.cc:534] Connection closed by peer [127.0.1.1]:60819

2024-05-20 19:07:39,981	ERROR train.py:379 in <module> -- Raise exception from ubuntu-DeepLearning-4806050 with rank id: 4
Traceback (most recent call last):
  File "/opt/conda/lib/python3.10/site-packages/optuna_integration/pytorch_distributed.py", line 67, in wrapped
    return f(*args, **kwargs)
  File "/opt/conda/lib/python3.10/site-packages/optuna_integration/pytorch_distributed.py", line 237, in report
    raise err
json.decoder.JSONDecodeError: Extra data: line 1 column 2 (char 1)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/juicefs-algorithm/workspace/nlp/li_wang/internevo/train.py", line 375, in <module>
    objective(None)
  File "/juicefs-algorithm/workspace/nlp/li_wang/internevo/sweep.py", line 13, in intern_5m_sweep_objective
    return fn(args, trial)
  File "/juicefs-algorithm/workspace/nlp/li_wang/internevo/train.py", line 305, in main
    trial.report(loss.item(), batch_count)
  File "/opt/conda/lib/python3.10/site-packages/optuna_integration/pytorch_distributed.py", line 76, in wrapped
    ) = self._call_and_communicate_obj(fetch_properties)
  File "/opt/conda/lib/python3.10/site-packages/optuna_integration/pytorch_distributed.py", line 323, in _call_and_communicate_obj
    return self._broadcast(result)
  File "/opt/conda/lib/python3.10/site-packages/optuna_integration/pytorch_distributed.py", line 332, in _broadcast
    dist.broadcast(size_buffer, src=0, group=self._group)
  File "/opt/conda/lib/python3.10/site-packages/torch/distributed/c10d_logger.py", line 47, in wrapper
    return func(*args, **kwargs)
  File "/opt/conda/lib/python3.10/site-packages/torch/distributed/distributed_c10d.py", line 1914, in broadcast
    work.wait()
RuntimeError: [../third_party/gloo/gloo/transport/tcp/pair.cc:534] Connection closed by peer [127.0.0.1]:6860

Exception in thread Thread-3 (_pin_memory_loop):
Traceback (most recent call last):
  File "/opt/conda/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "/opt/conda/lib/python3.10/threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "/opt/conda/lib/python3.10/site-packages/torch/utils/data/_utils/pin_memory.py", line 54, in _pin_memory_loop
    do_one_step()
  File "/opt/conda/lib/python3.10/site-packages/torch/utils/data/_utils/pin_memory.py", line 31, in do_one_step
2024-05-20 19:07:45,412	ERROR train.py:379 in <module> -- Raise exception from ubuntu-DeepLearning-4806050 with rank id: 3
Traceback (most recent call last):
  File "/opt/conda/lib/python3.10/site-packages/optuna_integration/pytorch_distributed.py", line 67, in wrapped
    return f(*args, **kwargs)
  File "/opt/conda/lib/python3.10/site-packages/optuna_integration/pytorch_distributed.py", line 237, in report
    raise err
json.decoder.JSONDecodeError: Extra data: line 1 column 2 (char 1)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/juicefs-algorithm/workspace/nlp/li_wang/internevo/train.py", line 375, in <module>
    objective(None)
  File "/juicefs-algorithm/workspace/nlp/li_wang/internevo/sweep.py", line 13, in intern_5m_sweep_objective
    return fn(args, trial)
  File "/juicefs-algorithm/workspace/nlp/li_wang/internevo/train.py", line 305, in main
    trial.report(loss.item(), batch_count)
  File "/opt/conda/lib/python3.10/site-packages/optuna_integration/pytorch_distributed.py", line 76, in wrapped
    ) = self._call_and_communicate_obj(fetch_properties)
  File "/opt/conda/lib/python3.10/site-packages/optuna_integration/pytorch_distributed.py", line 323, in _call_and_communicate_obj
    return self._broadcast(result)
  File "/opt/conda/lib/python3.10/site-packages/optuna_integration/pytorch_distributed.py", line 332, in _broadcast
    dist.broadcast(size_buffer, src=0, group=self._group)
  File "/opt/conda/lib/python3.10/site-packages/torch/distributed/c10d_logger.py", line 47, in wrapper
    return func(*args, **kwargs)
  File "/opt/conda/lib/python3.10/site-packages/torch/distributed/distributed_c10d.py", line 1914, in broadcast
    work.wait()
RuntimeError: [../third_party/gloo/gloo/transport/tcp/pair.cc:534] Connection closed by peer [127.0.0.1]:7378

2024-05-20 19:07:45,417	ERROR train.py:379 in <module> -- Raise exception from ubuntu-DeepLearning-4806050 with rank id: 5
Traceback (most recent call last):
  File "/opt/conda/lib/python3.10/site-packages/optuna_integration/pytorch_distributed.py", line 67, in wrapped
    return f(*args, **kwargs)
  File "/opt/conda/lib/python3.10/site-packages/optuna_integration/pytorch_distributed.py", line 237, in report
    raise err
json.decoder.JSONDecodeError: Extra data: line 1 column 2 (char 1)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/juicefs-algorithm/workspace/nlp/li_wang/internevo/train.py", line 375, in <module>
    objective(None)
  File "/juicefs-algorithm/workspace/nlp/li_wang/internevo/sweep.py", line 13, in intern_5m_sweep_objective
    return fn(args, trial)
  File "/juicefs-algorithm/workspace/nlp/li_wang/internevo/train.py", line 305, in main
    trial.report(loss.item(), batch_count)
  File "/opt/conda/lib/python3.10/site-packages/optuna_integration/pytorch_distributed.py", line 76, in wrapped
    ) = self._call_and_communicate_obj(fetch_properties)
  File "/opt/conda/lib/python3.10/site-packages/optuna_integration/pytorch_distributed.py", line 323, in _call_and_communicate_obj
    return self._broadcast(result)
  File "/opt/conda/lib/python3.10/site-packages/optuna_integration/pytorch_distributed.py", line 332, in _broadcast
    dist.broadcast(size_buffer, src=0, group=self._group)
  File "/opt/conda/lib/python3.10/site-packages/torch/distributed/c10d_logger.py", line 47, in wrapper
    return func(*args, **kwargs)
  File "/opt/conda/lib/python3.10/site-packages/torch/distributed/distributed_c10d.py", line 1914, in broadcast
    work.wait()
RuntimeError: [../third_party/gloo/gloo/transport/tcp/pair.cc:534] Connection closed by peer [127.0.1.1]:33690

2024-05-20 19:07:45,429	ERROR train.py:379 in <module> -- Raise exception from ubuntu-DeepLearning-4806050 with rank id: 6
Traceback (most recent call last):
  File "/opt/conda/lib/python3.10/site-packages/optuna_integration/pytorch_distributed.py", line 67, in wrapped
    return f(*args, **kwargs)
  File "/opt/conda/lib/python3.10/site-packages/optuna_integration/pytorch_distributed.py", line 237, in report
    raise err
json.decoder.JSONDecodeError: Extra data: line 1 column 2 (char 1)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/juicefs-algorithm/workspace/nlp/li_wang/internevo/train.py", line 375, in <module>
    objective(None)
  File "/juicefs-algorithm/workspace/nlp/li_wang/internevo/sweep.py", line 13, in intern_5m_sweep_objective
    return fn(args, trial)
  File "/juicefs-algorithm/workspace/nlp/li_wang/internevo/train.py", line 305, in main
    trial.report(loss.item(), batch_count)
  File "/opt/conda/lib/python3.10/site-packages/optuna_integration/pytorch_distributed.py", line 76, in wrapped
    ) = self._call_and_communicate_obj(fetch_properties)
  File "/opt/conda/lib/python3.10/site-packages/optuna_integration/pytorch_distributed.py", line 323, in _call_and_communicate_obj
    return self._broadcast(result)
  File "/opt/conda/lib/python3.10/site-packages/optuna_integration/pytorch_distributed.py", line 332, in _broadcast
    dist.broadcast(size_buffer, src=0, group=self._group)
  File "/opt/conda/lib/python3.10/site-packages/torch/distributed/c10d_logger.py", line 47, in wrapper
    return func(*args, **kwargs)
  File "/opt/conda/lib/python3.10/site-packages/torch/distributed/distributed_c10d.py", line 1914, in broadcast
    work.wait()
RuntimeError: [../third_party/gloo/gloo/transport/tcp/pair.cc:534] Connection closed by peer [127.0.0.1]:20689

2024-05-20 19:07:50,793	ERROR train.py:379 in <module> -- Raise exception from ubuntu-DeepLearning-4806050 with rank id: 7
Traceback (most recent call last):
  File "/opt/conda/lib/python3.10/site-packages/optuna_integration/pytorch_distributed.py", line 67, in wrapped
    return f(*args, **kwargs)
  File "/opt/conda/lib/python3.10/site-packages/optuna_integration/pytorch_distributed.py", line 237, in report
    raise err
json.decoder.JSONDecodeError: Extra data: line 1 column 2 (char 1)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/juicefs-algorithm/workspace/nlp/li_wang/internevo/train.py", line 375, in <module>
    objective(None)
  File "/juicefs-algorithm/workspace/nlp/li_wang/internevo/sweep.py", line 13, in intern_5m_sweep_objective
    return fn(args, trial)
  File "/juicefs-algorithm/workspace/nlp/li_wang/internevo/train.py", line 305, in main
    trial.report(loss.item(), batch_count)
  File "/opt/conda/lib/python3.10/site-packages/optuna_integration/pytorch_distributed.py", line 76, in wrapped
    ) = self._call_and_communicate_obj(fetch_properties)
  File "/opt/conda/lib/python3.10/site-packages/optuna_integration/pytorch_distributed.py", line 323, in _call_and_communicate_obj
    return self._broadcast(result)
  File "/opt/conda/lib/python3.10/site-packages/optuna_integration/pytorch_distributed.py", line 332, in _broadcast
    dist.broadcast(size_buffer, src=0, group=self._group)
  File "/opt/conda/lib/python3.10/site-packages/torch/distributed/c10d_logger.py", line 47, in wrapper
    return func(*args, **kwargs)
  File "/opt/conda/lib/python3.10/site-packages/torch/distributed/distributed_c10d.py", line 1914, in broadcast
    work.wait()
RuntimeError: [../third_party/gloo/gloo/transport/tcp/pair.cc:534] Connection closed by peer [127.0.0.1]:14053

By the way here’s the version just to confirm:

>>> import optuna
>>> optuna.__version__
'4.0.0.dev'