[Draft]Fake mode or CPU support - #410
Conversation
Greptile SummaryThis PR introduces "fake mode" for DynamicEmb: a
Confidence Score: 5/5The change adds an opt-in CPU/fake path gated behind an env var; the real GPU path is not altered beyond the four-line new guard protected by a cls-identity check. The real execution path is untouched except for the cls-identity-guarded new hook. Fake mode is entirely opt-in. Host-side bookkeeping methods are reused from the real class, keeping state in sync. No blocking issues found. _fake.py warrants a second look on the _build_fake_class global cache (no lock) and the device-ID extraction already noted in a prior thread. Important Files Changed
Sequence DiagramsequenceDiagram
participant U as User Code
participant Init as dynamicemb/__init__.py
participant Fake as _fake.py
participant V2 as BatchedDynamicEmbeddingTablesV2
participant FV2 as FakeBatchedDynamicEmbeddingTablesV2
Init->>Fake: bootstrap()
U->>V2: "BatchedDynamicEmbeddingTablesV2(**kwargs)"
V2->>Fake: maybe_get_fake_class()
alt "FAKE_MODE=1"
Fake-->>V2: FakeBatchedDynamicEmbeddingTablesV2
V2-->>U: fake instance
U->>FV2: forward(indices, offsets)
FV2-->>U: zeros tensor [cpu]
else "FAKE_MODE=0"
Fake-->>V2: None
V2-->>U: real instance
end
Reviews (2): Last reviewed commit: "fake: disable use_index_dedup in DMP tes..." | Re-trigger Greptile |
| if device is not None: | ||
| try: | ||
| self.device_id = int(str(device)[-1]) | ||
| except ValueError: | ||
| self.device_id = 0 |
There was a problem hiding this comment.
The
str(device)[-1] approach only reads the last character of the device string, so a device like cuda:10 yields "0" instead of 10, silently setting the wrong device ID. The except ValueError guard only catches the cpu case, not multi-digit indices. Use device.index (which is None for CPU) for a correct, idiomatic extraction.
| if device is not None: | |
| try: | |
| self.device_id = int(str(device)[-1]) | |
| except ValueError: | |
| self.device_id = 0 | |
| if device is not None: | |
| d = torch.device(device) if not isinstance(device, torch.device) else device | |
| self.device_id = d.index if d.index is not None else 0 |
| "test/unit_tests/test_alignment.sh" | ||
| "test/unit_tests/test_hash_roundrobin_kuairand.py" | ||
| "test/unit_tests/test_hybrid_storage_export.sh" | ||
| "test/unit_tests/test_vmm_tensor.py" | ||
| "test/unit_tests/test_fake_batched_dynamicemb_tables.sh" | ||
| ) | ||
|
|
||
| LOAD_DUMP_TEST_FILES=( |
There was a problem hiding this comment.
Unexplained removal of hybrid-storage export test
test_hybrid_storage_export.sh is silently dropped from the CI suite and replaced by the new fake-mode test. If this test covered a code path that is still exercised in production (hybrid HBM/DDR storage with export), removing it from the suite is an untracked coverage gap. Was this intentional (e.g., the test is superseded, or it no longer compiles without GPU), and if so, can you add a brief comment or remove the file entirely?
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
…KIP_CUDA_BUILD for nvcc-free install, plus tests covering dispatch / attribute parity / forward / DMP sequence-mode wiring. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…st.sh Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…ly kernel from dynamicemb_extensions, incompatible with the test's CPU input KJT). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Description
Checklist