Skip to content

Allocate fused MoE bias parameters in the locality-domain device context #18336

Closed

Description

@coderabbitai

Summary

FusedMoEMethodBase.create_weights selects device=torch.device("cuda") when a locality-domain weight context is active. It applies this device to w3_w1_weight and w2_weight, but not to w3_w1_bias and w2_bias.

Required change

Update tensorrt_llm/_torch/modules/fused_moe/quantization.py so both bias torch.empty(...) allocations in FusedMoEMethodBase.create_weights receive device=device.

Rationale

When module.bias is enabled in partition_weight_context(), the current code can allocate weights on CUDA while bias parameters use the ambient device. This can place related parameters on different devices and prevents the biases from using the locality-domain memory pool.

Acceptance criteria

  • w3_w1_bias and w2_bias use the same device variable as w3_w1_weight and w2_weight.
  • The behavior is unchanged when module.bias is disabled.
  • The non-locality-domain path continues to use the existing default allocation behavior.

Backlinks

Requested by: @farazkh80

Activity

  1. farazkh80 commented on Sep 17, 2026

    @farazkh80
    Collaborator

    Already handled on main: in tensorrt_llm/_torch/moe/fused_moe/quantization.py the device chosen for locality-domain weights (torch.device('cuda') when a locality-domain context is active) is passed to both w3_w1_bias and w2_bias allocations as well as the weights, since #18369 merged. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Pytorch<NV>Pytorch backend related issues

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions