# \[Developer Question\] How are the position indices updated?

**URL:** <https://discuss.vllm.ai/t/developer-question-how-are-the-position-indices-updated/193>\
**Category:** General\
**Created:** [March 22, 2025, 2:40pm UTC](https://discuss.vllm.ai/t/developer-question-how-are-the-position-indices-updated/193 "2025-03-22T14:40:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![XMaster96](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.vllm.ai/xmaster96/32/40_2.png) [@XMaster96](https://discuss.vllm.ai/u/XMaster96)\
**Post date:** [March 22, 2025, 2:40pm UTC](https://discuss.vllm.ai/t/developer-question-how-are-the-position-indices-updated/193/1 "2025-03-22T14:40:34Z")

</div>

So I am right now in the process of adding some guide custom model support to VLLM which requires me to keep track of which [input\_ids](https://github.com/vllm-project/vllm/blob/2f4bd358f1d39846a38e8f61d11edfa446617dcd/vllm/v1/worker/gpu_model_runner.py#L1037) belong to which request\_id. My assumption is that something similar is happening for the positions. So I tried to track back how they are set and updated.

positions seems to be a slice of [self.positions](https://github.com/vllm-project/vllm/blob/2f4bd358f1d39846a38e8f61d11edfa446617dcd/vllm/v1/worker/gpu_model_runner.py#L1018) which is updated with self.positions\_cpu. But I just can’t figure out how self.positions\_cpu is being updated. I string searched the entire code base and it is not a common variable name. So my assumption is it somewhere needs to be updated in place, but I have no idea where.

can someone maybe explain to me how this is being handled?

Thank you for your help in advance!

---

<div class="post-metadata">

**Author:** ![XMaster96](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.vllm.ai/xmaster96/32/40_2.png) [@XMaster96](https://discuss.vllm.ai/u/XMaster96)\
**Post date:** [March 22, 2025, 3:04pm UTC](https://discuss.vllm.ai/t/developer-question-how-are-the-position-indices-updated/193/2 "2025-03-22T15:04:25Z")

</div>

Ah I just found it out myself, it is happening even in the same file in `_prepare_inputs`. And what I need to correlate the input tokens with the request IDs is `req_indices`.

---

<div class="post-metadata">

**Author:** ![XMaster96](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.vllm.ai/xmaster96/32/40_2.png) [@XMaster96](https://discuss.vllm.ai/u/XMaster96)\
**Post date:** [March 22, 2025, 3:45pm UTC](https://discuss.vllm.ai/t/developer-question-how-are-the-position-indices-updated/193/3 "2025-03-22T15:45:16Z")

</div>

Nope, so apparently `req_indices` does not correlate to the request\_ids, sad

---

<div class="post-metadata">

**Author:** ![XMaster96](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.vllm.ai/xmaster96/32/40_2.png) [@XMaster96](https://discuss.vllm.ai/u/XMaster96)\
**Post date:** [March 22, 2025, 3:50pm UTC](https://discuss.vllm.ai/t/developer-question-how-are-the-position-indices-updated/193/4 "2025-03-22T15:50:53Z")

</div>

Obviously it was not that it is just a slice of a pre-allocated arrange

---

<div class="post-metadata">

**Author:** ![XMaster96](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.vllm.ai/xmaster96/32/40_2.png) [@XMaster96](https://discuss.vllm.ai/u/XMaster96)\
**Post date:** [March 22, 2025, 3:54pm UTC](https://discuss.vllm.ai/t/developer-question-how-are-the-position-indices-updated/193/5 "2025-03-22T15:54:00Z")

</div>

Oh, `self.input_batch` has a `req_id_to_index` mapping dict

Nice
