| 206 | return any(len(self.buckets[(p, t)]) > 0 for t in self._owned_t_buckets) |
| 207 | |
| 208 | def stats(self): |
| 209 | filled = sum(1 for b in self.buckets.values() if len(b) > 0) |
| 210 | total = sum(len(b) for b in self.buckets.values()) |
| 211 | num_owned_t = len(self._owned_t_buckets) |
| 212 | denom = self.num_blocks * num_owned_t if self.num_blocks > 0 else num_owned_t |
| 213 | out = { |
| 214 | "total_added": self.total_added, |
| 215 | "filled_buckets": f"{filled}/{denom}", |
| 216 | "total_entries": total, |
| 217 | } |
| 218 | if self.shard_size > 1: |
| 219 | out["shard"] = f"shard_rank={self.shard_rank}/{self.shard_size} ({num_owned_t}/{self.num_buckets} t-buckets)" |
| 220 | if self.num_blocks > 0: |
| 221 | lo = self.global_block_offset |
| 222 | hi = self.global_block_offset + self.num_blocks |
| 223 | out["global_block_range"] = f"[{lo},{hi})" |
| 224 | return out |
| 225 | |
| 226 | def state_dict(self): |
| 227 | # Keys are tuples (pos, t) when 2D — torch.save handles them fine |