Repository navigation
fix(analytic): treat --device-num as data-parallel replicas - #123
Merged
Merged
Conversation
llama_model.py and gpt_oss_model.py split the batch over device_num devices with floor division, then divided TTFT (and LLaDA's total time) by device_num again. Each device already prefills only its own sequences, so TTFT came out device_num times too small. A batch smaller than device_num left every device with zero sequences: llama-3.1-70b with batch 16 on 32 devices reported a TTFT of 0.00015 ms and 5,000,000 tokens/s. An uneven batch dropped sequences from the busiest device's time while TPS still counted them. Treat the devices as data-parallel replicas. The busiest one serves ceil(batch / device_num) sequences and sets TTFT and the decode time, TPS counts the whole batch, and device_num < 1 is rejected. A single device is unchanged. Communication between devices is still not modelled.
GeorgeWu1204
self-requested a review
October 25, 2026 15:47
GeorgeWu1204
approved these changes
Oct 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
llama_model.pyandgpt_oss_model.pysplit the batch over--device-numdevices with floor division (batch_size // device_num), then divided TTFT (and LLaDA's total time) bydevice_numagain:device_numtimes too small. Each device already prefills only its own sequences, so the second division counts the speed-up twice.device_numgave every device zero sequences. For example, llama-3.1-70b with batch 16 on 32 devices reported a TTFT of 0.00015 ms and 5,000,000 tokens/s.The devices are now data-parallel replicas:
ceil(batch / device_num)sequences and sets TTFT and the decode time;device_num < 1is rejected.A single device is unchanged. Communication between devices is still not modelled.
Before / after
--json, input 2048, output 1024, defaultplena_settings.toml:After the fix, N devices with batch N·b give the TTFT of one device with batch b and N times its TPS.
Tests
analytic_models/performance/tests/test_device_num.pyadds 9 tests, for both scripts:device_num=0is rejected.All 9 fail on
mainand pass here.ruff format --check .andruff check .pass with the locked ruff.Also in this PR
d34ba4abis the same change as #121's093de4ea, which makesanalytic_modelsimportable. Without it, pytest cannot collect anything underanalytic_modelsonmain.#103 and #118 carry their own version of that fix. Whichever lands first, the others resolve
analytic_models/__init__.pyby keeping the union of imports. Thellama_model.pychanges here merge cleanly with #103.