Repository navigation
[Bugfix] Fix bitwise determinism after vLLM SiluAndMul change - #2358
Conversation
556ae85 to
5a68847
Compare
| # Since these are parameter free we instantiate default config | ||
| with set_current_vllm_config(VllmConfig()): | ||
| vllm_silu_and_mul = VLLMSiluAndMul() | ||
| vllm_silu_and_mul = VLLMSiluAndMul(compile_native=False) |
There was a problem hiding this comment.
Does compile_native=False means we don't use torch.compile inside the custom op? Can you add a line of comment to explain why this field is neede? Thanks!
There was a problem hiding this comment.
n00b q: Is vllm_compat path using vllm's compile mechanism, or it applies compile manually? Or compile is not yet enabled?
NOTE: if we enable compile in vLLM in the future, we need to compile this op as well.
I'm a little bit confused here, and want to high-levely understand how we should enable compile properly. IIUC there should be 2 ways of applying compile:
- apply compile by ourself, like
apply_compile()function, and send the compiled model to vllm (set vllm.compilation_config.level =0); - Let vllm engine enable compile (vllm.compilation_config.level = 3), and decorate our model with decorator @support_torch_compile
There was a problem hiding this comment.
Currently there is no compile enabled yet - however, we can compile either the vLLM model or (inclusive) the torch.Titan model.
-
To compile the vLLM model, we would need
enforce_eager=Falsethen setting the vllm.compilation_config to our desired level of opimizations. This won't affect the numerics of torch titan definition -
To compile the torchtitan model, we would need to apply torch compile (there are some options for how we can do this, but we should in general start with aot_eager backend for numerics). This will not affect the numerics of the vLLM definition
Hopefully that clarifies - we have two levers for compile which do not interact so we can (and should) see how we can leverage both
278337a to
972b13b
Compare
972b13b to
7981609
Compare
…h#2358) ## Summary vllm-project/vllm#32806 Changed the behavior of `SiluAndMul` to use `torch.compile` inside the custom op. This causes a divergence in the vllm definition and torchtitan definition, causing the RL script to fail We fix this by changing the implementation to call through to the kernel used in vLLM for equivalence ## Test Plan ```bash VLLM_BATCH_INVARIANT=1 VLLM_FLASH_ATTN_VERSION=3 python -m torchtitan.experiments.rl.vllm_compat.simple_rl ``` ### Before (Main) ```bash ⚠ vLLM-TorchTitan logprobs differ: 59/100 tokens Max delta: 3.650573e-01, Avg delta: 1.829216e-02 vLLM logprobs: ['-0.0642131940', '-0.1617958397', '-0.0011243457', '-0.0051660384', '-0.2546415329'] TorchTitan logprobs: ['-0.0609663166', '-0.1456209123', '-0.0010027625', '-0.0048254938', '-0.2543271184'] ``` ### After ```bash INFO 02-09 15:18:20 [llm.py:343] Supported tasks: ['generate'] ✓ Created new vLLM engine Adding requests: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 10/10 [00:00<00:00, 402.86it/s] Processed prompts: 100%|████████████████████████████████████████████████████████| 80/80 [00:03<00:00, 22.59it/s, est. speed input: 1473.08 toks/s, output: 2259.32 toks/s] ✓ vLLM-TorchTitan bitwise determinism verified: 100 tokens match exactly Adding requests: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 10/10 [00:00<00:00, 495.83it/s] Processed prompts: 100%|████████████████████████████████████████████████████████| 80/80 [00:03<00:00, 24.28it/s, est. speed input: 1583.37 toks/s, output: 2428.49 toks/s] ✓ vLLM-TorchTitan bitwise determinism verified: 100 tokens match exactly ```
…h#2358) ## Summary vllm-project/vllm#32806 Changed the behavior of `SiluAndMul` to use `torch.compile` inside the custom op. This causes a divergence in the vllm definition and torchtitan definition, causing the RL script to fail We fix this by changing the implementation to call through to the kernel used in vLLM for equivalence ## Test Plan ```bash VLLM_BATCH_INVARIANT=1 VLLM_FLASH_ATTN_VERSION=3 python -m torchtitan.experiments.rl.vllm_compat.simple_rl ``` ### Before (Main) ```bash ⚠ vLLM-TorchTitan logprobs differ: 59/100 tokens Max delta: 3.650573e-01, Avg delta: 1.829216e-02 vLLM logprobs: ['-0.0642131940', '-0.1617958397', '-0.0011243457', '-0.0051660384', '-0.2546415329'] TorchTitan logprobs: ['-0.0609663166', '-0.1456209123', '-0.0010027625', '-0.0048254938', '-0.2543271184'] ``` ### After ```bash INFO 02-09 15:18:20 [llm.py:343] Supported tasks: ['generate'] ✓ Created new vLLM engine Adding requests: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 10/10 [00:00<00:00, 402.86it/s] Processed prompts: 100%|████████████████████████████████████████████████████████| 80/80 [00:03<00:00, 22.59it/s, est. speed input: 1473.08 toks/s, output: 2259.32 toks/s] ✓ vLLM-TorchTitan bitwise determinism verified: 100 tokens match exactly Adding requests: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 10/10 [00:00<00:00, 495.83it/s] Processed prompts: 100%|████████████████████████████████████████████████████████| 80/80 [00:03<00:00, 24.28it/s, est. speed input: 1583.37 toks/s, output: 2428.49 toks/s] ✓ vLLM-TorchTitan bitwise determinism verified: 100 tokens match exactly ```
Summary
vllm-project/vllm#32806 Changed the behavior of
SiluAndMulto usetorch.compileinside the custom op. This causes a divergence in the vllm definition and torchtitan definition, causing the RL script to failWe fix this by changing the implementation to call through to the kernel used in vLLM for equivalence
Test Plan
Before (Main)
⚠ vLLM-TorchTitan logprobs differ: 59/100 tokens Max delta: 3.650573e-01, Avg delta: 1.829216e-02 vLLM logprobs: ['-0.0642131940', '-0.1617958397', '-0.0011243457', '-0.0051660384', '-0.2546415329'] TorchTitan logprobs: ['-0.0609663166', '-0.1456209123', '-0.0010027625', '-0.0048254938', '-0.2543271184']After