[Bug]: MappingBase.to_dict() drops pp_partition

Aperta Adatta ai principianti
#23,394 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
65/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
backend

Direzione di ricerca

Leggi MappingBase.to_dict() in tensorrt_llm/mapping.py e i test di mapping in tests/unittest/others/test_mapping.py. Riproduci il round-trip con un pp_partition personalizzato, poi verifica che Mapping.from_dict(m.to_dict()) lo conservi e che modificare la lista esportata non cambi l’originale. L’issue descrive il comportamento previsto e la posizione del test.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Inference runtime Windows
System Info
  • OS: Windows 11 (x86_64) — reproduced directly against NVIDIA/TensorRT-LLM main (1d379e2b4)
  • Python: 3.14 (CPU-only pure-Python unit reproduction; tensorrt_llm/mapping.py is pure Python)
  • TensorRT-LLM commit: 1d379e2b4 (origin/main)
Who can help?

@Shixiaowei02 @funatiq (listed under Inference runtime in .github/workflows/module-owners.json / @NVIDIA/trt-llm-runtime-devs in CODEOWNERS).

I already have a minimal fix and regression unit test ready locally and would be happy to open the PR if a maintainer agrees this should proceed.

Information
  • The official example scripts
  • My own modified scripts
Tasks
  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)
Reproduction

MappingBase.to_dict() in tensorrt_llm/mapping.py (around lines 472–491 on 1d379e2b4) exports all constructor parameters of MappingBase.__init__ except pp_partition. Calling Mapping.from_dict(m.to_dict()) or Mapping(**m.to_dict()) silently resets pp_partition to None.

Minimal reproduction:

from tensorrt_llm.mapping import Mapping

m1 = Mapping(
    world_size=2,
    rank=0,
    tp_size=1,
    pp_size=2,
    pp_partition=[10, 22],
)
as_dict = m1.to_dict()
m2 = Mapping.from_dict(as_dict)

assert "pp_partition" in as_dict, f"missing pp_partition key: {sorted(as_dict.keys())}"

Inspecting the resulting objects without modifying MappingBase.to_dict():

m1.pp_partition = [10, 22]
m2.pp_partition = None
m1 == m2 -> False
m1.pp_layers(32) = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
m2.pp_layers(32) = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
Expected behavior

MappingBase.to_dict() should include 'pp_partition': copy.copy(self.pp_partition) so that:

  • Mapping.from_dict(m.to_dict()) and Mapping(**m.to_dict()) preserve custom pp_partition values (m2 == m1, hash(m2) == hash(m1), identical pp_layers() and pp_rank_of_layer()).
  • Mutating the exported list in the returned dict does not mutate m.pp_partition.
actual behavior

MappingBase.to_dict() omits 'pp_partition', so any Mapping.from_dict(m.to_dict()) or Mapping(**m.to_dict()) round-trip silently drops pp_partition to None and reverts to uniform layer partitioning across PP ranks.

additional notes

Real callers affected on main (1d379e2b4):

  • tensorrt_llm/_torch/pyexecutor/py_executor_creator.py (lines 955–958):
    mapping = Mapping(**{
        **mapping.to_dict(), "dwdp_size": dwdp_size,
        "dwdp_rank": dwdp_rank
    })
    
    When expert DWDP (dwdp_size > 1) is combined with a custom pp_partition, this call silently resets pp_partition to None before creating Distributed.get(mapping) and the executor.
  • tensorrt_llm/_torch/models/modeling_kimi_linear.py (lines 2151–2155):
    mapping_dict = mapping.to_dict()
    mapping_dict["moe_cluster_size"] = 1
    mapping_dict["moe_tp_size"] = moe_tp
    mapping_dict["moe_ep_size"] = moe_ep
    routed_mapping = Mapping.from_dict(mapping_dict)
    
    Similarly drops any custom pp_partition on routed_mapping.

Note: Adding 'pp_partition': copy.copy(self.pp_partition) in MappingBase.to_dict() is a minimal 1-line fix; I have it ready locally alongside parametrized regression tests in tests/unittest/others/test_mapping.py and will open the PR once confirmed.

Before submitting a new issue...
  • Make sure you already searched for relevant issues, and checked the documentation and examples for answers to frequently asked questions.
Lingua principale
Python
Stelle
15.2k
Fork
3k
Merge medio
2g 21h
PR unite (30g)
477

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di NVIDIA/TensorRT-LLM

Tutte le issue di NVIDIA/TensorRT-LLM

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.