MCPcopy Create free account
hub / github.com/bitsandbytes-foundation/bitsandbytes / __getattr__

Method __getattr__

bitsandbytes/functional.py:461–471  ·  view source on GitHub ↗
(self, name)

Source from the content-addressed store, hash-verified

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 """

Callers

nothing calls this directly

Calls 1

as_dictMethod · 0.95

Tested by

no test coverage detected