| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Signed-off-by: 0oshowero0 <o0shower0o@outlook.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command. You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Comment @coderabbitai help to get the list of available commands and usage tips. |
Sorry, something went wrong.
| return partition.generate_data_status_mask(field_names, task_name, sample_filter) | ||
|
|
||
| def _get_metadata( | ||
| def get_metadata( |
There was a problem hiding this comment.
Why not make get_metadata a private method?
Sorry, something went wrong.
|
|
||
| def _scan_data_status( | ||
| self, data_fields: list[str], global_step: int, task_name: str, get_n_samples: bool | ||
| def scan_data_status( |
There was a problem hiding this comment.
Why not make scan_data_status a private method?
Sorry, something went wrong.
|
|
||
| def _generate_batch_meta( | ||
| self, global_step: int, global_indexes: list[int], data_fields: list[str], mode: str | ||
| def generate_batch_meta( |
There was a problem hiding this comment.
Why not make generate_batch_meta a private method?
Sorry, something went wrong.
| per_field_shapes[global_idx][field] = data_item.shape if hasattr(data_item, "shape") else None | ||
|
|
||
| # Get current data partition id | ||
| partition_id = metadata.samples[0].partition_id |
There was a problem hiding this comment.
Maybe we need to support put to & get from multiple partitions.
We can simply point out that currently we support only one partition and may consider supporting it in the future
Sorry, something went wrong.
| metadata: Records the metadata of a batch of data samples, containing index and | ||
| storage unit information. If None, metadata will be auto-generated. | ||
| global_step: Current processing step (required if metadata is not provided) | ||
| partition_id: Current data partition id (required if metadata is not provided) |
There was a problem hiding this comment.
| partition_id: Current data partition id (required if metadata is not provided) | |
| partition_id: Target data partition id (required if metadata is not provided) |
Sorry, something went wrong.
|
|
||
| if metadata is None: | ||
| assert global_step is not None, "global_steps must be provided if metadata is not given" | ||
| assert partition_id is not None, "partition_id must be provided if metadata is not given" |
There was a problem hiding this comment.
better to raise an error. assert might be ignored
Sorry, something went wrong.
|
|
||
| @dynamic_socket(socket_name="request_handle_socket") | ||
| async def check_current_step_consumption(self, task_name: str, global_step: int): | ||
| async def check_current_step_consumption(self, task_name: str, partition_id: str): |
There was a problem hiding this comment.
| async def check_current_step_consumption(self, task_name: str, partition_id: str): | |
| async def check_data_consumption_status(self, task_name: str, partition_id: str): |
Sorry, something went wrong.
| @dynamic_socket(socket_name="request_handle_socket") | ||
| async def check_current_step_production(self, data_fields: list[str], global_step: int): | ||
| """Check if all samples for current step are ready for consumption. | ||
| async def check_current_step_production(self, data_fields: list[str], partition_id: str): |
There was a problem hiding this comment.
| async def check_current_step_production(self, data_fields: list[str], partition_id: str): | |
| async def check_data_production_status(self, data_fields: list[str], partition_id: str): |
Sorry, something went wrong.
| data: Data to write as TensorDict | ||
| metadata: Optional metadata containing index and storage unit information | ||
| global_step: Current processing step (required if metadata is not provided) | ||
| partition_id: Current data partition id (required if metadata is not provided) |
There was a problem hiding this comment.
| partition_id: Current data partition id (required if metadata is not provided) | |
| partition_id: Target data partition id (required if metadata is not provided) |
Sorry, something went wrong.
| data_fields: List of data field names to retrieve metadata for | ||
| batch_size: Number of samples to request in the batch | ||
| global_step: Current training/processing step | ||
| partition_id: Current data partition id |
There was a problem hiding this comment.
| partition_id: Current data partition id | |
| partition_id: Target data partition |
Sorry, something went wrong.
| TQ_FIELD_MIN_EXPANSION_SIZE = int( | ||
| os.environ.get("TQ_FIELD_MIN_EXPANSION_SIZE", 5) | ||
| ) # Minimum expansion size for fields (columns) | ||
| TQ_INIT_SAMPLE_NUM = int(os.environ.get("TQ_INIT_SAMPLE_NUM", 10)) # Initial number of samples |
There was a problem hiding this comment.
Put this near TQ_INIT_FIELD_NUM ~
Sorry, something went wrong.
| for idx in indexes: | ||
| self.allocated_indexes.discard(idx) |
There was a problem hiding this comment.
why allocated_indexes is tracking reusable_indexes?
Sorry, something went wrong.
There was a problem hiding this comment.
maybe we can just release them during release_indexes
Sorry, something went wrong.
| indexes = [] | ||
|
|
||
| # Get indexes from reusable pool | ||
| if self.reusable_indexes and count > 0: |
There was a problem hiding this comment.
need to tackle count <=0 by rasing an error
Sorry, something went wrong.
| while len(new_indexes) < needed: | ||
| # Check if current counter points to an already used index | ||
| if self.global_index_counter not in self.allocated_indexes: | ||
| new_indexes.append(self.global_index_counter) | ||
| self.allocated_indexes.add(self.global_index_counter) | ||
| self.global_index_counter += 1 | ||
| else: | ||
| # If already used, increment counter until finding available index | ||
| self.global_index_counter += 1 | ||
|
|
||
| indexes.extend(new_indexes) |
There was a problem hiding this comment.
can be optimized. using while loop and append list is slow
Sorry, something went wrong.
| # Add released indexes to allocated_indexes set | ||
| self.allocated_indexes.update(indexes) |
There was a problem hiding this comment.
why?
Sorry, something went wrong.
| """ | ||
| return self.partition_to_indexes.get(partition_id, set()).copy() | ||
|
|
||
| def get_allocated_indexes(self): |
There was a problem hiding this comment.
If not used, we can simply delete this func
Sorry, something went wrong.
|
|
||
| # Field metadata | ||
| field_name_mapping: dict[str, int] = field(default_factory=dict) # field_name -> column_index | ||
| field_dtypes: dict[int, dict[str, Any]] = field(default_factory=dict) # sample_idx -> {field: dtype} |
There was a problem hiding this comment.
sample_idx -> global_idx?
Sorry, something went wrong.
| return len(self.field_name_mapping) | ||
|
|
||
| @property | ||
| def allocated_fields(self) -> int: |
There was a problem hiding this comment.
if not used we can delete this func
Sorry, something went wrong.
| return self.production_status.shape[0] if self.production_status is not None else 0 | ||
|
|
||
| @property | ||
| def total_fields(self) -> int: |
There was a problem hiding this comment.
| def total_fields(self) -> int: | |
| def total_fields_num(self) -> int: |
Sorry, something went wrong.
|
|
||
| # Dynamic configuration - these are computed from the current state | ||
| @property | ||
| def total_samples(self) -> int: |
There was a problem hiding this comment.
| def total_samples(self) -> int: | |
| def total_samples_num(self) -> int: |
Sorry, something went wrong.
| Returns: | ||
| True if expansion was successful or not needed, False on error | ||
| """ | ||
| if self.production_status is None: |
There was a problem hiding this comment.
better do this during init process
Sorry, something went wrong.
| required_samples: Minimum number of samples needed | ||
|
|
||
| Returns: | ||
| True if expansion was successful or not needed, False on error |
There was a problem hiding this comment.
we don't need a return value. same for field expansion
Sorry, something went wrong.
There was a problem hiding this comment.
add TODO
Sorry, something went wrong.
| num_n_samples: int = 1, | ||
| ) -> None: | ||
| """Initialize the TransferQueueController. | ||
| sample_indices: list[int], |
There was a problem hiding this comment.
| sample_indices: list[int], | |
| global_indices: list[int], |
Sorry, something went wrong.
| """Initialize the TransferQueueController. | ||
| sample_indices: list[int], | ||
| field_names: list[str], | ||
| dtypes: Optional[dict[int, dict[str, Any]]] = None, |
There was a problem hiding this comment.
the d type and shape will be always required
Sorry, something went wrong.
There was a problem hiding this comment.
because many storage backends need these info to speed up transport
Sorry, something went wrong.
There was a problem hiding this comment.
add TODO
Sorry, something went wrong.
| # Ensure consumption tensor has same number of rows as production tensor | ||
| consumption_tensor = self.consumption_status[task_name] | ||
| if self.production_status is not None and consumption_tensor.shape[0] < self.total_samples: | ||
| expanded_consumption = torch.zeros(self.total_samples, dtype=torch.int8) | ||
| expanded_consumption[: consumption_tensor.shape[0]] = consumption_tensor | ||
| self.consumption_status[task_name] = expanded_consumption |
There was a problem hiding this comment.
extend consumption status should not be here (in get_consumption_status)? When we update data status, we should extend the consumption status as well
Sorry, something went wrong.
| sample_indices: List of sample indices to mark as consumed | ||
|
|
||
| Returns: | ||
| True if successful, False on error |
There was a problem hiding this comment.
Just raise an error. same for other functions
Sorry, something went wrong.
There was a problem hiding this comment.
add TODO
Sorry, something went wrong.
|
|
||
| # ==================== Data Scanning and Query Methods ==================== | ||
|
|
||
| def scan_data_status( |
There was a problem hiding this comment.
When merge with Sampler design, maybe we can just pass the production_status and consumption_status to the Sampler.sample function.
Sorry, something went wrong.
There was a problem hiding this comment.
need more thinking here
Sorry, something went wrong.
There was a problem hiding this comment.
暂时不用改
Sorry, something went wrong.
| return [] | ||
|
|
||
| # Create row mask | ||
| if sample_filter is not None: |
There was a problem hiding this comment.
if it is not necessary, we can delete it
Sorry, something went wrong.
|
|
||
| return ready_sample_indices | ||
|
|
||
| def generate_data_status_mask( |
There was a problem hiding this comment.
if it is not necessary, we can delete it
Sorry, something went wrong.
| logger.error(f"Error updating production status for partition {self.partition_id}: {e}") | ||
| return False | ||
|
|
||
| def _update_field_metadata( |
There was a problem hiding this comment.
need to optimize. Now it will be very slow
Sorry, something went wrong.
There was a problem hiding this comment.
add TODO
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
No description provided.