Skip to content

Instantly share code, notes, and snippets.

@shafty023
shafty023 / REPORT.md
Created September 15, 2026 22:23
google.gemma-4-26b-a4b on Amazon Bedrock: nondeterministic greedy decoding, standalone repro and report

Nondeterministic greedy decoding for google.gemma-4-26b-a4b on Bedrock's OpenAI-compatible endpoint

Summary

On the Bedrock OpenAI-compatible chat completions endpoint, repeated identical requests to google.gemma-4-26b-a4b at temperature 0 (greedy decoding) do not return byte-identical completions once the output grows past a few hundred tokens, even though a short 24-token completion at the same setting is byte-identical every time. The divergence is structural, not cosmetic: for a JSON entity/relation extraction task the parsed edge count, edge set, and individual relation labels differ between runs on the same input. This matches an open vLLM issue reporting the same fingerprint on the same checkpoint under CUDA graph replay on specific GPU hardware, which suggests the nondeterminism may originate in the serving stack rather than in any client-side parameter handling.

Environment

  • Endpoint: https://bedrock-mantle.us-east-1.api.aws/openai/v1/chat/completions
  • Model id: `google.gemma-4-26b-a
@shafty023
shafty023 / check_skills.sh
Created November 19, 2025 14:26
claude skill activation hook
#!/bin/bash
# Hook: UserPromptSubmit
# Purpose: ENFORCE skill checking before starting work
# Return JSON with proper hookSpecificOutput structure per Claude Code docs
cat <<'EOF'
{
"decision": undefined ,
"reason": "n/a",
@shafty023
shafty023 / messy_prefs.kt
Last active June 10, 2020 00:47
Messy preferences
@Singleton
class Preferences(context: Context) {
private val prefs: SharedPreferences = context.getSharedPreferences("Prefs", Context.MODE_PRIVATE)
companion object {
const val PREF_CURRENT_STATE = "CurrentState"
const val PREF_LAST_KNOWN_ERROR = "LastKnownError"
const val PREF_LAST_ACTION_PERFORMED = "LastActionPerformed"
}
@shafty023
shafty023 / state_machine.kt
Created June 10, 2020 00:46
StateMachine
/**
* Keeps track of current and prior application state.
*
* @param dataStore storage
*/
@Singleton
class StateMachine(private val dataStore: DataStore) {
/**
* Storage implementation for our state machine.
*
/**
* A factory that can serialize/deserialize json.
*/
object GsonUtils {
/**
* Handles deserializing the json string into a [T] instance.
*
* @param json the json to deserialize into an instance of [T]
* @throws JsonSyntaxException if there is a failure deserializing then this exception is thrown
*/
@shafty023
shafty023 / datastore.kt
Last active June 10, 2020 00:37
DataStore
/**
* A storage implementation that enforces whole class serialization/deserialization.
*
* This enforces organization of data that needs to be persisted rather than having generic classes
* with lots of unrelated data.
*
* @param context the caller's context
*/
@Singleton
class DataStore(context: Context) {
@shafty023
shafty023 / encrypted_room_db.kt
Created June 9, 2020 23:19
Encrypted Room db
abstract class EncryptedDatabase : RoomDatabase() {
companion object {
fun getInstance(passcode: CharArray, context: Context):
EncryptedDatabase = buildDatabase(passcode, context)
private fun buildDatabase(
passcode: CharArray,
context: Context
): EncryptedDatabase {
// DatabaseKeyMgr is a singleton that all of the above code is wrapped into.
@shafty023
shafty023 / get_char_key.kt
Created June 9, 2020 23:10
Returns the db key
/**
* Returns the database key suitable for using with Room.
*
* @param passcode the user's passcode
* @param context the caller's context
*/
fun getCharKey(passcode: CharArray, context: Context): CharArray {
if (dbCharKey == null) {
initKey(passcode, context)
}
@shafty023
shafty023 / get_raw_byte_key.kt
Created June 9, 2020 23:02
Decrypts the Storable instance using a passcode
/**
* Decrypts the [Storable] instance using the [passcode].
*
* @pararm passcode the user's passcode
* @param storable the storable instance previously saved with [saveToPrefs]
* @return the raw byte key previously generated with [generateRandomKey]
*/
fun getRawByteKey(passcode: CharArray, storable: Storable): ByteArray {
val aesWrappedKey = Base64.decode(storable.key, Base64.DEFAULT)
val iv = Base64.decode(storable.iv, Base64.DEFAULT)
@shafty023
shafty023 / get_storable.kt
Last active August 7, 2020 00:13
Retrieve Storable instance from storage
/**
* Retrieves the [Storable] instance from prefs.
*
* @param context the caller's context
* @return the storable instance
*/
fun getStorable(context: Context): Storable? {
val prefs = context.getSharedPreferences("database",
Context.MODE_PRIVATE)
val serialized = prefs.getString("key", null)