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

Class CheckpointedNet

tests/test_linear4bit.py:483–503  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

481 torch.compiler.reset()
482
483 class CheckpointedNet(torch.nn.Module):
484 def __init__(self):
485 super().__init__()
486 self.layers = torch.nn.ModuleList(
487 [
488 bnb.nn.Linear4bit(
489 dim,
490 dim,
491 bias=False,
492 compute_dtype=compute_dtype,
493 compress_statistics=compress_statistics,
494 quant_type=quant_type,
495 )
496 for _ in range(4)
497 ]
498 )
499
500 def forward(self, x):
501 for layer in self.layers:
502 x = torch.utils.checkpoint.checkpoint(layer, x, use_reentrant=False)
503 return x
504
505 net = CheckpointedNet().to(device)
506

Calls

no outgoing calls