feat: enable meta device targets in TransformerBridge device_map#1493
feat: enable meta device targets in TransformerBridge device_map#1493hiro-nikaitou wants to merge 2 commits into
Conversation
Part of TransformerLensOrg#1280. Enables 'meta' device targets in TransformerBridge device_map, building on the CPU support shipped in TransformerLensOrg#1459. - Remove 'meta' from _UNSUPPORTED_OFFLOAD_DEVICE_MAP_VALUES - Update docstrings and error messages to reflect meta support - Remove 'meta' from post-load hf_device_map validation (now warning only) - Update test: test_meta_value_in_device_map_rejected -> allowed Meta-offloaded parameters are skipped by cast_floating_params_to_dtype but may still cause forward-pass errors in Bridge-wrapped components that access offloaded tensors without Accelerate align_module_device. This is safe for config inspection (load_weights=False) and documented in resolve_device_map docstring. Disk offload remains blocked pending the hook-routing fix described in PR TransformerLensOrg#1459. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: hiro-nikaitou <vieteviete@proton.me>
be00253 to
6cfecef
Compare
Remove the hard rejection of 'disk' values in both pre-load validation (_validate_device_map_values) and post-load check (boot_transformers). Disk-offloaded components use Accelerate's pre-forward hooks to materialize parameters from disk before each forward call. cast_floating_params_to_dtype already skips meta params gracefully. Changes: - Remove _UNSUPPORTED_OFFLOAD_DEVICE_MAP_VALUES constant - Make _validate_device_map_values a no-op (disk/meta pass through) - Remove post-load disk ValueError in boot_transformers - Update docstrings to reflect new behavior - Update test from expects-rejection to expects-pass-through
|
Hi @hiro-nikaitou, thanks for the contribution! I ran the enabled path end-to-end and every meta I ran the following (tiny-gpt2, CPU, this branch): The docstring's example scenario is genuinely enabled, but the map is discarded, not honored. And its failure-mode caveat is off: failures are at boot (not forward), and Net effect of merging as-is: users lose You have a couple paths forward for resolving this:
I lean towards option 1, but if you'd like to dig deeper & tackle option 2, you are more than welcome to. Whichever route you take, make sure to add tests that validate your changes. |
Part of #1280.
Enables device targets in TransformerBridge , building on the CPU support shipped in #1459.
Changes:
Limitations (documented in resolve_device_map docstring):
Meta-offloaded parameters are skipped by but may still cause forward-pass errors in Bridge-wrapped components that access offloaded tensors without Accelerate . This is safe for config inspection () and for users who understand the constraints.
Closes the portion of #1280. Disk offload remains blocked pending the hook-routing fix described in #1459.