TypeError: slice indices must be integers or None or have an __index__ method

Any idea what might be the cause? Thanks team!

Traceback (most recent call last):
  File "/root/miniconda3/envs/firl/lib/python3.8/site-packages/ray/tune/trial_runner.py", line 924, in _process_trial
    results = self.trial_executor.fetch_result(trial)
  File "/root/miniconda3/envs/firl/lib/python3.8/site-packages/ray/tune/ray_trial_executor.py", line 787, in fetch_result
    result = ray.get(trial_future[0], timeout=DEFAULT_GET_TIMEOUT)
  File "/root/miniconda3/envs/firl/lib/python3.8/site-packages/ray/_private/client_mode_hook.py", line 105, in wrapper
    return func(*args, **kwargs)
  File "/root/miniconda3/envs/firl/lib/python3.8/site-packages/ray/worker.py", line 1713, in get
    raise value.as_instanceof_cause()
ray.exceptions.RayTaskError(TypeError): ray::PPO.train() (pid=12757, ip=172.17.0.18, repr=PPO)
  File "/root/miniconda3/envs/firl/lib/python3.8/site-packages/ray/tune/trainable.py", line 314, in train
    result = self.step()
  File "/root/miniconda3/envs/firl/lib/python3.8/site-packages/ray/rllib/agents/trainer.py", line 885, in step
    raise e
  File "/root/miniconda3/envs/firl/lib/python3.8/site-packages/ray/rllib/agents/trainer.py", line 867, in step
    result = self.step_attempt()
  File "/root/miniconda3/envs/firl/lib/python3.8/site-packages/ray/rllib/agents/trainer.py", line 925, in step_attempt
    step_results = next(self.train_exec_impl)
  File "/root/miniconda3/envs/firl/lib/python3.8/site-packages/ray/util/iter.py", line 756, in __next__
    return next(self.built_iterator)
  File "/root/miniconda3/envs/firl/lib/python3.8/site-packages/ray/util/iter.py", line 783, in apply_foreach
    for item in it:
  File "/root/miniconda3/envs/firl/lib/python3.8/site-packages/ray/util/iter.py", line 783, in apply_foreach
    for item in it:
  File "/root/miniconda3/envs/firl/lib/python3.8/site-packages/ray/util/iter.py", line 843, in apply_filter
    for item in it:
  File "/root/miniconda3/envs/firl/lib/python3.8/site-packages/ray/util/iter.py", line 843, in apply_filter
    for item in it:
  File "/root/miniconda3/envs/firl/lib/python3.8/site-packages/ray/util/iter.py", line 783, in apply_foreach
    for item in it:
  File "/root/miniconda3/envs/firl/lib/python3.8/site-packages/ray/util/iter.py", line 783, in apply_foreach
    for item in it:
  File "/root/miniconda3/envs/firl/lib/python3.8/site-packages/ray/util/iter.py", line 791, in apply_foreach
    result = fn(item)
  File "/root/miniconda3/envs/firl/lib/python3.8/site-packages/ray/rllib/execution/train_ops.py", line 197, in __call__
    results = policy.learn_on_loaded_batch(
  File "/root/miniconda3/envs/firl/lib/python3.8/site-packages/ray/rllib/policy/torch_policy.py", line 532, in learn_on_loaded_batch
    batch = self._loaded_batches[0][0][offset:offset +
  File "/root/miniconda3/envs/firl/lib/python3.8/site-packages/ray/rllib/policy/sample_batch.py", line 696, in __getitem__
    return self._slice(key)
  File "/root/miniconda3/envs/firl/lib/python3.8/site-packages/ray/rllib/policy/sample_batch.py", line 909, in _slice
    data = tree.map_structure(lambda value: value[start:stop], self)
  File "/root/miniconda3/envs/firl/lib/python3.8/site-packages/tree/__init__.py", line 510, in map_structure
    [func(*args) for args in zip(*map(flatten, structures))])
  File "/root/miniconda3/envs/firl/lib/python3.8/site-packages/tree/__init__.py", line 510, in <listcomp>
    [func(*args) for args in zip(*map(flatten, structures))])
  File "/root/miniconda3/envs/firl/lib/python3.8/site-packages/ray/rllib/policy/sample_batch.py", line 909, in <lambda>
    data = tree.map_structure(lambda value: value[start:stop], self)
TypeError: slice indices must be integers or None or have an __index__ method

That’s a tricky one, but solved. I wrongly give sgd_minibatch_size=10.0, it should be sgd_minibatch_size=10.

Maybe future we can have type assertion for those variables, Thanks!