| 459 | self.nested = state2 is not None |
| 460 | |
| 461 | def __getattr__(self, name): |
| 462 | # Support attribute access for packed state_dict keys like "bitsandbytes__nf4". |
| 463 | # PyTorch's FSDP state_dict traversal (_get_fqns) resolves dotted FQN paths via |
| 464 | # getattr. The packed key "quant_state.bitsandbytes__nf4" causes it to call |
| 465 | # getattr(quant_state_obj, "bitsandbytes__nf4"), which we handle here. |
| 466 | if name.startswith("bitsandbytes__"): |
| 467 | qs_dict = self.as_dict(packed=True) |
| 468 | packed_key = "quant_state." + name |
| 469 | if packed_key in qs_dict: |
| 470 | return qs_dict[packed_key] |
| 471 | raise AttributeError(f"'{type(self).__name__}' object has no attribute '{name}'") |
| 472 | |
| 473 | def __getitem__(self, idx): |
| 474 | """ |