Skip to content

Commit

Permalink
suppress errors in deeplearning/fbgemm/fbgemm_gpu
Browse files Browse the repository at this point in the history
Differential Revision: D47398494

fbshipit-source-id: bc4ee6710be8309f1235f49383f62f1b85aef573
  • Loading branch information
generatedunixname89002005307016 authored and facebook-github-bot committed Jul 12, 2023
1 parent eea19e8 commit 07c3f6b
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 179 deletions.
2 changes: 0 additions & 2 deletions fbgemm_gpu/bench/sparse_ops_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ def gen_inverse_index(curr_size: int, final_size: int) -> np.array:
else:
raise RuntimeError(f"Does not support data type {input_precision}")

# pyre-fixme[16]: Module `cuda` has no attribute `IntTensor`.
indices = torch.cuda.IntTensor(gen_inverse_index(unique_batch_size, batch_size))

input = torch.rand(unique_batch_size, row_size, dtype=dtype, device="cuda")
Expand Down Expand Up @@ -260,7 +259,6 @@ def gen_inverse_index(curr_size: int, final_size: int) -> np.array:
offset_indices_group = []
indices_group = []
for i in range(num_groups):
# pyre-fixme[16]: Module `cuda` has no attribute `IntTensor`.
indices = torch.cuda.IntTensor(gen_inverse_index(unique_batch_size, batch_size))
if sort_indices:
indices, _ = indices.sort()
Expand Down
4 changes: 0 additions & 4 deletions fbgemm_gpu/bench/split_embeddings_cache_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,10 +416,8 @@ def replay_populate(linear_indices: Tensor) -> None:

total_rows = 0
for request in requests:
# pyre-ignore
prev = replay_cc.lxu_cache_state.clone().detach()
replay_populate(request)
# pyre-ignore
after = replay_cc.lxu_cache_state.clone().detach()

diff = after - prev
Expand Down Expand Up @@ -535,10 +533,8 @@ def replay_populate(linear_indices: Tensor) -> None:

total_rows = 0
for request in requests:
# pyre-ignore
prev = replay_cc.lxu_cache_state.clone().detach()
replay_populate(request)
# pyre-ignore
after = replay_cc.lxu_cache_state.clone().detach()

diff = after - prev
Expand Down
18 changes: 2 additions & 16 deletions fbgemm_gpu/bench/split_table_batched_embeddings_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -693,17 +693,10 @@ def cache( # noqa C901
exchanged_cache_lines = []
NOT_FOUND = -1
for indices, offsets, _ in requests:
# pyre-fixme[29]:
# `Union[BoundMethod[typing.Callable(Tensor.clone)[[Named(self,
# Variable[torch._TTensor (bound to Tensor)])], Variable[torch._TTensor (bound
# to Tensor)]], Tensor], Tensor, torch.nn.Module]` is not a function.
old_lxu_cache_state = emb.lxu_cache_state.clone()
emb.prefetch(indices.long(), offsets.long())
exchanged_cache_lines.append(
# pyre-fixme[16]: `bool` has no attribute `sum`.
(emb.lxu_cache_state != old_lxu_cache_state)
.sum()
.item()
(emb.lxu_cache_state != old_lxu_cache_state).sum().item()
)
cache_misses.append((emb.lxu_cache_locations_list[0] == NOT_FOUND).sum().item())
emb.forward(indices.long(), offsets.long())
Expand Down Expand Up @@ -2064,17 +2057,10 @@ def nbit_cache( # noqa C901
emb.reset_uvm_cache_stats()

for indices, offsets, _ in requests:
# pyre-fixme[29]:
# `Union[BoundMethod[typing.Callable(Tensor.clone)[[Named(self,
# Variable[torch._TTensor (bound to Tensor)])], Variable[torch._TTensor (bound
# to Tensor)]], Tensor], Tensor, torch.nn.Module]` is not a function.
old_lxu_cache_state = emb.lxu_cache_state.clone()
emb.prefetch(indices, offsets)
exchanged_cache_lines.append(
# pyre-fixme[16]: `bool` has no attribute `sum`.
(emb.lxu_cache_state != old_lxu_cache_state)
.sum()
.item()
(emb.lxu_cache_state != old_lxu_cache_state).sum().item()
)
cache_misses.append(
(emb.lxu_cache_locations_list.top() == NOT_FOUND).sum().item()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,9 +490,6 @@ def print_uvm_cache_stats(self) -> None:
def prefetch(self, indices: Tensor, offsets: Tensor) -> None:
self.timestep_counter.increment()
self.timestep_prefetch_size.increment()
# pyre-fixme[29]:
# `Union[BoundMethod[typing.Callable(Tensor.numel)[[Named(self, Tensor)],
# int], Tensor], Tensor, nn.Module]` is not a function.
if not self.lxu_cache_weights.numel():
return

Expand Down Expand Up @@ -669,9 +666,6 @@ def _update_tablewise_cache_miss(
CACHE_MISS = torch.tensor([-1], device=self.current_device, dtype=torch.int32)
CACHE_HIT = torch.tensor([-2], device=self.current_device, dtype=torch.int32)

# pyre-ignore[6]:
# Incompatible parameter type [6]: Expected `typing.Sized` for 1st
# positional only parameter to call `len` but got `typing.Union[Tensor, nn.Module]`.
num_tables = len(self.cache_hash_size_cumsum) - 1
num_offsets_per_table = (len(offsets) - 1) // num_tables
cache_missed_locations = torch.where(
Expand Down Expand Up @@ -1128,9 +1122,6 @@ def _apply_cache_state(
self.reset_uvm_cache_stats()

def reset_cache_states(self) -> None:
# pyre-fixme[29]:
# `Union[BoundMethod[typing.Callable(Tensor.numel)[[Named(self, Tensor)],
# int], Tensor], Tensor, nn.Module]` is not a function.
if not self.lxu_cache_weights.numel():
return
self.lxu_cache_state.fill_(-1)
Expand Down Expand Up @@ -1500,9 +1491,6 @@ def embedding_inplace_update_internal(
)

lxu_cache_locations = None
# pyre-fixme[29]:
# `Union[BoundMethod[typing.Callable(Tensor.numel)[[Named(self, Tensor)],
# int], Tensor], Tensor, nn.Module]` is not a function.
if self.lxu_cache_weights.numel() > 0:
linear_cache_indices = (
torch.ops.fbgemm.linearize_cache_indices_from_row_idx(
Expand Down
123 changes: 0 additions & 123 deletions fbgemm_gpu/fbgemm_gpu/split_table_batched_embeddings_ops_training.py
Original file line number Diff line number Diff line change
Expand Up @@ -803,8 +803,6 @@ def get_cache_miss_counter(self) -> Tensor:
# The first one is cache_miss_forward_count which records the total number of forwards which has at least one cache miss
# The second one is the unique_cache_miss_count which records to total number of unique (dedup) cache misses

# pyre-fixme[7]: Expected `Tensor` but got `typing.Union[Tensor,
# nn.Module]`.
return self.cache_miss_counter

@torch.jit.export
Expand Down Expand Up @@ -930,23 +928,11 @@ def forward( # noqa: C901
)
common_args = invokers.lookup_args.CommonArgs(
placeholder_autograd_tensor=self.placeholder_autograd_tensor,
# pyre-fixme[6]: Expected `Tensor` for 2nd param but got `Union[Tensor,
# nn.Module]`.
dev_weights=self.weights_dev,
# pyre-fixme[6]: Expected `Tensor` for 3rd param but got `Union[Tensor,
# nn.Module]`.
host_weights=self.weights_host,
# pyre-fixme[6]: Expected `Tensor` for 4th param but got `Union[Tensor,
# nn.Module]`.
uvm_weights=self.weights_uvm,
# pyre-fixme[6]: Expected `Tensor` for 5th param but got `Union[Tensor,
# nn.Module]`.
lxu_cache_weights=self.lxu_cache_weights,
# pyre-fixme[6]: Expected `Tensor` for 6th param but got `Union[Tensor,
# nn.Module]`.
weights_placements=self.weights_placements,
# pyre-fixme[6]: Expected `Tensor` for 7th param but got `Union[Tensor,
# nn.Module]`.
weights_offsets=self.weights_offsets,
D_offsets=self.D_offsets,
total_D=self.total_D,
Expand Down Expand Up @@ -976,20 +962,10 @@ def forward( # noqa: C901
return invokers.lookup_sgd.invoke(common_args, self.optimizer_args)

momentum1 = invokers.lookup_args.Momentum(
# pyre-fixme[6]: Expected `Tensor` for 1st param but got `Union[Tensor,
# nn.Module]`.
dev=self.momentum1_dev,
# pyre-fixme[6]: Expected `Tensor` for 2nd param but got `Union[Tensor,
# nn.Module]`.
host=self.momentum1_host,
# pyre-fixme[6]: Expected `Tensor` for 3rd param but got `Union[Tensor,
# nn.Module]`.
uvm=self.momentum1_uvm,
# pyre-fixme[6]: Expected `Tensor` for 4th param but got `Union[Tensor,
# nn.Module]`.
offsets=self.momentum1_offsets,
# pyre-fixme[6]: Expected `Tensor` for 5th param but got `Union[Tensor,
# nn.Module]`.
placements=self.momentum1_placements,
)

Expand All @@ -1003,20 +979,10 @@ def forward( # noqa: C901
)

momentum2 = invokers.lookup_args.Momentum(
# pyre-fixme[6]: Expected `Tensor` for 1st param but got `Union[Tensor,
# nn.Module]`.
dev=self.momentum2_dev,
# pyre-fixme[6]: Expected `Tensor` for 2nd param but got `Union[Tensor,
# nn.Module]`.
host=self.momentum2_host,
# pyre-fixme[6]: Expected `Tensor` for 3rd param but got `Union[Tensor,
# nn.Module]`.
uvm=self.momentum2_uvm,
# pyre-fixme[6]: Expected `Tensor` for 4th param but got `Union[Tensor,
# nn.Module]`.
offsets=self.momentum2_offsets,
# pyre-fixme[6]: Expected `Tensor` for 5th param but got `Union[Tensor,
# nn.Module]`.
placements=self.momentum2_placements,
)
# Ensure iter is always on CPU so the increment doesn't synchronize.
Expand Down Expand Up @@ -1075,37 +1041,17 @@ def forward( # noqa: C901
)

prev_iter = invokers.lookup_args.Momentum(
# pyre-fixme[6]: Expected `Tensor` for 1st param but got `Union[Tensor,
# nn.Module]`.
dev=self.prev_iter_dev,
# pyre-fixme[6]: Expected `Tensor` for 2nd param but got `Union[Tensor,
# nn.Module]`.
host=self.prev_iter_host,
# pyre-fixme[6]: Expected `Tensor` for 3rd param but got `Union[Tensor,
# nn.Module]`.
uvm=self.prev_iter_uvm,
# pyre-fixme[6]: Expected `Tensor` for 4th param but got `Union[Tensor,
# nn.Module]`.
offsets=self.prev_iter_offsets,
# pyre-fixme[6]: Expected `Tensor` for 5th param but got `Union[Tensor,
# nn.Module]`.
placements=self.prev_iter_placements,
)
row_counter = invokers.lookup_args.Momentum(
# pyre-fixme[6]: Expected `Tensor` for 1st param but got `Union[Tensor,
# nn.Module]`.
dev=self.row_counter_dev,
# pyre-fixme[6]: Expected `Tensor` for 2nd param but got `Union[Tensor,
# nn.Module]`.
host=self.row_counter_host,
# pyre-fixme[6]: Expected `Tensor` for 3rd param but got `Union[Tensor,
# nn.Module]`.
uvm=self.row_counter_uvm,
# pyre-fixme[6]: Expected `Tensor` for 4th param but got `Union[Tensor,
# nn.Module]`.
offsets=self.row_counter_offsets,
# pyre-fixme[6]: Expected `Tensor` for 5th param but got `Union[Tensor,
# nn.Module]`.
placements=self.row_counter_placements,
)
if self._used_rowwise_adagrad_with_counter:
Expand Down Expand Up @@ -1170,9 +1116,6 @@ def print_uvm_cache_stats(self) -> None:
def prefetch(self, indices: Tensor, offsets: Tensor) -> None:
self.timestep += 1
self.timesteps_prefetched.append(self.timestep)
# pyre-fixme[29]:
# `Union[BoundMethod[typing.Callable(Tensor.numel)[[Named(self, Tensor)],
# int], Tensor], Tensor, nn.Module]` is not a function.
if not self.lxu_cache_weights.numel():
return

Expand Down Expand Up @@ -1272,16 +1215,8 @@ def _update_cache_miss_counter(

miss_count = torch.sum(unique_ids_count_list)

# pyre-fixme[29]:
# `Union[BoundMethod[typing.Callable(Tensor.__getitem__)[[Named(self,
# Tensor), Named(item, typing.Any)], typing.Any], Tensor], Tensor,
# nn.Module]` is not a function.
self.cache_miss_counter[0] += (miss_count > 0).to(torch.int64)

# pyre-fixme[29]:
# `Union[BoundMethod[typing.Callable(Tensor.__getitem__)[[Named(self,
# Tensor), Named(item, typing.Any)], typing.Any], Tensor], Tensor,
# nn.Module]` is not a function.
self.cache_miss_counter[1] += miss_count

def _update_tablewise_cache_miss(
Expand All @@ -1293,9 +1228,6 @@ def _update_tablewise_cache_miss(
CACHE_MISS = -1
CACHE_HIT = -2

# pyre-ignore[6]:
# Incompatible parameter type [6]: Expected `typing.Sized` for 1st
# positional only parameter to call `len` but got `typing.Union[Tensor, nn.Module]`.
num_tables = len(self.cache_hash_size_cumsum) - 1
num_offsets_per_table = (len(offsets) - 1) // num_tables
cache_missed_locations = torch.where(
Expand Down Expand Up @@ -1340,23 +1272,14 @@ def split_embedding_weights(self) -> List[Tensor]:
for t, (rows, dim, _, _) in enumerate(self.embedding_specs):
if self.weights_precision == SparseType.INT8:
dim += self.int8_emb_row_dim_offset
# pyre-fixme[29]:
# `Union[BoundMethod[typing.Callable(Tensor.__getitem__)[[Named(self,
# Tensor), Named(item, typing.Any)], typing.Any], Tensor], Tensor,
# nn.Module]` is not a function.
placement = self.weights_physical_placements[t]
# pyre-fixme[29]:
# `Union[BoundMethod[typing.Callable(Tensor.__getitem__)[[Named(self,
# Tensor), Named(item, typing.Any)], typing.Any], Tensor], Tensor,
# nn.Module]` is not a function.
offset = self.weights_physical_offsets[t]
if placement == EmbeddingLocation.DEVICE.value:
weights = self.weights_dev
elif placement == EmbeddingLocation.HOST.value:
weights = self.weights_host
else:
weights = self.weights_uvm
# pyre-ignore[29]
if weights.dim() == 2:
weights = weights.flatten()
splits.append(
Expand Down Expand Up @@ -1456,20 +1379,10 @@ def get_optimizer_states(
if self.optimizer not in (OptimType.EXACT_SGD,):
states.append(
get_optimizer_states(
# pyre-fixme[6]: Expected `Tensor` for 1st param but got
# `Union[Tensor, nn.Module]`.
self.momentum1_dev,
# pyre-fixme[6]: Expected `Tensor` for 2nd param but got
# `Union[Tensor, nn.Module]`.
self.momentum1_host,
# pyre-fixme[6]: Expected `Tensor` for 3rd param but got
# `Union[Tensor, nn.Module]`.
self.momentum1_uvm,
# pyre-fixme[6]: Expected `Tensor` for 4th param but got
# `Union[Tensor, nn.Module]`.
self.momentum1_physical_offsets,
# pyre-fixme[6]: Expected `Tensor` for 5th param but got
# `Union[Tensor, nn.Module]`.
self.momentum1_physical_placements,
rowwise=self.optimizer
in [
Expand All @@ -1486,20 +1399,10 @@ def get_optimizer_states(
):
states.append(
get_optimizer_states(
# pyre-fixme[6]: Expected `Tensor` for 1st param but got
# `Union[Tensor, nn.Module]`.
self.momentum2_dev,
# pyre-fixme[6]: Expected `Tensor` for 2nd param but got
# `Union[Tensor, nn.Module]`.
self.momentum2_host,
# pyre-fixme[6]: Expected `Tensor` for 3rd param but got
# `Union[Tensor, nn.Module]`.
self.momentum2_uvm,
# pyre-fixme[6]: Expected `Tensor` for 4th param but got
# `Union[Tensor, nn.Module]`.
self.momentum2_physical_offsets,
# pyre-fixme[6]: Expected `Tensor` for 5th param but got
# `Union[Tensor, nn.Module]`.
self.momentum2_physical_placements,
rowwise=self.optimizer
in (OptimType.PARTIAL_ROWWISE_ADAM, OptimType.PARTIAL_ROWWISE_LAMB),
Expand All @@ -1508,40 +1411,20 @@ def get_optimizer_states(
if self._used_rowwise_adagrad_with_counter:
states.append(
get_optimizer_states(
# pyre-fixme[6]: Expected `Tensor` for 1st param but got
# `Union[Tensor, nn.Module]`.
self.prev_iter_dev,
# pyre-fixme[6]: Expected `Tensor` for 2nd param but got
# `Union[Tensor, nn.Module]`.
self.prev_iter_host,
# pyre-fixme[6]: Expected `Tensor` for 3rd param but got
# `Union[Tensor, nn.Module]`.
self.prev_iter_uvm,
# pyre-fixme[6]: Expected `Tensor` for 4th param but got
# `Union[Tensor, nn.Module]`.
self.prev_iter_physical_offsets,
# pyre-fixme[6]: Expected `Tensor` for 5th param but got
# `Union[Tensor, nn.Module]`.
self.prev_iter_physical_placements,
rowwise=True,
)
)
states.append(
get_optimizer_states(
# pyre-fixme[6]: Expected `Tensor` for 1st param but got
# `Union[Tensor, nn.Module]`.
self.row_counter_dev,
# pyre-fixme[6]: Expected `Tensor` for 2nd param but got
# `Union[Tensor, nn.Module]`.
self.row_counter_host,
# pyre-fixme[6]: Expected `Tensor` for 3rd param but got
# `Union[Tensor, nn.Module]`.
self.row_counter_uvm,
# pyre-fixme[6]: Expected `Tensor` for 4th param but got
# `Union[Tensor, nn.Module]`.
self.row_counter_physical_offsets,
# pyre-fixme[6]: Expected `Tensor` for 5th param but got
# `Union[Tensor, nn.Module]`.
self.row_counter_physical_placements,
rowwise=True,
)
Expand Down Expand Up @@ -1582,9 +1465,6 @@ def set_optimizer_step(self, step: int) -> None:

@torch.jit.export
def flush(self) -> None:
# pyre-fixme[29]:
# `Union[BoundMethod[typing.Callable(Tensor.numel)[[Named(self, Tensor)],
# int], Tensor], Tensor, nn.Module]` is not a function.
if not self.lxu_cache_weights.numel():
return
torch.ops.fbgemm.lxu_cache_flush(
Expand Down Expand Up @@ -1816,9 +1696,6 @@ def _init_uvm_cache_stats(self) -> None:
self.reset_uvm_cache_stats()

def reset_cache_states(self) -> None:
# pyre-fixme[29]:
# `Union[BoundMethod[typing.Callable(Tensor.numel)[[Named(self, Tensor)],
# int], Tensor], Tensor, nn.Module]` is not a function.
if not self.lxu_cache_weights.numel():
return
self.lxu_cache_state.fill_(-1)
Expand Down
Loading

0 comments on commit 07c3f6b

Please sign in to comment.