Sync contents

This commit is contained in:
Daniel Xu 2025-11-25 05:55:10 +00:00
parent 097e108902
commit 937c36e9b1
6 changed files with 109 additions and 106 deletions

View file

@ -25,7 +25,7 @@ result = api_future.result() # Blocks until complete
```
Args:
T: The type of the result value
- `T`: The type of the result value
Example:
```python
@ -48,10 +48,10 @@ async def result_async(timeout: float | None = None) -> T
Get the result asynchronously with optional timeout.
Args:
timeout: Maximum time to wait in seconds. None means wait indefinitely.
- `timeout`: Maximum time to wait in seconds. None means wait indefinitely.
Returns:
The result value of type T
- The result value of type `T`
Raises:
TimeoutError: If timeout is exceeded
@ -66,10 +66,10 @@ def result(timeout: float | None = None) -> T
Get the result synchronously with optional timeout.
Args:
timeout: Maximum time to wait in seconds. None means wait indefinitely.
- `timeout`: Maximum time to wait in seconds. None means wait indefinitely.
Returns:
The result value of type T
- The result value of type `T`
Raises:
TimeoutError: If timeout is exceeded
@ -87,7 +87,7 @@ standard Future to be used in async contexts. It's commonly returned by
Tinker API methods to provide both sync and async access patterns.
Args:
future: A concurrent.futures.Future to wrap
- `future`: A concurrent.futures.Future to wrap
Example:
```python
@ -111,10 +111,10 @@ def result(timeout: float | None = None) -> T
Get the result synchronously with optional timeout.
Args:
timeout: Maximum time to wait in seconds. None means wait indefinitely.
- `timeout`: Maximum time to wait in seconds. None means wait indefinitely.
Returns:
The result value of type T
- The result value of type `T`
Raises:
TimeoutError: If timeout is exceeded
@ -143,7 +143,7 @@ def future() -> ConcurrentFuture[T]
Get the underlying concurrent.futures.Future.
Returns:
The wrapped ConcurrentFuture object
- The wrapped `ConcurrentFuture` object
Example:
```python

View file

@ -24,7 +24,7 @@ Key methods:
- unpublish_checkpoint_from_tinker_path() - unpublish a checkpoint to make it private
Args:
holder: Internal client managing HTTP connections and async operations
- `holder`: Internal client managing HTTP connections and async operations
Example:
```python
@ -49,10 +49,10 @@ def get_training_run(
Get training run info.
Args:
training_run_id: The training run ID to get information for
- `training_run_id`: The training run ID to get information for
Returns:
A Future containing the training run information
- A `Future` containing the training run information
Example:
```python
@ -83,10 +83,10 @@ def get_training_run_by_tinker_path(
Get training run info.
Args:
tinker_path: The tinker path to the checkpoint
- `tinker_path`: The tinker path to the checkpoint
Returns:
A Future containing the training run information
- A `Future` containing the training run information
Example:
```python
@ -116,10 +116,10 @@ def get_weights_info_by_tinker_path(
Get checkpoint information from a tinker path.
Args:
tinker_path: The tinker path to the checkpoint
- `tinker_path`: The tinker path to the checkpoint
Returns:
An APIFuture containing the checkpoint information. The future is awaitable.
- An `APIFuture` containing the checkpoint information. The future is awaitable.
Example:
```python
@ -141,11 +141,11 @@ def list_training_runs(
List training runs with pagination support.
Args:
limit: Maximum number of training runs to return (default 20)
offset: Offset for pagination (default 0)
- `limit`: Maximum number of training runs to return (default 20)
- `offset`: Offset for pagination (default 0)
Returns:
A Future containing the TrainingRunsResponse with training runs and cursor info
- A `Future` containing the `TrainingRunsResponse` with training runs and cursor info
Example:
```python
@ -181,10 +181,10 @@ def list_checkpoints(
List available checkpoints (both training and sampler).
Args:
training_run_id: The training run ID to list checkpoints for
- `training_run_id`: The training run ID to list checkpoints for
Returns:
A Future containing the CheckpointsListResponse with available checkpoints
- A `Future` containing the `CheckpointsListResponse` with available checkpoints
Example:
```python
@ -220,11 +220,11 @@ def get_checkpoint_archive_url(
Get signed URL to download checkpoint archive.
Args:
training_run_id: The training run ID to download weights for
checkpoint_id: The checkpoint ID to download
- `training_run_id`: The training run ID to download weights for
- `checkpoint_id`: The checkpoint ID to download
Returns:
A Future containing the CheckpointArchiveUrlResponse with signed URL and expiration
- A `Future` containing the `CheckpointArchiveUrlResponse` with signed URL and expiration
Example:
```python
@ -300,10 +300,10 @@ def get_checkpoint_archive_url_from_tinker_path(
Get signed URL to download checkpoint archive.
Args:
tinker_path: The tinker path to the checkpoint
- `tinker_path`: The tinker path to the checkpoint
Returns:
A Future containing the CheckpointArchiveUrlResponse with signed URL and expiration
- A `Future` containing the `CheckpointArchiveUrlResponse` with signed URL and expiration
#### `get_checkpoint_archive_url_from_tinker_path_async`
@ -330,10 +330,10 @@ Only the exact owner of the training run can publish checkpoints.
Published checkpoints can be unpublished using the unpublish_checkpoint_from_tinker_path method.
Args:
tinker_path: The tinker path to the checkpoint (e.g., "tinker://run-id/weights/0001")
- `tinker_path`: The tinker path to the checkpoint (e.g., "tinker://run-id/weights/0001")
Returns:
A Future that completes when the checkpoint is published
- A `Future` that completes when the checkpoint is published
Raises:
HTTPException: 400 if checkpoint identifier is invalid
@ -372,10 +372,10 @@ Only the exact owner of the training run can unpublish checkpoints.
This reverses the effect of publishing a checkpoint.
Args:
tinker_path: The tinker path to the checkpoint (e.g., "tinker://run-id/weights/0001")
- `tinker_path`: The tinker path to the checkpoint (e.g., "tinker://run-id/weights/0001")
Returns:
A Future that completes when the checkpoint is unpublished
- A `Future` that completes when the checkpoint is unpublished
Raises:
HTTPException: 400 if checkpoint identifier is invalid
@ -417,11 +417,11 @@ sorted by time (newest first). It supports pagination for efficiently handling l
numbers of checkpoints.
Args:
limit: Maximum number of checkpoints to return (default 100)
offset: Offset for pagination (default 0)
- `limit`: Maximum number of checkpoints to return (default 100)
- `offset`: Offset for pagination (default 0)
Returns:
A Future containing the CheckpointsListResponse with checkpoints and cursor info
- A `Future` containing the `CheckpointsListResponse` with checkpoints and cursor info
Example:
```python
@ -458,10 +458,10 @@ def get_session(session_id: str) -> ConcurrentFuture[types.GetSessionResponse]
Get session information including all training runs and samplers.
Args:
session_id: The session ID to get information for
- `session_id`: The session ID to get information for
Returns:
A Future containing the GetSessionResponse with training_run_ids and sampler_ids
- A `Future` containing the `GetSessionResponse` with training_run_ids and sampler_ids
Example:
```python
@ -493,11 +493,11 @@ def list_sessions(
List sessions with pagination support.
Args:
limit: Maximum number of sessions to return (default 20)
offset: Offset for pagination (default 0)
- `limit`: Maximum number of sessions to return (default 20)
- `offset`: Offset for pagination (default 0)
Returns:
A Future containing the ListSessionsResponse with list of session IDs
- A `Future` containing the `ListSessionsResponse` with list of session IDs
Example:
```python
@ -528,10 +528,10 @@ def get_sampler(sampler_id: str) -> APIFuture[types.GetSamplerResponse]
Get sampler information.
Args:
sampler_id: The sampler ID (sampling_session_id) to get information for
- `sampler_id`: The sampler ID (sampling_session_id) to get information for
Returns:
An APIFuture containing the GetSamplerResponse with sampler details
- An `APIFuture` containing the `GetSamplerResponse` with sampler details
Example:
```python

View file

@ -18,10 +18,10 @@ Key methods:
- compute_logprobs() - get log probabilities for prompt tokens
Args:
holder: Internal client managing HTTP connections and async operations
model_path: Path to saved model weights (starts with 'tinker://')
base_model: Name of base model to use for inference
retry_config: Configuration for retrying failed requests
- `holder`: Internal client managing HTTP connections and async operations
- `model_path`: Path to saved model weights (starts with 'tinker://')
- `base_model`: Name of base model to use for inference
- `retry_config`: Configuration for retrying failed requests
Example:
```python
@ -48,14 +48,14 @@ def sample(
Generate text completions from the model.
Args:
prompt: The input tokens as ModelInput
num_samples: Number of independent samples to generate
sampling_params: Parameters controlling generation (temperature, max_tokens, etc.)
include_prompt_logprobs: Whether to include log probabilities for prompt tokens
topk_prompt_logprobs: Number of top token log probabilities to return per position
- `prompt`: The input tokens as ModelInput
- `num_samples`: Number of independent samples to generate
- `sampling_params`: Parameters controlling generation (temperature, max_tokens, etc.)
- `include_prompt_logprobs`: Whether to include log probabilities for prompt tokens
- `topk_prompt_logprobs`: Number of top token log probabilities to return per position
Returns:
A Future containing the SampleResponse with generated text
- A `Future` containing the `SampleResponse` with generated text
Example:
```python
@ -90,10 +90,10 @@ def compute_logprobs(
Compute log probabilities for prompt tokens.
Args:
prompt: The input tokens as ModelInput
- `prompt`: The input tokens as ModelInput
Returns:
A Future containing a list of log probabilities for each token in the prompt.
- A `Future` containing a list of log probabilities for each token in the prompt.
None values indicate tokens where log probabilities couldn't be computed.
Example:

View file

@ -20,14 +20,17 @@ Args:
Example:
```python
# Near instant
client = ServiceClient()
# ^^^ near-instant
# Takes a moment as we initialize the model and assign resources
training_client = client.create_lora_training_client(base_model="Qwen/Qwen3-8B")
# ^^^ takes a moment as we initialize the model and assign resources
# Near-instant
sampling_client = client.create_sampling_client(base_model="Qwen/Qwen3-8B")
# ^^^ near-instant
# Near-instant
rest_client = client.create_rest_client()
# ^^^ near-instant
```
#### `get_server_capabilities`
@ -41,7 +44,7 @@ def get_server_capabilities() -> types.GetServerCapabilitiesResponse
Query the server's supported features and capabilities.
Returns:
GetServerCapabilitiesResponse with available models, features, and limits
- `GetServerCapabilitiesResponse` with available models, features, and limits
Example:
```python
@ -78,16 +81,16 @@ def create_lora_training_client(
Create a TrainingClient for LoRA fine-tuning.
Args:
base_model: Name of the base model to fine-tune (e.g., "Qwen/Qwen2.5-7B")
rank: LoRA rank controlling the size of adaptation matrices (default 32)
seed: Random seed for initialization. None means random seed.
train_mlp: Whether to train MLP layers (default True)
train_attn: Whether to train attention layers (default True)
train_unembed: Whether to train unembedding layers (default True)
user_metadata: Optional metadata to attach to the training run
- `base_model`: Name of the base model to fine-tune (e.g., "Qwen/Qwen2.5-7B")
- `rank`: LoRA rank controlling the size of adaptation matrices (default 32)
- `seed`: Random seed for initialization. None means random seed.
- `train_mlp`: Whether to train MLP layers (default True)
- `train_attn`: Whether to train attention layers (default True)
- `train_unembed`: Whether to train unembedding layers (default True)
- `user_metadata`: Optional metadata to attach to the training run
Returns:
TrainingClient configured for LoRA training
- `TrainingClient` configured for LoRA training
Example:
```python
@ -129,11 +132,11 @@ def create_training_client_from_state(
Create a TrainingClient from saved model weights.
Args:
path: Tinker path to saved weights (e.g., "tinker://run-id/weights/checkpoint-001")
user_metadata: Optional metadata to attach to the new training run
- `path`: Tinker path to saved weights (e.g., "tinker://run-id/weights/checkpoint-001")
- `user_metadata`: Optional metadata to attach to the new training run
Returns:
TrainingClient loaded with the specified weights
- `TrainingClient` loaded with the specified weights
Example:
```python
@ -168,12 +171,12 @@ def create_sampling_client(
Create a SamplingClient for text generation.
Args:
model_path: Path to saved model weights (e.g., "tinker://run-id/weights/checkpoint-001")
base_model: Name of base model to use (e.g., "Qwen/Qwen2.5-7B")
retry_config: Optional configuration for retrying failed requests
- `model_path`: Path to saved model weights (e.g., "tinker://run-id/weights/checkpoint-001")
- `base_model`: Name of base model to use (e.g., "Qwen/Qwen2.5-7B")
- `retry_config`: Optional configuration for retrying failed requests
Returns:
SamplingClient configured for text generation
- `SamplingClient` configured for text generation
Raises:
ValueError: If neither model_path nor base_model is provided
@ -216,7 +219,7 @@ The RestClient provides access to various REST endpoints for querying
model information, checkpoints, sessions, and managing checkpoint visibility.
Returns:
RestClient for accessing REST API endpoints
- `RestClient` for accessing REST API endpoints
Example:
```python

View file

@ -18,8 +18,8 @@ Key methods:
- save_weights_and_get_sampling_client() - export trained model for inference
Args:
holder: Internal client managing HTTP connections and async operations
model_id: Unique identifier for the model to train. Required for training operations.
- `holder`: Internal client managing HTTP connections and async operations
- `model_id`: Unique identifier for the model to train. Required for training operations.
Example:
```python
@ -45,12 +45,12 @@ def forward(
Compute forward pass without gradients.
Args:
data: List of training data samples
loss_fn: Loss function type (e.g., "cross_entropy")
loss_fn_config: Optional configuration for the loss function
- `data`: List of training data samples
- `loss_fn`: Loss function type (e.g., "cross_entropy")
- `loss_fn_config`: Optional configuration for the loss function
Returns:
APIFuture containing the forward pass outputs and loss
- `APIFuture` containing the forward pass outputs and loss
Example:
```python
@ -89,12 +89,12 @@ def forward_backward(
Compute forward pass and backward pass to calculate gradients.
Args:
data: List of training data samples
loss_fn: Loss function type (e.g., "cross_entropy")
loss_fn_config: Optional configuration for the loss function
- `data`: List of training data samples
- `loss_fn`: Loss function type (e.g., "cross_entropy")
- `loss_fn_config`: Optional configuration for the loss function
Returns:
APIFuture containing the forward/backward outputs, loss, and gradients
- `APIFuture` containing the forward/backward outputs, loss, and gradients
Example:
```python
@ -143,11 +143,11 @@ Allows you to define custom loss functions that operate on log probabilities.
The custom function receives logprobs and computes loss and gradients.
Args:
data: List of training data samples
loss_fn: Custom loss function that takes (data, logprobs) and returns (loss, metrics)
- `data`: List of training data samples
- `loss_fn`: Custom loss function that takes (data, logprobs) and returns (loss, metrics)
Returns:
APIFuture containing the forward/backward outputs with custom loss
- `APIFuture` containing the forward/backward outputs with custom loss
Example:
```python
@ -185,10 +185,10 @@ def optim_step(
Update model parameters using Adam optimizer.
Args:
adam_params: Adam optimizer parameters (learning_rate, betas, eps, weight_decay)
- `adam_params`: Adam optimizer parameters (learning_rate, betas, eps, weight_decay)
Returns:
APIFuture containing optimizer step response
- `APIFuture` containing optimizer step response
Example:
```python
@ -227,10 +227,10 @@ def save_state(name: str) -> APIFuture[types.SaveWeightsResponse]
Save model weights to persistent storage.
Args:
name: Name for the saved checkpoint
- `name`: Name for the saved checkpoint
Returns:
APIFuture containing the save response with checkpoint path
- `APIFuture` containing the save response with checkpoint path
Example:
```python
@ -258,10 +258,10 @@ def load_state(path: str) -> APIFuture[types.LoadWeightsResponse]
Load model weights from a saved checkpoint.
Args:
path: Tinker path to saved weights (e.g., "tinker://run-id/weights/checkpoint-001")
- `path`: Tinker path to saved weights (e.g., "tinker://run-id/weights/checkpoint-001")
Returns:
APIFuture containing the load response
- `APIFuture` containing the load response
Example:
```python
@ -290,10 +290,10 @@ def load_state_with_optimizer(
Load model weights and optimizer state from a checkpoint.
Args:
path: Tinker path to saved weights (e.g., "tinker://run-id/weights/checkpoint-001")
- `path`: Tinker path to saved weights (e.g., "tinker://run-id/weights/checkpoint-001")
Returns:
APIFuture containing the load response
- `APIFuture` containing the load response
Example:
```python
@ -325,10 +325,10 @@ def save_weights_for_sampler(
Save model weights for use with a SamplingClient.
Args:
name: Name for the saved sampler weights
- `name`: Name for the saved sampler weights
Returns:
APIFuture containing the save response with sampler path
- `APIFuture` containing the save response with sampler path
Example:
```python
@ -363,7 +363,7 @@ def get_info() -> types.GetInfoResponse
Get information about the current model.
Returns:
GetInfoResponse with model configuration and metadata
- `GetInfoResponse` with model configuration and metadata
Example:
```python
@ -393,7 +393,7 @@ def get_tokenizer() -> PreTrainedTokenizer
Get the tokenizer for the current model.
Returns:
PreTrainedTokenizer compatible with the model
- `PreTrainedTokenizer` compatible with the model
Example:
```python
@ -414,11 +414,11 @@ def create_sampling_client(
Create a SamplingClient from saved weights.
Args:
model_path: Tinker path to saved weights
retry_config: Optional configuration for retrying failed requests
- `model_path`: Tinker path to saved weights
- `retry_config`: Optional configuration for retrying failed requests
Returns:
SamplingClient configured with the specified weights
- `SamplingClient` configured with the specified weights
Example:
```python
@ -451,11 +451,11 @@ def save_weights_and_get_sampling_client(
Save current weights and create a SamplingClient for inference.
Args:
name: Optional name for the saved weights (currently ignored for ephemeral saves)
retry_config: Optional configuration for retrying failed requests
- `name`: Optional name for the saved weights (currently ignored for ephemeral saves)
- `retry_config`: Optional configuration for retrying failed requests
Returns:
SamplingClient configured with the current model weights
- `SamplingClient` configured with the current model weights
Example:
```python