Repository navigation
[graph_trainer] Add bitwise deterministic guardrail test - #2799
Conversation
Add a dedicated CLAUDE.md for the graph_trainer experiment covering: - Graph pass signature convention (gm, example_inputs, *, kwargs) -> gm - Core modification policy (extend via subclassing, not branching) - Local development commands for Llama3 and DeepSeek-v3 aot_fx_trace - Unit, numerics, and integration test commands - Reference to root CLAUDE.md for shared conventions [ghstack-poisoned]
Add test_bitwise_deterministic.py that verifies GraphTrainer (aot_fx_trace) and Trainer (eager) produce bitwise identical losses, model weights, and gradients on both Llama3 and DeepSeek-v3 debug models. Uses hash_model and hash_gradient utilities for efficient whole-model comparison. This serves as a guardrail — all graph_trainer changes must pass this test before proceeding with other tests. Also adds hash_model/hash_gradient to torchtitan/tools/utils.py and documents the guardrail in graph_trainer's CLAUDE.md. TODO: 1. Use distributed setup for multi-GPU testing [ghstack-poisoned]
Add a dedicated CLAUDE.md for the graph_trainer experiment covering: - Graph pass signature convention (gm, example_inputs, *, kwargs) -> gm - Core modification policy (extend via subclassing, not branching) - Local development commands for Llama3 and DeepSeek-v3 aot_fx_trace - Unit, numerics, and integration test commands - Reference to root CLAUDE.md for shared conventions [ghstack-poisoned]
Add test_bitwise_deterministic.py that verifies GraphTrainer (aot_fx_trace) and Trainer (eager) produce bitwise identical losses, model weights, and gradients on both Llama3 and DeepSeek-v3 debug models. Uses hash_model and hash_gradient utilities for efficient whole-model comparison. This serves as a guardrail — all graph_trainer changes must pass this test before proceeding with other tests. Also adds hash_model/hash_gradient to torchtitan/tools/utils.py and documents the guardrail in graph_trainer's CLAUDE.md. TODO: 1. Use distributed setup for multi-GPU testing ghstack-source-id: c9165a8 Pull Request resolved: #2799
Add test_bitwise_deterministic.py that verifies GraphTrainer (aot_fx_trace) and Trainer (eager) produce bitwise identical losses, model weights, and gradients on both Llama3 and DeepSeek-v3 debug models. Uses hash_model and hash_gradient utilities for efficient whole-model comparison. This serves as a guardrail — all graph_trainer changes must pass this test before proceeding with other tests. Also adds hash_model/hash_gradient to torchtitan/tools/utils.py and documents the guardrail in graph_trainer's CLAUDE.md. TODO: 1. Use distributed setup for multi-GPU testing [ghstack-poisoned]
Add test_bitwise_deterministic.py that verifies GraphTrainer (aot_fx_trace) and Trainer (eager) produce bitwise identical losses, model weights, and gradients on both Llama3 and DeepSeek-v3 debug models. Uses hash_model and hash_gradient utilities for efficient whole-model comparison. This serves as a guardrail — all graph_trainer changes must pass this test before proceeding with other tests. Also adds hash_model/hash_gradient to torchtitan/tools/utils.py and documents the guardrail in graph_trainer's CLAUDE.md. TODO: 1. Use distributed setup for multi-GPU testing ghstack-source-id: 58f4079 Pull Request resolved: #2799
Add test_bitwise_deterministic.py that verifies GraphTrainer (aot_fx_trace) and Trainer (eager) produce bitwise identical losses, model weights, and gradients on both Llama3 and DeepSeek-v3 debug models. Uses hash_model and hash_gradient utilities for efficient whole-model comparison. This serves as a guardrail — all graph_trainer changes must pass this test before proceeding with other tests. Also adds hash_model/hash_gradient to torchtitan/tools/utils.py and documents the guardrail in graph_trainer's CLAUDE.md. TODO: 1. Use distributed setup for multi-GPU testing [ghstack-poisoned]
Add test_bitwise_deterministic.py that verifies GraphTrainer (aot_fx_trace) and Trainer (eager) produce bitwise identical losses, model weights, and gradients on both Llama3 and DeepSeek-v3 debug models. Uses hash_model and hash_gradient utilities for efficient whole-model comparison. This serves as a guardrail — all graph_trainer changes must pass this test before proceeding with other tests. Also adds hash_model/hash_gradient to torchtitan/tools/utils.py and documents the guardrail in graph_trainer's CLAUDE.md. TODO: 1. Use distributed setup for multi-GPU testing ghstack-source-id: 604814a Pull Request resolved: #2799
| if isinstance(obj, torch.Tensor): | ||
| if isinstance(obj, DTensor): | ||
| t = obj.to_local().cpu().contiguous() | ||
| else: |
There was a problem hiding this comment.
just curious, how long does this take for a model like 8B or 70B? (or what size models have you been using it on)?
There was a problem hiding this comment.
I have been using debug configs, which is tiny model, and the test is <20s.
I have previously uses the same hash for internal T2 models, perf doesn't seems to be an issue.
Add test_bitwise_deterministic.py that verifies GraphTrainer (aot_fx_trace) and Trainer (eager) produce bitwise identical losses, model weights, and gradients on both Llama3 and DeepSeek-v3 debug models. Uses hash_model and hash_gradient utilities for efficient whole-model comparison. This serves as a guardrail — all graph_trainer changes must pass this test before proceeding with other tests. Also adds hash_model/hash_gradient to torchtitan/tools/utils.py and documents the guardrail in graph_trainer's CLAUDE.md. TODO: 1. Use distributed setup for multi-GPU testing [ghstack-poisoned]
Stack from [ghstack](https://github.com/ezyang/ghstack) (oldest at bottom): * #2802 * #2799 * __->__ #2797 Add a dedicated CLAUDE.md for the graph_trainer experiment covering: - Graph pass signature convention (gm, example_inputs, *, kwargs) -> gm - Core modification policy (extend via subclassing, not branching) - Local development commands for Llama3 and DeepSeek-v3 aot_fx_trace - Unit, numerics, and integration test commands - Reference to root CLAUDE.md for shared conventions
Stack from [ghstack](https://github.com/ezyang/ghstack) (oldest at bottom): * #2802 * #2799 * __->__ #2797 Add a dedicated CLAUDE.md for the graph_trainer experiment covering: - Graph pass signature convention (gm, example_inputs, *, kwargs) -> gm - Core modification policy (extend via subclassing, not branching) - Local development commands for Llama3 and DeepSeek-v3 aot_fx_trace - Unit, numerics, and integration test commands - Reference to root CLAUDE.md for shared conventions
…guardrail test" Add test_bitwise_deterministic.py that verifies GraphTrainer (aot_fx_trace) and Trainer (eager) produce bitwise identical losses, model weights, and gradients on both Llama3 and DeepSeek-v3 debug models. Uses hash_model and hash_gradient utilities for efficient whole-model comparison. This serves as a guardrail — all graph_trainer changes must pass this test before proceeding with other tests. Also adds hash_model/hash_gradient to torchtitan/tools/utils.py and documents the guardrail in graph_trainer's CLAUDE.md. TODO: 1. Use distributed setup for multi-GPU testing [ghstack-poisoned]
Add test_bitwise_deterministic.py that verifies GraphTrainer (aot_fx_trace) and Trainer (eager) produce bitwise identical losses, model weights, and gradients on both Llama3 and DeepSeek-v3 debug models. Uses hash_model and hash_gradient utilities for efficient whole-model comparison. This serves as a guardrail — all graph_trainer changes must pass this test before proceeding with other tests. Also adds hash_model/hash_gradient to torchtitan/tools/utils.py and documents the guardrail in graph_trainer's CLAUDE.md. TODO: 1. Use distributed setup for multi-GPU testing [ghstack-poisoned]
Add test_bitwise_deterministic.py that verifies GraphTrainer (aot_fx_trace) and Trainer (eager) produce bitwise identical losses, model weights, and gradients on both Llama3 and DeepSeek-v3 debug models. Uses hash_model and hash_gradient utilities for efficient whole-model comparison. This serves as a guardrail — all graph_trainer changes must pass this test before proceeding with other tests. Also adds hash_model/hash_gradient to torchtitan/tools/utils.py and documents the guardrail in graph_trainer's CLAUDE.md. TODO: 1. Use distributed setup for multi-GPU testing ghstack-source-id: 6ddf67b Pull Request resolved: #2799
| numpy < 2 | ||
| pytest |
There was a problem hiding this comment.
could you put this in https://github.com/pytorch/torchtitan/blob/main/.ci/docker/requirements-dev.txt
also, why numpy has to <2?
| t = obj.cpu().contiguous() | ||
| if per_tensor: | ||
| tensor_hash = hashlib.new(algo) | ||
| tensor_hash.update(t.numpy().tobytes()) |
There was a problem hiding this comment.
just curious -- do we have to depend on numpy to get bytes? Ideally we don't need to introduce numpy dependency if we can workaround it here.
There was a problem hiding this comment.
alternative is to use tensor.untyped_storage(), but call is sinificantly slower than the numpy().tobytes() path.
Added a todo to investigate.
There was a problem hiding this comment.
| return 312e12 | ||
|
|
||
|
|
||
| def _hash_model_impl( |
There was a problem hiding this comment.
since these functions are only used in testing, can we put them in [repo_root]/test/utils.py for now?
| # pytest torchtitan/experiments/graph_trainer/tests/test_precompile.py -v | ||
|
|
||
| # Run bitwise deterministic guardrail test | ||
| pytest torchtitan/experiments/graph_trainer/tests/test_bitwise_deterministic.py -v |
There was a problem hiding this comment.
just so I understand correctly, this is running identical test on all 8 ranks.
There was a problem hiding this comment.
this is still a single gpu test atm.
We can make it a distribute test to cover deterministic of distributed init/ops.
If we don't have such coverage in titan core, we should add one.
…guardrail test" Add test_bitwise_deterministic.py that verifies GraphTrainer (aot_fx_trace) and Trainer (eager) produce bitwise identical losses, model weights, and gradients on both Llama3 and DeepSeek-v3 debug models. Uses hash_model and hash_gradient utilities for efficient whole-model comparison. This serves as a guardrail — all graph_trainer changes must pass this test before proceeding with other tests. Also adds hash_model/hash_gradient to torchtitan/tools/utils.py and documents the guardrail in graph_trainer's CLAUDE.md. TODO: 1. Use distributed setup for multi-GPU testing [ghstack-poisoned]
Add test_bitwise_deterministic.py that verifies GraphTrainer (aot_fx_trace) and Trainer (eager) produce bitwise identical losses, model weights, and gradients on both Llama3 and DeepSeek-v3 debug models. Uses hash_model and hash_gradient utilities for efficient whole-model comparison. This serves as a guardrail — all graph_trainer changes must pass this test before proceeding with other tests. Also adds hash_model/hash_gradient to torchtitan/tools/utils.py and documents the guardrail in graph_trainer's CLAUDE.md. TODO: 1. Use distributed setup for multi-GPU testing [ghstack-poisoned]
Add test_bitwise_deterministic.py that verifies GraphTrainer (aot_fx_trace) and Trainer (eager) produce bitwise identical losses, model weights, and gradients on both Llama3 and DeepSeek-v3 debug models. Uses hash_model and hash_gradient utilities for efficient whole-model comparison. This serves as a guardrail — all graph_trainer changes must pass this test before proceeding with other tests. Also adds hash_model/hash_gradient to torchtitan/tools/utils.py and documents the guardrail in graph_trainer's CLAUDE.md. TODO: 1. Use distributed setup for multi-GPU testing ghstack-source-id: 4c052fe Pull Request resolved: #2799
Add test_bitwise_deterministic.py that verifies GraphTrainer (aot_fx_trace) and Trainer (eager) produce bitwise identical losses, model weights, and gradients on both Llama3 and DeepSeek-v3 debug models. Uses hash_model and hash_gradient utilities for efficient whole-model comparison. This serves as a guardrail — all graph_trainer changes must pass this test before proceeding with other tests. Also adds hash_model/hash_gradient to torchtitan/tools/utils.py and documents the guardrail in graph_trainer's CLAUDE.md. TODO: 1. Use distributed setup for multi-GPU testing ghstack-source-id: 6ddf67b Pull Request resolved: #2799
…guardrail test" Add test_bitwise_deterministic.py that verifies GraphTrainer (aot_fx_trace) and Trainer (eager) produce bitwise identical losses, model weights, and gradients on both Llama3 and DeepSeek-v3 debug models. Uses hash_model and hash_gradient utilities for efficient whole-model comparison. This serves as a guardrail — all graph_trainer changes must pass this test before proceeding with other tests. Also adds hash_model/hash_gradient to torchtitan/tools/utils.py and documents the guardrail in graph_trainer's CLAUDE.md. TODO: 1. Use distributed setup for multi-GPU testing [ghstack-poisoned]
Add test_bitwise_deterministic.py that verifies GraphTrainer (aot_fx_trace) and Trainer (eager) produce bitwise identical losses, model weights, and gradients on both Llama3 and DeepSeek-v3 debug models. Uses hash_model and hash_gradient utilities for efficient whole-model comparison. This serves as a guardrail — all graph_trainer changes must pass this test before proceeding with other tests. Also adds hash_model/hash_gradient to torchtitan/tools/utils.py and documents the guardrail in graph_trainer's CLAUDE.md. TODO: 1. Use distributed setup for multi-GPU testing [ghstack-poisoned]
Add test_bitwise_deterministic.py that verifies GraphTrainer (aot_fx_trace) and Trainer (eager) produce bitwise identical losses, model weights, and gradients on both Llama3 and DeepSeek-v3 debug models. Uses hash_model and hash_gradient utilities for efficient whole-model comparison. This serves as a guardrail — all graph_trainer changes must pass this test before proceeding with other tests. Also adds hash_model/hash_gradient to torchtitan/tools/utils.py and documents the guardrail in graph_trainer's CLAUDE.md. TODO: 1. Use distributed setup for multi-GPU testing ghstack-source-id: 3fdd7af Pull Request resolved: #2799
Add test_bitwise_deterministic.py that verifies GraphTrainer (aot_fx_trace) and Trainer (eager) produce bitwise identical losses, model weights, and gradients on both Llama3 and DeepSeek-v3 debug models. Uses hash_model and hash_gradient utilities for efficient whole-model comparison. This serves as a guardrail — all graph_trainer changes must pass this test before proceeding with other tests. Also adds hash_model/hash_gradient to torchtitan/tools/utils.py and documents the guardrail in graph_trainer's CLAUDE.md. TODO: 1. Use distributed setup for multi-GPU testing ghstack-source-id: 6ddf67b Pull Request resolved: #2799
…guardrail test" Add test_bitwise_deterministic.py that verifies GraphTrainer (aot_fx_trace) and Trainer (eager) produce bitwise identical losses, model weights, and gradients on both Llama3 and DeepSeek-v3 debug models. Uses hash_model and hash_gradient utilities for efficient whole-model comparison. This serves as a guardrail — all graph_trainer changes must pass this test before proceeding with other tests. Also adds hash_model/hash_gradient to torchtitan/tools/utils.py and documents the guardrail in graph_trainer's CLAUDE.md. TODO: 1. Use distributed setup for multi-GPU testing [ghstack-poisoned]
Add test_bitwise_deterministic.py that verifies GraphTrainer (aot_fx_trace) and Trainer (eager) produce bitwise identical losses, model weights, and gradients on both Llama3 and DeepSeek-v3 debug models. Uses hash_model and hash_gradient utilities for efficient whole-model comparison. This serves as a guardrail — all graph_trainer changes must pass this test before proceeding with other tests. Also adds hash_model/hash_gradient to torchtitan/tools/utils.py and documents the guardrail in graph_trainer's CLAUDE.md. TODO: 1. Use distributed setup for multi-GPU testing [ghstack-poisoned]
Add test_bitwise_deterministic.py that verifies GraphTrainer (aot_fx_trace) and Trainer (eager) produce bitwise identical losses, model weights, and gradients on both Llama3 and DeepSeek-v3 debug models. Uses hash_model and hash_gradient utilities for efficient whole-model comparison. This serves as a guardrail — all graph_trainer changes must pass this test before proceeding with other tests. Also adds hash_model/hash_gradient to torchtitan/tools/utils.py and documents the guardrail in graph_trainer's CLAUDE.md. TODO: 1. Use distributed setup for multi-GPU testing ghstack-source-id: aa4e514 Pull Request resolved: #2799
…guardrail test" Add test_bitwise_deterministic.py that verifies GraphTrainer (aot_fx_trace) and Trainer (eager) produce bitwise identical losses, model weights, and gradients on both Llama3 and DeepSeek-v3 debug models. Uses hash_model and hash_gradient utilities for efficient whole-model comparison. This serves as a guardrail — all graph_trainer changes must pass this test before proceeding with other tests. Also adds hash_model/hash_gradient to torchtitan/tools/utils.py and documents the guardrail in graph_trainer's CLAUDE.md. TODO: 1. Use distributed setup for multi-GPU testing [ghstack-poisoned]
Add test_bitwise_deterministic.py that verifies GraphTrainer (aot_fx_trace) and Trainer (eager) produce bitwise identical losses, model weights, and gradients on both Llama3 and DeepSeek-v3 debug models. Uses hash_model and hash_gradient utilities for efficient whole-model comparison. This serves as a guardrail — all graph_trainer changes must pass this test before proceeding with other tests. Also adds hash_model/hash_gradient to torchtitan/tools/utils.py and documents the guardrail in graph_trainer's CLAUDE.md. TODO: 1. Use distributed setup for multi-GPU testing [ghstack-poisoned]
Add test_bitwise_deterministic.py that verifies GraphTrainer (aot_fx_trace) and Trainer (eager) produce bitwise identical losses, model weights, and gradients on both Llama3 and DeepSeek-v3 debug models. Uses hash_model and hash_gradient utilities for efficient whole-model comparison. This serves as a guardrail — all graph_trainer changes must pass this test before proceeding with other tests. Also adds hash_model/hash_gradient to torchtitan/tools/utils.py and documents the guardrail in graph_trainer's CLAUDE.md. TODO: 1. Use distributed setup for multi-GPU testing ghstack-source-id: adc501e Pull Request resolved: #2799
Add test_bitwise_deterministic.py that verifies GraphTrainer (aot_fx_trace) and Trainer (eager) produce bitwise identical losses, model weights, and gradients on both Llama3 and DeepSeek-v3 debug models. Uses hash_model and hash_gradient utilities for efficient whole-model comparison. This serves as a guardrail — all graph_trainer changes must pass this test before proceeding with other tests. Also adds hash_model/hash_gradient to torchtitan/tools/utils.py and documents the guardrail in graph_trainer's CLAUDE.md. TODO: 1. Use distributed setup for multi-GPU testing ghstack-source-id: 6ddf67b Pull Request resolved: #2799
Stack from [ghstack](https://github.com/ezyang/ghstack) (oldest at bottom): * pytorch#2802 * pytorch#2799 * __->__ pytorch#2797 Add a dedicated CLAUDE.md for the graph_trainer experiment covering: - Graph pass signature convention (gm, example_inputs, *, kwargs) -> gm - Core modification policy (extend via subclassing, not branching) - Local development commands for Llama3 and DeepSeek-v3 aot_fx_trace - Unit, numerics, and integration test commands - Reference to root CLAUDE.md for shared conventions
Stack from [ghstack](https://github.com/ezyang/ghstack) (oldest at bottom): * __->__ pytorch#2799 Add test_bitwise_deterministic.py that verifies GraphTrainer (aot_fx_trace) and Trainer (eager) produce bitwise identical losses, model weights, and gradients on both Llama3 and DeepSeek-v3 debug models. Uses hash_model and hash_gradient utilities for efficient whole-model comparison. This serves as a guardrail — all graph_trainer changes must pass this test before proceeding with other tests. Also adds hash_model/hash_gradient to torchtitan/tools/utils.py and documents the guardrail in graph_trainer's CLAUDE.md. TODO: 1. Use distributed setup for multi-GPU testing
Stack from [ghstack](https://github.com/ezyang/ghstack) (oldest at bottom): * pytorch#2802 * pytorch#2799 * __->__ pytorch#2797 Add a dedicated CLAUDE.md for the graph_trainer experiment covering: - Graph pass signature convention (gm, example_inputs, *, kwargs) -> gm - Core modification policy (extend via subclassing, not branching) - Local development commands for Llama3 and DeepSeek-v3 aot_fx_trace - Unit, numerics, and integration test commands - Reference to root CLAUDE.md for shared conventions
Stack from [ghstack](https://github.com/ezyang/ghstack) (oldest at bottom): * __->__ pytorch#2799 Add test_bitwise_deterministic.py that verifies GraphTrainer (aot_fx_trace) and Trainer (eager) produce bitwise identical losses, model weights, and gradients on both Llama3 and DeepSeek-v3 debug models. Uses hash_model and hash_gradient utilities for efficient whole-model comparison. This serves as a guardrail — all graph_trainer changes must pass this test before proceeding with other tests. Also adds hash_model/hash_gradient to torchtitan/tools/utils.py and documents the guardrail in graph_trainer's CLAUDE.md. TODO: 1. Use distributed setup for multi-GPU testing
Stack from [ghstack](https://github.com/ezyang/ghstack) (oldest at bottom): * pytorch#2802 * pytorch#2799 * __->__ pytorch#2797 Add a dedicated CLAUDE.md for the graph_trainer experiment covering: - Graph pass signature convention (gm, example_inputs, *, kwargs) -> gm - Core modification policy (extend via subclassing, not branching) - Local development commands for Llama3 and DeepSeek-v3 aot_fx_trace - Unit, numerics, and integration test commands - Reference to root CLAUDE.md for shared conventions
Stack from [ghstack](https://github.com/ezyang/ghstack) (oldest at bottom): * __->__ pytorch#2799 Add test_bitwise_deterministic.py that verifies GraphTrainer (aot_fx_trace) and Trainer (eager) produce bitwise identical losses, model weights, and gradients on both Llama3 and DeepSeek-v3 debug models. Uses hash_model and hash_gradient utilities for efficient whole-model comparison. This serves as a guardrail — all graph_trainer changes must pass this test before proceeding with other tests. Also adds hash_model/hash_gradient to torchtitan/tools/utils.py and documents the guardrail in graph_trainer's CLAUDE.md. TODO: 1. Use distributed setup for multi-GPU testing
Stack from ghstack (oldest at bottom):
Add test_bitwise_deterministic.py that verifies GraphTrainer (aot_fx_trace)
and Trainer (eager) produce bitwise identical losses, model weights, and
gradients on both Llama3 and DeepSeek-v3 debug models. Uses hash_model and
hash_gradient utilities for efficient whole-model comparison.
This serves as a guardrail — all graph_trainer changes must pass this
test before proceeding with other tests.
Also adds hash_model/hash_gradient to torchtitan/tools/utils.py and
documents the guardrail in graph_trainer's CLAUDE.md.
TODO: