repo_name stringlengths 1 62 | dataset stringclasses 1
value | lang stringclasses 11
values | pr_id int64 1 20.1k | owner stringlengths 2 34 | reviewer stringlengths 2 39 | diff_hunk stringlengths 15 262k | code_review_comment stringlengths 1 99.6k |
|---|---|---|---|---|---|---|---|
axlearn | github_2023 | python | 699 | apple | markblee | @@ -0,0 +1,334 @@
+# Copyright © 2024 Apple Inc.
+"""Utilities for the detailed tool use metrics."""
+
+import re
+import string
+from enum import Enum
+from typing import Union
+
+from typing_extensions import TypeAlias
+
+Value = Union[str, int, bool, float]
+ValueOrListOf: TypeAlias = Union[Value, list[Value]]
+
+_S... | nit -- a basic for loop seems more readable here?
```suggestion
start_index = len(words)
for i, word in enumerate(words):
if word not in _STOP_WORDS:
start_index = i
break
``` |
axlearn | github_2023 | python | 699 | apple | markblee | @@ -0,0 +1,334 @@
+# Copyright © 2024 Apple Inc.
+"""Utilities for the detailed tool use metrics."""
+
+import re
+import string
+from enum import Enum
+from typing import Union
+
+from typing_extensions import TypeAlias
+
+Value = Union[str, int, bool, float]
+ValueOrListOf: TypeAlias = Union[Value, list[Value]]
+
+_S... | Same here. |
axlearn | github_2023 | python | 699 | apple | markblee | @@ -0,0 +1,334 @@
+# Copyright © 2024 Apple Inc.
+"""Utilities for the detailed tool use metrics."""
+
+import re
+import string
+from enum import Enum
+from typing import Union
+
+from typing_extensions import TypeAlias
+
+Value = Union[str, int, bool, float]
+ValueOrListOf: TypeAlias = Union[Value, list[Value]]
+
+_S... | ```suggestion
# Only handling string payloads for lenient evaluation.
```
(A gentle reminder to apply review comments throughout the PR.) |
axlearn | github_2023 | python | 705 | apple | markblee | @@ -666,3 +673,96 @@ def _mha_backward(
flash_attention.defvjp(_mha_forward, _mha_backward)
+
+
+def check_local_compute_capability(cc): | Does this need to be a public fn? Also annotate types/returns/docstring etc? |
axlearn | github_2023 | python | 705 | apple | markblee | @@ -666,3 +673,96 @@ def _mha_backward(
flash_attention.defvjp(_mha_forward, _mha_backward)
+
+
+def check_local_compute_capability(cc):
+ if cuda_versions is None:
+ raise RuntimeError("cuDNN is not detected.")
+ for i in range(jax.local_device_count()):
+ compute_cap = cuda_versions.cuda_comp... | Is this accurate? |
axlearn | github_2023 | python | 705 | apple | markblee | @@ -666,3 +673,96 @@ def _mha_backward(
flash_attention.defvjp(_mha_forward, _mha_backward)
+
+
+def check_local_compute_capability(cc):
+ if cuda_versions is None:
+ raise RuntimeError("cuDNN is not detected.")
+ for i in range(jax.local_device_count()):
+ compute_cap = cuda_versions.cuda_comp... | ```suggestion
# Check if cuDNN is installed.
```
and below |
axlearn | github_2023 | python | 705 | apple | markblee | @@ -174,56 +176,59 @@ def ref_fn(q, k, v, bias):
chex.assert_trees_all_close(jax_grads, jax_ref_grads, atol=0.05)
-# We also include a test for Triton with Pallas, to cross validate the triton
-# compatibility with our own implementation.
+# We test the cudnn_dot_product_attention against the reference flash_a... | Can we retain the original atol for the float16 case? |
axlearn | github_2023 | python | 705 | apple | markblee | @@ -174,56 +176,65 @@ def ref_fn(q, k, v, bias):
chex.assert_trees_all_close(jax_grads, jax_ref_grads, atol=0.05)
-# We also include a test for Triton with Pallas, to cross validate the triton
-# compatibility with our own implementation.
+# We test the cudnn_dot_product_attention against the reference flash_a... | We should probably add an `else: raise` or similar. If someone parameterizes a different dtype, we don't want to inadvertently skip the check. |
axlearn | github_2023 | python | 705 | apple | markblee | @@ -174,56 +176,65 @@ def ref_fn(q, k, v, bias):
chex.assert_trees_all_close(jax_grads, jax_ref_grads, atol=0.05)
-# We also include a test for Triton with Pallas, to cross validate the triton
-# compatibility with our own implementation.
+# We test the cudnn_dot_product_attention against the reference flash_a... | Same here. |
axlearn | github_2023 | python | 701 | apple | markblee | @@ -211,12 +212,21 @@ def __init__(
utils.validate_float_dtype(cfg.train_dtype)
# Create the device mesh.
- self._step_log(
- "Devices: global=%s local=%s %s",
- jax.device_count(),
- jax.local_device_count(),
- [device.platform for device in ja... | nit -- you could also just assign `devices,local_devices` and log after the conditional. |
axlearn | github_2023 | python | 701 | apple | markblee | @@ -49,7 +52,7 @@ def _compile_and_dump_programs(
compile_topology: Optional[str],
compile_topology_num_slices: int = 1,
):
- with set_data_dir("FAKE"):
+ with set_data_dir(FLAGS.data_dir): | nit -- We could also read from env rather than taking a new flag. |
axlearn | github_2023 | python | 696 | apple | markblee | @@ -1059,19 +1059,25 @@ def _maybe_stop_or_start_tracing(
def select_mesh_config(trainer_config: SpmdTrainer.Config, *, mesh_selector: str):
- """Selects a mesh rule (if one matches `mesh_selector` to override mesh config.
+ """Selects a mesh rule (if one matches mesh_selector to override mesh config.
- ... | Can we retain the backticks for code formatting? |
axlearn | github_2023 | python | 696 | apple | markblee | @@ -0,0 +1,151 @@
+"""Defines trainer config modifiers, which will be used in model definitions.""" | Missing copyright. |
axlearn | github_2023 | python | 696 | apple | markblee | @@ -0,0 +1,151 @@
+"""Defines trainer config modifiers, which will be used in model definitions."""
+
+from typing import Dict, List, Optional, Union
+
+from axlearn.common import config
+from axlearn.common.base_layer import RematSpec
+from axlearn.common.config import REQUIRED, ConfigModifier, ConfigOr, Required, con... | ```suggestion
cfg: The trainer config to be modified.
```
The types are already specified in the signature. |
axlearn | github_2023 | python | 696 | apple | markblee | @@ -0,0 +1,151 @@
+"""Defines trainer config modifiers, which will be used in model definitions."""
+
+from typing import Dict, List, Optional, Union
+
+from axlearn.common import config
+from axlearn.common.base_layer import RematSpec
+from axlearn.common.config import REQUIRED, ConfigModifier, ConfigOr, Required, con... | ```suggestion
The modified trainer config.
``` |
axlearn | github_2023 | python | 696 | apple | markblee | @@ -0,0 +1,151 @@
+"""Defines trainer config modifiers, which will be used in model definitions."""
+
+from typing import Dict, List, Optional, Union
+
+from axlearn.common import config
+from axlearn.common.base_layer import RematSpec
+from axlearn.common.config import REQUIRED, ConfigModifier, ConfigOr, Required, con... | Do we need to support `None`? The caller can just avoid applying the modifier if they don't want to enable it. |
axlearn | github_2023 | python | 696 | apple | markblee | @@ -0,0 +1,151 @@
+"""Defines trainer config modifiers, which will be used in model definitions."""
+
+from typing import Dict, List, Optional, Union
+
+from axlearn.common import config
+from axlearn.common.base_layer import RematSpec
+from axlearn.common.config import REQUIRED, ConfigModifier, ConfigOr, Required, con... | A suggestion on naming:
```suggestion
class RematSpecModifier(ConfigModifier):
```
It may be more consistent/discoverable to name them as `XModifier`. |
axlearn | github_2023 | python | 696 | apple | markblee | @@ -0,0 +1,150 @@
+# Copyright © 2023 Apple Inc.
+
+"""Defines trainer config modifiers, which will be used in model definitions."""
+
+from typing import Dict, List, Optional, Union
+
+from axlearn.common import config
+from axlearn.common.base_layer import RematSpec
+from axlearn.common.config import REQUIRED, Config... | Could we apply the same comment re. None here?
Also, should we spell out how users should configure these, e.g. with a config docstring:
```
@config_class
class Config(ConfigModifier.Config):
"""Configures RematSpecModifier.
Attributes:
remat_policies: A mapping fr... |
axlearn | github_2023 | python | 696 | apple | markblee | @@ -0,0 +1,150 @@
+# Copyright © 2023 Apple Inc.
+
+"""Defines trainer config modifiers, which will be used in model definitions."""
+
+from typing import Dict, List, Optional, Union
+
+from axlearn.common import config
+from axlearn.common.base_layer import RematSpec
+from axlearn.common.config import REQUIRED, Config... | Likewise with the comments on typing/casing?
```suggestion
cfg: The trainer config to be modified.
``` |
axlearn | github_2023 | python | 696 | apple | markblee | @@ -0,0 +1,150 @@
+# Copyright © 2023 Apple Inc.
+
+"""Defines trainer config modifiers, which will be used in model definitions."""
+
+from typing import Dict, List, Optional, Union
+
+from axlearn.common import config
+from axlearn.common.base_layer import RematSpec
+from axlearn.common.config import REQUIRED, Config... | ```suggestion
class GradientAccumulationModifier(ConfigModifier):
``` |
axlearn | github_2023 | python | 696 | apple | markblee | @@ -102,6 +105,26 @@ def sharding(self) -> jax.sharding.Sharding:
NestedTensorSpec = Optional[Union[TensorSpec, dict[str, Any]]]
+def offload_dots_saveble(offload_src, offload_dst): | Missing types/returns?
```suggestion
def offload_dots_saveable(offload_src, offload_dst):
``` |
axlearn | github_2023 | python | 696 | apple | markblee | @@ -102,6 +105,26 @@ def sharding(self) -> jax.sharding.Sharding:
NestedTensorSpec = Optional[Union[TensorSpec, dict[str, Any]]]
+def offload_dots_saveble(offload_src, offload_dst):
+ """Extract and combine the policy from save_and_offload_only_these_names and dots_saveable.
+ https://github.com/google/jax/b... | ```suggestion
"""Extract and combine the policy from save_and_offload_only_these_names and dots_saveable.
https://github.com/google/jax/blob/e3110c18f8bce83901cff42458d4204df9e3abeb/jax/_src/ad_checkpoint.py#L151
This would remove the need to match the names for activation tensors.
Args:... |
axlearn | github_2023 | python | 696 | apple | markblee | @@ -102,6 +105,26 @@ def sharding(self) -> jax.sharding.Sharding:
NestedTensorSpec = Optional[Union[TensorSpec, dict[str, Any]]]
+def offload_dots_saveble(offload_src, offload_dst):
+ """Extract and combine the policy from save_and_offload_only_these_names and dots_saveable.
+ https://github.com/google/jax/b... | ```suggestion
offload_src: The source device for offloading.
offload_dst: The target device for offloading.
``` |
axlearn | github_2023 | python | 696 | apple | markblee | @@ -102,6 +105,26 @@ def sharding(self) -> jax.sharding.Sharding:
NestedTensorSpec = Optional[Union[TensorSpec, dict[str, Any]]]
+def offload_dots_saveble(offload_src, offload_dst):
+ """Extract and combine the policy from save_and_offload_only_these_names and dots_saveable.
+ https://github.com/google/jax/b... | Do we need this? |
axlearn | github_2023 | python | 696 | apple | markblee | @@ -0,0 +1,150 @@
+# Copyright © 2023 Apple Inc.
+
+"""Defines trainer config modifiers, which will be used in model definitions."""
+
+from typing import Dict, List, Optional, Union
+
+from axlearn.common import config
+from axlearn.common.base_layer import RematSpec
+from axlearn.common.config import REQUIRED, Config... | ```suggestion
``` |
axlearn | github_2023 | python | 696 | apple | markblee | @@ -0,0 +1,150 @@
+# Copyright © 2023 Apple Inc.
+
+"""Defines trainer config modifiers, which will be used in model definitions."""
+
+from typing import Dict, List, Optional, Union
+
+from axlearn.common import config
+from axlearn.common.base_layer import RematSpec
+from axlearn.common.config import REQUIRED, Config... | Same comment as above. |
axlearn | github_2023 | python | 696 | apple | markblee | @@ -0,0 +1,150 @@
+# Copyright © 2023 Apple Inc.
+
+"""Defines trainer config modifiers, which will be used in model definitions."""
+
+from typing import Dict, List, Optional, Union
+
+from axlearn.common import config
+from axlearn.common.base_layer import RematSpec
+from axlearn.common.config import REQUIRED, Config... | Same comment as above. |
axlearn | github_2023 | python | 696 | apple | markblee | @@ -0,0 +1,150 @@
+# Copyright © 2023 Apple Inc.
+
+"""Defines trainer config modifiers, which will be used in model definitions."""
+
+from typing import Dict, List, Optional, Union
+
+from axlearn.common import config
+from axlearn.common.base_layer import RematSpec
+from axlearn.common.config import REQUIRED, Config... | Also here. |
axlearn | github_2023 | python | 696 | apple | markblee | @@ -0,0 +1,150 @@
+# Copyright © 2023 Apple Inc.
+
+"""Defines trainer config modifiers, which will be used in model definitions."""
+
+from typing import Dict, List, Optional, Union
+
+from axlearn.common import config
+from axlearn.common.base_layer import RematSpec
+from axlearn.common.config import REQUIRED, Config... | Since we specify the config modifier as `ConfigOr[ConfigModifier]`, we should use
```suggestion
maybe_instantiate(cfg_modifier) for cfg_modifier in cfg.config_modifiers
``` |
axlearn | github_2023 | python | 696 | apple | markblee | @@ -0,0 +1,150 @@
+# Copyright © 2023 Apple Inc.
+
+"""Defines trainer config modifiers, which will be used in model definitions."""
+
+from typing import Dict, List, Optional, Union
+
+from axlearn.common import config
+from axlearn.common.base_layer import RematSpec
+from axlearn.common.config import REQUIRED, Config... | ```suggestion
config_modifiers: Required[Sequence[ConfigOr[ConfigModifier]]] = REQUIRED
``` |
axlearn | github_2023 | python | 696 | apple | markblee | @@ -0,0 +1,150 @@
+# Copyright © 2023 Apple Inc.
+
+"""Defines trainer config modifiers, which will be used in model definitions."""
+
+from typing import Dict, List, Optional, Union
+
+from axlearn.common import config
+from axlearn.common.base_layer import RematSpec
+from axlearn.common.config import REQUIRED, Config... | ```suggestion
metric_accumulator: MetricAccumulator.Config = MetricAccumulator.default_config()
``` |
axlearn | github_2023 | python | 696 | apple | markblee | @@ -0,0 +1,150 @@
+# Copyright © 2023 Apple Inc.
+
+"""Defines trainer config modifiers, which will be used in model definitions."""
+
+from typing import Dict, List, Optional, Union
+
+from axlearn.common import config
+from axlearn.common.base_layer import RematSpec
+from axlearn.common.config import REQUIRED, Config... | ```suggestion
cfg: The trainer config to be modified.
``` |
axlearn | github_2023 | python | 696 | apple | markblee | @@ -102,6 +105,26 @@ def sharding(self) -> jax.sharding.Sharding:
NestedTensorSpec = Optional[Union[TensorSpec, dict[str, Any]]]
+def offload_dots_saveble(offload_src, offload_dst):
+ """Extract and combine the policy from save_and_offload_only_these_names and dots_saveable. | Is this accurate? Seems that `dots_saveable` includes `lax_convolution.conv_general_dilated_p`. Also clarify how it combines `save_and_offload_only_these_names `? |
axlearn | github_2023 | python | 696 | apple | markblee | @@ -0,0 +1,180 @@
+# Copyright © 2023 Apple Inc. | ```suggestion
# Copyright © 2024 Apple Inc.
```
(here and elsewhere) |
axlearn | github_2023 | python | 693 | apple | markblee | @@ -659,7 +659,7 @@ class Config(BaseLayer.Config):
# Dimension of each attention head.
per_head_dim: Required[int] = REQUIRED
# Autoregressive cache dtype. Should match the step dtype.
- # Needs to match the forward dtype for Repeated layers. If None, infer as config.dtype.
+ #... | ```suggestion
# Needs to match the forward dtype for Repeated layers. If None, infer as `self.dtype()`.
``` |
axlearn | github_2023 | python | 695 | apple | ruomingp | @@ -185,78 +134,169 @@ def test_training_lm_processor_single_example(self, text: str):
# The inputs should be one-off the labels.
self.assertNestedAllClose(target_labels[:-1], input_ids[1:])
+ @parameterized.parameters(
+ dict(
+ packing_method=PackingMethodType.EOS_DELIM_MASK,
... | With this change, do we still test the truncation behavior? |
axlearn | github_2023 | python | 695 | apple | ruomingp | @@ -142,12 +163,45 @@ def process_batched(inputs: dict[str, Any]) -> dict[str, Any]:
target_num_bytes = num_bytes(
batched_target_labels, sp_vocab=vocab, newlines_replaced_with=replace_newlines_with
)
- return dict(
+
+ result = dict(
input_ids=batched_input_ids... | Neat use of tf.scan! |
axlearn | github_2023 | python | 656 | apple | samos123 | @@ -403,4 +401,24 @@ def make_grad_accum_config(
make_grad_accum_config, make_single_host_config_func, 4
)
+ if model_size == "70B":
+
+ def make_config_with_act_offload(base_config_name: str) -> SpmdTrainer.Config:
+ """Make configs for the v5e/v6e tpu w... | Would it call update_model_remat_config twice this way?
The first time during initial config of base config and then 2nd time during make_config_with_act_offload |
axlearn | github_2023 | python | 675 | apple | ruomingp | @@ -1162,6 +1171,139 @@ def test_only_linear_weight(self):
target_state.trainer_state.model["linear2"]["bias"],
)
+ def _create_fake_state_and_convert(self, scope_mapping: Dict[str, str]):
+ # Create fake source_state and target_state with nested layers.
+ source_cfg, source_sta... | Nit: use assertIs(...)? |
axlearn | github_2023 | python | 675 | apple | markblee | @@ -791,10 +792,38 @@ def target_to_source(self, target: Builder.State) -> tuple[Builder.State, Any]:
return source, aux
def source_to_target(self, source: Builder.State, aux: Any) -> Builder.State:
- """Load model state from source to target."""
+ """Load model state from source to target... | Move this into `_copy_leaf` so we can use separator for the join? |
axlearn | github_2023 | python | 675 | apple | markblee | @@ -791,10 +793,41 @@ def target_to_source(self, target: Builder.State) -> tuple[Builder.State, Any]:
return source, aux
def source_to_target(self, source: Builder.State, aux: Any) -> Builder.State:
- """Load model state from source to target."""
+ """Load model state from source to target... | ```suggestion
lambda path, leaf, src_scope=source_scope: _copy_leaf(
path,
leaf,
source_scope=src_scope,
``` |
axlearn | github_2023 | python | 674 | apple | markblee | @@ -61,8 +61,14 @@ def is_pending(self) -> bool:
return self in {CloudBuildStatus.PENDING, CloudBuildStatus.QUEUED, CloudBuildStatus.WORKING}
-def get_cloud_build_status(project_id: str, image_name: str) -> Optional[CloudBuildStatus]:
- """Get the status of the latest build filter on the image_name.
+de... | ```suggestion
"""Gets the status of the latest build by filtering on the build tags or image name.
``` |
axlearn | github_2023 | python | 659 | apple | markblee | @@ -121,22 +122,47 @@ def filter_for_validation(structure):
)
-# pylint: disable-next=redefined-builtin
-def save_tf_savables(value_map: Dict[str, Any], *, dir: str):
- """Saves TF savables from `value_map` into `dir`."""
+def _upload_dir(src_dir_handle: tempfile.TemporaryDirectory, *, dst_dir: str):
+ ... | nit -- `makedirs` should work even if it exists. |
axlearn | github_2023 | python | 659 | apple | markblee | @@ -272,6 +298,7 @@ def __init__(self, cfg: Config):
self._manager = array_serialization.GlobalAsyncCheckpointManager(
timeout_secs=cfg.timeout_secs
)
+ self._executor = futures.ThreadPoolExecutor() | Since we're no longer using a context manager, should we invoke `shutdown` explicitly? |
axlearn | github_2023 | python | 651 | apple | cpgaffney1 | @@ -922,3 +971,216 @@ def validate_and_restore(*, step: int, ckpt_dir: str):
restored_state = state
return step, restored_state
+
+
+class OrbaxCheckpointer(BaseCheckpointer):
+ """A checkpointer that uses orbax CheckpointManager.
+
+ NOTE: While this class uses index files to do additiona... | Use
```
name_format = ocp.path.step.standard_name_format(
step_prefix=_STEP_PREFIX,
step_format_fixed_length=_STEP_NUM_DIGITS,
)
ocp.path.step.build_step_path(directory, name_format, step)
``` |
axlearn | github_2023 | python | 651 | apple | cpgaffney1 | @@ -922,3 +971,216 @@ def validate_and_restore(*, step: int, ckpt_dir: str):
restored_state = state
return step, restored_state
+
+
+class OrbaxCheckpointer(BaseCheckpointer):
+ """A checkpointer that uses orbax CheckpointManager.
+
+ NOTE: While this class uses index files to do additiona... | What is the concern with doing this? Orbax doesn't loop in that many additional dependencies. |
axlearn | github_2023 | python | 651 | apple | cpgaffney1 | @@ -922,3 +971,216 @@ def validate_and_restore(*, step: int, ckpt_dir: str):
restored_state = state
return step, restored_state
+
+
+class OrbaxCheckpointer(BaseCheckpointer):
+ """A checkpointer that uses orbax CheckpointManager.
+
+ NOTE: While this class uses index files to do additiona... | My preference would be for doing this check first and raising an error earlier if no steps are found, followed by the try/except. I think it's a bit more readable but up to you. |
axlearn | github_2023 | python | 651 | apple | jiya-zhang | @@ -922,3 +953,220 @@ def validate_and_restore(*, step: int, ckpt_dir: str):
restored_state = state
return step, restored_state
+
+
+class OrbaxCheckpointer(BaseCheckpointer):
+ """A checkpointer that uses orbax CheckpointManager.
+
+ NOTE: While this class uses index files to do additiona... | Is this method ever called? |
axlearn | github_2023 | python | 651 | apple | jiya-zhang | @@ -922,3 +953,220 @@ def validate_and_restore(*, step: int, ckpt_dir: str):
restored_state = state
return step, restored_state
+
+
+class OrbaxCheckpointer(BaseCheckpointer):
+ """A checkpointer that uses orbax CheckpointManager.
+
+ NOTE: While this class uses index files to do additiona... | Is this method ever called? |
axlearn | github_2023 | python | 651 | apple | jiya-zhang | @@ -922,3 +953,220 @@ def validate_and_restore(*, step: int, ckpt_dir: str):
restored_state = state
return step, restored_state
+
+
+class OrbaxCheckpointer(BaseCheckpointer):
+ """A checkpointer that uses orbax CheckpointManager.
+
+ NOTE: While this class uses index files to do additiona... | What are `index` and `tf_ckpt_args`? Does orbax provide similar functionalities, eg. checking tree structure (which I assume is what the index file is for)? |
axlearn | github_2023 | python | 662 | apple | markblee | @@ -270,6 +270,7 @@ def sample_decode(
Args:
prefix: The prefix to use for prompting. Of shape [batch, max_prefix_length].
+ The prefix for each example in the batch should begin with the [BOS] token. | nit -- not all vocabs have `[BOS]`, maybe
```suggestion
The prefix for each example in the batch should begin with a prompt token (e.g., BOS).
```
? |
axlearn | github_2023 | python | 662 | apple | markblee | @@ -679,6 +679,98 @@ def test_output_logits_modifier(self):
decoder = decoder_cfg.instantiate(parent=None)
chex.assert_trees_all_close(decoder(5 * jnp.ones(3)), dict(logits=17 * 5 * jnp.ones(3)))
+ def test_token_scores_match_between_decoded_and_prefix(self):
+ """Test that token s... | ```suggestion
This test is intended to detect if the scores from prefill_states do not match up with
``` |
axlearn | github_2023 | python | 652 | apple | markblee | @@ -172,6 +177,9 @@ def binary_clf_curve(
fps = jnp.where(y_pred_diff, fps, jnp.iinfo(jnp.int32).max)
fps = jax.lax.cummin(fps, reverse=True)
+ # Masked entries at the end of thresholds are set to jnp.finfo(jnp.float32).max.
+ # Reset them to the rightmost unmasked threshold value.
+ thresholds = j... | Thanks, as discussed offline maybe we should remove this to simplify, since the masked values should not be used anyway, and I'm not sure that `jnp.argsort(weight)[-1]` gives the rightmost unmasked value. |
axlearn | github_2023 | python | 643 | apple | ruomingp | @@ -3874,6 +3874,7 @@ def build_remat_spec(
],
self_attention: bool = True,
feed_forward: bool = False,
+ offload: bool = False, | Instead of a bool, should we allow the caller to customize `offload_dst` directly?
```suggestion
offload_dst: Optional[Literal["pinned_host"]] = None,
```
This will make the API more extensible and closer to the JAX API. |
axlearn | github_2023 | python | 643 | apple | ruomingp | @@ -3891,6 +3904,7 @@ def build_remat_spec(
stack_cfg: A transformer config.
self_attention: Checkpoint self attention layer activations if true.
feed_forward: Checkpoint feed-forward layer activations if true.
+ offload_dst: Destination of remat checkptoing offloading. | Add a link to the JAX documentation on `offset_dst` on the potential values? |
axlearn | github_2023 | python | 643 | apple | ruomingp | @@ -188,6 +188,7 @@ def get_trainer_kwargs(
num_kv_heads=None if version == Version.V1 else 8,
rope_theta=rope_theta,
flash_attention=flash_attention,
+ remat_offload_dst="pinned_host", | Add a comment on the observed MFU and step time? |
axlearn | github_2023 | python | 643 | apple | markblee | @@ -3891,6 +3904,10 @@ def build_remat_spec(
stack_cfg: A transformer config.
self_attention: Checkpoint self attention layer activations if true.
feed_forward: Checkpoint feed-forward layer activations if true.
+ offload_dst: Destination of remat checkptoing offloading. Relevant Maxte... | ```suggestion
``` |
axlearn | github_2023 | python | 556 | apple | ruomingp | @@ -1306,6 +1306,7 @@ def forward(
*,
key: Optional[Tensor] = None,
value: Optional[Tensor] = None,
+ kv_state: Optional[KVState] = None, | If `kv_state` is not None, how is it used? Should it be passed to `i_proj` below? Otherwise we should throw a NotImplementedError if kv_state is not None. |
axlearn | github_2023 | python | 465 | apple | apghml | @@ -94,8 +95,7 @@ def _prune_empty(in_tree: NestedTensor) -> NestedTensor:
return prune_tree(in_tree, lambda _, v: isinstance(v, dict) and not v)
-@dataclasses.dataclass
-class ForwardOutputs:
+class ForwardOutputs(NamedTuple): | What is the purpose of this change? |
axlearn | github_2023 | python | 465 | apple | apghml | @@ -444,6 +444,153 @@ def _mask_tree(tree: dict, *, keep: dict) -> dict:
)
+class MetricsAccumulationOp(NamedTuple): | Axlearn already has metric accumulation classes that are used by evalers. Could those be reused here instead of defining new classes? |
axlearn | github_2023 | python | 465 | apple | apghml | @@ -9,7 +9,8 @@
import dataclasses
import enum
-from typing import Callable, Mapping, Optional, Protocol, Sequence, Tuple
+import logging | We typically use absl logging instead of python logging. |
axlearn | github_2023 | python | 465 | apple | apghml | @@ -444,6 +444,153 @@ def _mask_tree(tree: dict, *, keep: dict) -> dict:
)
+class MetricsAccumulationOp(NamedTuple):
+ microbatches: int
+
+ def aggregrate(self, x, buffer):
+ raise NotImplementedError(self)
+
+ def normalize(self, buffer):
+ raise NotImplementedError(self)
+
+
+class Ar... | Does the existing learner class use this? If not, we should try to be consistent with its API. |
axlearn | github_2023 | python | 465 | apple | apghml | @@ -444,6 +444,153 @@ def _mask_tree(tree: dict, *, keep: dict) -> dict:
)
+class MetricsAccumulationOp(NamedTuple):
+ microbatches: int
+
+ def aggregrate(self, x, buffer):
+ raise NotImplementedError(self)
+
+ def normalize(self, buffer):
+ raise NotImplementedError(self)
+
+
+class Ar... | I wonder if instead of having a separate learner for microbatching, it would be more flexible to have a generic way of wrapping a ForwardFn so that it uses Jax.lax.map to run the microbatches. Beyond avoiding the need to add a new learner, it would also allow for other microbetching uses outside of learner, eg inferenc... |
axlearn | github_2023 | python | 614 | apple | markblee | @@ -0,0 +1,298 @@
+# Copyright © 2024 Apple Inc.
+"""This module provides functions to decorate a ForwardFn to allow for a minibatched
+version that enables gradient accumulation.
+"""
+import functools
+from typing import Any, Callable, Optional, Tuple
+
+import jax
+import numpy as np
+from jax import numpy as jnp
+
... | Sorry for missing this earlier, but we should document the other raise conditions too. |
axlearn | github_2023 | python | 544 | apple | markblee | @@ -299,6 +299,21 @@ def _start(self):
if tier is not None:
reserved = str(tier) == "0"
logging.info("Found tier=%s in env. Using reserved=%s", tier, reserved)
+
+ # Create labels for vm tier that can be used to group tpu metrics.
+ # In QRM, vm tier can be one o... | ```suggestion
if reserved is None:
reserved = gcp_settings("reserved_tpu", default=False, required=False)
labels = {"bastion_tier": "reserved" if reserved else "spot"}
```
Not sure if `vmtier` label is arbitrary? |
axlearn | github_2023 | python | 544 | apple | markblee | @@ -299,6 +299,15 @@ def _start(self):
if tier is not None:
reserved = str(tier) == "0"
logging.info("Found tier=%s in env. Using reserved=%s", tier, reserved)
+
+ # Create labels for vm tier that can be used to group tpu metrics.
+ # In QRM, vm tier can be one o... | ```suggestion
# The "reserved" label is used for guaranteed instances and "spot" for other instances (e.g. best-effort or spot instances).
``` |
axlearn | github_2023 | python | 544 | apple | markblee | @@ -299,6 +299,15 @@ def _start(self):
if tier is not None:
reserved = str(tier) == "0"
logging.info("Found tier=%s in env. Using reserved=%s", tier, reserved)
+
+ # Create labels for vm tier that can be used to group tpu metrics.
+ # In QRM, vm tier can be one o... | ```suggestion
# BASTION_TIER env has presendence over the reserved_tpu.
``` |
axlearn | github_2023 | python | 592 | apple | apghml | @@ -62,6 +62,11 @@ def generate_job_name() -> str:
return f"{os.environ['USER'].replace('_', '')}-{uuid.uuid4().hex.lower()[:6]}"
+def generate_job_id() -> str:
+ """Generate a unique job uuid."""
+ return str(uuid.uuid4()) | IIUC, uuid4 is a random uuid. Do we know if the randomness used is good? Would it make sense to instead use `secrets.token_urlsafe()`, which is cryptographically random? |
axlearn | github_2023 | others | 470 | apple | markblee | @@ -75,6 +75,10 @@ ENV RUN_PYTHON_SDK_IN_DEFAULT_ENVIRONMENT=1
RUN pip install .[gcp,dataflow]
COPY . .
+COPY --from=apache/beam_python3.9_sdk:2.52.0 /opt/apache/beam /opt/apache/beam
+ENTRYPOINT ["/opt/apache/beam/boot"] | Do we plan to merge https://github.com/apple/axlearn/pull/384 eventually? |
axlearn | github_2023 | others | 470 | apple | markblee | @@ -75,6 +75,10 @@ ENV RUN_PYTHON_SDK_IN_DEFAULT_ENVIRONMENT=1
RUN pip install .[gcp,dataflow]
COPY . .
+COPY --from=apache/beam_python3.9_sdk:2.52.0 /opt/apache/beam /opt/apache/beam
+ENTRYPOINT ["/opt/apache/beam/boot"]
+
+ | nit -- spacing
```suggestion
``` |
axlearn | github_2023 | python | 470 | apple | markblee | @@ -0,0 +1,205 @@
+"""An Apache Beam example pipeline to run batch inference jobs using a model trained with AXLearn. | ```suggestion
"""An Apache Beam example pipeline to run batch inference jobs using a model trained with AXLearn.
```
Can we also make a separate directory like `axlearn/cloud/gcp/examples` with these scripts, to distinguish from libraries? |
axlearn | github_2023 | python | 470 | apple | markblee | @@ -0,0 +1,205 @@
+"""An Apache Beam example pipeline to run batch inference jobs using a model trained with AXLearn.
+Command line options:
+--module: the same module used for training
+--config: the same config used for training
+--trainer_dir: location of your checkpoints for inference
+
+To debug locally:
+$ docker... | nit -- Usually, `trainer_dir` refers to the root of this dir. Maybe we can call it `checkpoint_dir`? |
axlearn | github_2023 | python | 470 | apple | markblee | @@ -0,0 +1,205 @@
+"""An Apache Beam example pipeline to run batch inference jobs using a model trained with AXLearn.
+Command line options:
+--module: the same module used for training
+--config: the same config used for training
+--trainer_dir: location of your checkpoints for inference
+
+To debug locally:
+$ docker... | Comment on why we need this? |
axlearn | github_2023 | python | 470 | apple | markblee | @@ -0,0 +1,205 @@
+"""An Apache Beam example pipeline to run batch inference jobs using a model trained with AXLearn.
+Command line options:
+--module: the same module used for training
+--config: the same config used for training
+--trainer_dir: location of your checkpoints for inference
+
+To debug locally:
+$ docker... | ```suggestion
"""Defines how to load a custom checkpoint and run inference."""
``` |
axlearn | github_2023 | python | 470 | apple | markblee | @@ -0,0 +1,205 @@
+"""An Apache Beam example pipeline to run batch inference jobs using a model trained with AXLearn.
+Command line options:
+--module: the same module used for training
+--config: the same config used for training
+--trainer_dir: location of your checkpoints for inference
+
+To debug locally:
+$ docker... | Missing types. Also comment on what `flag_dict` is supposed to represent? I suppose these are the locally-parsed flag values corresponding to trainer flags? |
axlearn | github_2023 | python | 470 | apple | markblee | @@ -0,0 +1,205 @@
+"""An Apache Beam example pipeline to run batch inference jobs using a model trained with AXLearn.
+Command line options:
+--module: the same module used for training
+--config: the same config used for training
+--trainer_dir: location of your checkpoints for inference
+
+To debug locally:
+$ docker... | Following the [google style guide](https://google.github.io/styleguide/pyguide.html#386-punctuation-spelling-and-grammar), comments should be full sentences with punctuations.
(Please also fix elsewhere, thanks!) |
axlearn | github_2023 | python | 470 | apple | markblee | @@ -0,0 +1,205 @@
+"""An Apache Beam example pipeline to run batch inference jobs using a model trained with AXLearn.
+Command line options:
+--module: the same module used for training
+--config: the same config used for training
+--trainer_dir: location of your checkpoints for inference
+
+To debug locally:
+$ docker... | ```suggestion
trainer_cfg = trainer_utils.get_trainer_config(flag_values=flag_values)
``` |
axlearn | github_2023 | python | 470 | apple | markblee | @@ -0,0 +1,205 @@
+"""An Apache Beam example pipeline to run batch inference jobs using a model trained with AXLearn.
+Command line options:
+--module: the same module used for training
+--config: the same config used for training
+--trainer_dir: location of your checkpoints for inference
+
+To debug locally:
+$ docker... | ```suggestion
inference_runner = inference_runner_cfg.instantiate(parent=None)
``` |
axlearn | github_2023 | python | 470 | apple | markblee | @@ -0,0 +1,205 @@
+"""An Apache Beam example pipeline to run batch inference jobs using a model trained with AXLearn.
+Command line options:
+--module: the same module used for training
+--config: the same config used for training
+--trainer_dir: location of your checkpoints for inference
+
+To debug locally:
+$ docker... | nit -- we don't need the extra `method_runner` variable. |
axlearn | github_2023 | python | 470 | apple | markblee | @@ -0,0 +1,205 @@
+"""An Apache Beam example pipeline to run batch inference jobs using a model trained with AXLearn.
+Command line options:
+--module: the same module used for training
+--config: the same config used for training
+--trainer_dir: location of your checkpoints for inference
+
+To debug locally:
+$ docker... | Should we have a way to configure the PRNGKey? |
axlearn | github_2023 | python | 470 | apple | markblee | @@ -0,0 +1,205 @@
+"""An Apache Beam example pipeline to run batch inference jobs using a model trained with AXLearn.
+Command line options:
+--module: the same module used for training
+--config: the same config used for training
+--trainer_dir: location of your checkpoints for inference
+
+To debug locally:
+$ docker... | Missing returns? |
axlearn | github_2023 | python | 470 | apple | markblee | @@ -0,0 +1,205 @@
+"""An Apache Beam example pipeline to run batch inference jobs using a model trained with AXLearn.
+Command line options:
+--module: the same module used for training
+--config: the same config used for training
+--trainer_dir: location of your checkpoints for inference
+
+To debug locally:
+$ docker... | ```suggestion
Args:
batch: A sequence of examples as NestedTensors.
model: An instance of a MethodRunner.
inference_kwargs: Optional additional keyword arguments for inference.
Returns:
A list of method runner outputs.
```
In general, we do not... |
axlearn | github_2023 | python | 470 | apple | markblee | @@ -0,0 +1,205 @@
+"""An Apache Beam example pipeline to run batch inference jobs using a model trained with AXLearn.
+Command line options:
+--module: the same module used for training
+--config: the same config used for training
+--trainer_dir: location of your checkpoints for inference
+
+To debug locally:
+$ docker... | nit -- use fstring for logging. |
axlearn | github_2023 | python | 470 | apple | markblee | @@ -0,0 +1,205 @@
+"""An Apache Beam example pipeline to run batch inference jobs using a model trained with AXLearn.
+Command line options:
+--module: the same module used for training
+--config: the same config used for training
+--trainer_dir: location of your checkpoints for inference
+
+To debug locally:
+$ docker... | Missing types. Also, comment on what this `PostProcessFn` is supposed to do? |
axlearn | github_2023 | python | 470 | apple | markblee | @@ -0,0 +1,205 @@
+"""An Apache Beam example pipeline to run batch inference jobs using a model trained with AXLearn.
+Command line options:
+--module: the same module used for training
+--config: the same config used for training
+--trainer_dir: location of your checkpoints for inference
+
+To debug locally:
+$ docker... | nit -- iterate over `fake_input` directly and break (or use `take`) if needed. |
axlearn | github_2023 | python | 470 | apple | markblee | @@ -0,0 +1,205 @@
+"""An Apache Beam example pipeline to run batch inference jobs using a model trained with AXLearn.
+Command line options:
+--module: the same module used for training
+--config: the same config used for training
+--trainer_dir: location of your checkpoints for inference
+
+To debug locally:
+$ docker... | Seems this is mainly intended for pipeline args? If so, clarify in docstring? |
axlearn | github_2023 | python | 470 | apple | markblee | @@ -0,0 +1,105 @@
+"""An Apache Beam example pipeline to run batch inference jobs with a HuggingFace model.
+Reference: https://cloud.google.com/dataflow/docs/notebooks/
+run_inference_huggingface#runinference_with_a_pretrained_model_from_hugging_face_hub
+
+ | ```suggestion
"""An Apache Beam example pipeline to run batch inference jobs with a HuggingFace model.
Reference: https://cloud.google.com/dataflow/docs/notebooks/
run_inference_huggingface#runinference_with_a_pretrained_model_from_hugging_face_hub
``` |
axlearn | github_2023 | others | 470 | apple | markblee | @@ -33,6 +33,7 @@ dependencies = [
"tensorstore>=0.1.21", # used for supporting GDA checkpoints
"toml", # for config management
"typing-extensions==4.9.0", # needed for typing.Protocol. >4.9.0 runs into attribute error `__non_callable_proto_members__`.
+ "scipy==1.12.0", | I think this should go away with a rebase. |
axlearn | github_2023 | python | 470 | apple | markblee | @@ -0,0 +1,202 @@
+"""An Apache Beam example pipeline to run batch inference jobs using a model trained with AXLearn. | I think we require a copyright header on all files. |
axlearn | github_2023 | python | 470 | apple | yqwangustc | @@ -0,0 +1,202 @@
+"""An Apache Beam example pipeline to run batch inference jobs using a model trained with AXLearn.
+
+Command line options:
+--module: the same module used for training
+--config: the same config used for training
+--trainer_dir: location of your checkpoints for inference
+
+To debug locally:
+$ dock... | Looks like this is a new thing. Do you have document pointer for this ModelHandler ? |
axlearn | github_2023 | others | 470 | apple | ruomingp | @@ -75,6 +75,9 @@ ENV RUN_PYTHON_SDK_IN_DEFAULT_ENVIRONMENT=1
RUN pip install .[gcp,dataflow]
COPY . .
+COPY --from=apache/beam_python3.9_sdk:2.52.0 /opt/apache/beam /opt/apache/beam
+ENTRYPOINT ["/opt/apache/beam/boot"] | Comment on why we need this step? |
axlearn | github_2023 | python | 470 | apple | ruomingp | @@ -0,0 +1,205 @@
+# Copyright © 2024 Google LLC
+
+"""An Apache Beam example pipeline to run batch inference jobs using a model trained with AXLearn.
+
+Command line options:
+--module: the same module used for training
+--config: the same config used for training
+--trainer_dir: location of your checkpoints for infer... | Is there a way to use TPU? |
axlearn | github_2023 | python | 470 | apple | ruomingp | @@ -0,0 +1,205 @@
+# Copyright © 2024 Google LLC
+
+"""An Apache Beam example pipeline to run batch inference jobs using a model trained with AXLearn.
+
+Command line options:
+--module: the same module used for training
+--config: the same config used for training
+--trainer_dir: location of your checkpoints for infer... | Is this method inheriting from the parent class? |
axlearn | github_2023 | python | 224 | apple | ruomingp | @@ -130,7 +129,6 @@ def __init__(self, cfg: _BaseLoraAdapter.Config, *, parent: Module):
cfg.lora_up.set(
input_dim=cfg.rank,
output_dim=cfg.output_dim,
- param_partition_spec=["model", None], | Is there a test for this change? |
axlearn | github_2023 | python | 578 | apple | markblee | @@ -188,6 +187,24 @@ def _aggregate_tool_role_messages(messages: List[Dict[str, Any]]) -> List[Dict[s
return aggregated_messages
+def _santize_request(request: Dict[str, Any]):
+ """Santizes request to follow Gemini request rules.""" | ```suggestion
def _format_request(request: Dict[str, Any]):
"""Formats request to follow Gemini request rules."""
```
Since it seems more like formatting than sanitization? |
axlearn | github_2023 | python | 578 | apple | markblee | @@ -69,20 +65,22 @@ async def async_generate(
"""
cfg: OpenAIClient.Config = self.config
client: AsyncOpenAI = self._client
- assert prompt is not None or messages is not None, ValidationError(
+ prompt = request.get("prompt", None)
+ messages = request.get("messages", No... | Is this correct? Previously we require one to be non-None, but now we check that one of them is None. |
axlearn | github_2023 | python | 578 | apple | markblee | @@ -188,6 +187,24 @@ def _aggregate_tool_role_messages(messages: List[Dict[str, Any]]) -> List[Dict[s
return aggregated_messages
+def _santize_request(request: Dict[str, Any]):
+ """Santizes request to follow Gemini request rules."""
+ if "messages" in request:
+ new_messages = []
+ for mes... | nit -- could be simpler with list comprehensions. |
axlearn | github_2023 | python | 300 | apple | gyin94 | @@ -125,26 +125,40 @@ class Foo:
def similar_names(name: str, candidates: Iterable[str]) -> List[str]:
- """Return a sorted list of candidates that are similar to name."""
-
- def overlaps(name: str, key: str) -> float:
- """The fraction of 3-char substrings in <name> that appear in key."""
- m... | consider a type hint and return type? |
axlearn | github_2023 | python | 572 | apple | patrick-toulme | @@ -305,80 +310,99 @@ def vmap_fn(
policy=jax.checkpoint_policies.nothing_saveable,
)
def scan_fn(
- carry_output_t_1: NestedTensor,
- scan_t: Tuple[NestedTensor, NestedTensor, NestedTensor],
+ carry_in: NestedTensor,
+ ... | see this PR: https://github.com/markblee/axlearn/pull/1 |
axlearn | github_2023 | python | 573 | apple | markblee | @@ -272,6 +264,85 @@ async def async_generate_from_requests(
del item["async_index"]
return responses
+ @classmethod
+ def define_flags(cls, fv: flags.FlagValues):
+ """Defines flags for generator.py."""
+ common_kwargs = dict(flag_values=fv, allow_override=True)
+ ... | Forgot to mention, but for these non-config flags (check_vllm_readiness, debug or repeat_requests_for_n) it may be worth defining them separately in `generator.py`. Feel free to address separately. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.